diff --git a/.github/workflows/cli-verification.yaml b/.github/workflows/cli-verification.yaml new file mode 100644 index 00000000000..9bcc0af3b92 --- /dev/null +++ b/.github/workflows/cli-verification.yaml @@ -0,0 +1,60 @@ +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-and-test: + runs-on: ubuntu-latest + env: + NANGO_CLI_UPGRADE_MODE: ignore + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '18.x' + registry-url: 'https://npm.pkg.github.com' + scope: '@nangohq' + always-auth: true + - 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) + 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 --access public + - name: Install the cli from the github package registry + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + GIT_HASH=$(git rev-parse HEAD) + mkdir nango-cli-test && cd nango-cli-test + npm init -y + npm install @nangohq/cli@0.0.1-$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 diff --git a/scripts/publish.sh b/scripts/publish.sh index d936eae1874..c8013e8b824 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -20,9 +20,9 @@ function bump_and_npm_publish { GIT_ROOT_DIR=$(git rev-parse --show-toplevel) VERSION=$1 -# ensure version is of format x.y.z -if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "VERSION '$VERSION' is not of format x.y.z" +# ensure version is of format x.y.z or 0.0.1- +if [[ ! "$VERSION" =~ ^([0-9]+\.[0-9]+\.[0-9]+|0\.0\.1-[0-9a-fA-F]{40})$ ]]; then + echo "VERSION '$VERSION' is not of format x.y.z or 0.0.1-" exit 1 fi