forked from NangoHQ/nango
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (98 loc) · 3.95 KB
/
cli-verification.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: CLI Publish & Verify
on:
push:
branches:
- master
- staging/**
pull_request:
concurrency:
group: verify-cli-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
GIT_HASH: ${{ steps.publish_step.outputs.hash }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://npm.pkg.github.com'
scope: '@nangohq'
always-auth: true
- name: Build
run: |
npm ci
npm run ts-build
- name: Publish packages to github registry so they can be bumped
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
function check_and_publish {
PACKAGE_PATH=$1
PACKAGE_NAME=$(node -p "require('./${PACKAGE_PATH}/package.json').name")
PACKAGE_VERSION=$(node -p "require('./${PACKAGE_PATH}/package.json').version")
if npm view ${PACKAGE_NAME}@${PACKAGE_VERSION} ; then
echo "Version ${PACKAGE_VERSION} of ${PACKAGE_NAME} already exists. Skipping publish."
else
echo "Publishing ${PACKAGE_NAME}@${PACKAGE_VERSION}..."
pushd ./${PACKAGE_PATH}
npm publish --ignore-scripts
popd
fi
}
check_and_publish packages/node-client
check_and_publish packages/shared
check_and_publish packages/frontend
check_and_publish packages/types
check_and_publish packages/nango-yaml
- id: publish_step
name: Publish npm packages to the github registry
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
continue-on-error: true
run: |
GIT_HASH=$(git rev-parse HEAD)
echo "hash=${GIT_HASH}" >> "$GITHUB_OUTPUT"
bash ./scripts/publish.sh 0.0.1-$GIT_HASH
- name: Publish the cli privately under the correct scope
working-directory: packages/cli
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
jq '.name = "@nangohq/cli"' package.json > temp.json && mv temp.json package.json
npm publish
verify:
runs-on: ubuntu-latest
needs: publish
env:
NANGO_CLI_UPGRADE_MODE: ignore
GIT_HASH: ${{ needs.publish.outputs.GIT_HASH }}
permissions:
contents: read
packages: write
steps:
- uses: actions/setup-node@v4
with:
node-version: '20.12.2'
registry-url: 'https://npm.pkg.github.com'
scope: '@nangohq'
always-auth: true
- name: Install the cli from the github package registry
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm init -y
npm install nango@npm:@nangohq/[email protected]$GIT_HASH
VERSION_OUTPUT=$(npx nango version)
EXPECTED_VERSION="Nango CLI version: 0.0.1-$GIT_HASH"
[ "$VERSION_OUTPUT" = "$EXPECTED_VERSION" ] || { echo "Version mismatch. Expected: $EXPECTED_VERSION, got: $VERSION_OUTPUT"; exit 1; }
npx nango version --debug
npx nango init --debug
cd nango-integrations
npx nango generate --debug