Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nan-668] add verification bash script to publish packages #1930

Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1be386a
[nan-668] add verification bash script to publish packages
khaliqgant Apr 1, 2024
e7d6736
[nan-668] skip version check
khaliqgant Apr 1, 2024
ebbaef5
[nan-668] fix hash check
khaliqgant Apr 1, 2024
e3468d4
[nan-668] add token
khaliqgant Apr 1, 2024
48ac9d4
[nan-668] set npmrc
khaliqgant Apr 1, 2024
1c2ce3c
[nan-668] debug
khaliqgant Apr 1, 2024
693bc99
Merge branch 'master' of github.com:NangoHQ/nango into khaliq/nan-668…
khaliqgant Apr 1, 2024
c739262
[nan-668] build and ignore scripts
khaliqgant Apr 1, 2024
b2df7af
[nan-668] publish from the github action
khaliqgant Apr 1, 2024
e400702
[nan-668] ignore scripts and build at each stage
khaliqgant Apr 1, 2024
bb6769e
[nan-668] build hosted
khaliqgant Apr 1, 2024
36f5e7d
[nan-668] explicit with the npmrc
khaliqgant Apr 1, 2024
d35efe8
[nan-668] remove package specific npmrc
khaliqgant Apr 1, 2024
10ff590
[nan-668] workspaces-update to false
khaliqgant Apr 1, 2024
9777444
[nan-668] install shared version
khaliqgant Apr 1, 2024
cfdf267
[nan-668] debug
khaliqgant Apr 1, 2024
3615e9f
[nan-668] always auth
khaliqgant Apr 1, 2024
ac8c2f3
[nan-668] override package.json
khaliqgant Apr 1, 2024
18ec0ca
[nan-668] fix path
khaliqgant Apr 1, 2024
c852337
[nan-668] install after updating the package.json
khaliqgant Apr 1, 2024
0d2f23e
[nan-668] bump all and publish
khaliqgant Apr 1, 2024
90f0549
[nan-668] ref correct package
khaliqgant Apr 1, 2024
45376ec
[nan-668] build before publishing
khaliqgant Apr 2, 2024
b1f2693
[nan-668] install after each step
khaliqgant Apr 2, 2024
7144770
[nan-668] remove wonk
khaliqgant Apr 2, 2024
2098fd5
[nan-668] remove short
khaliqgant Apr 2, 2024
27726fb
[nan-668] publish cli under scope
khaliqgant Apr 2, 2024
72af132
[nan-668] no need to bump
khaliqgant Apr 2, 2024
95dc821
[nan-668] correct package reference
khaliqgant Apr 2, 2024
b644104
install in tmp directory
khaliqgant Apr 2, 2024
7dfcdb5
[nan-668] make dir
khaliqgant Apr 2, 2024
ec42c9f
[nan-668] correct scope
khaliqgant Apr 2, 2024
cf9b4b4
[nan-668] navigate out of the repo
khaliqgant Apr 2, 2024
23804b4
[nan-668] global install and test
khaliqgant Apr 2, 2024
33fcf09
[nan-668] init and generate
khaliqgant Apr 2, 2024
2cb08a1
[nan-668] local install and use npx
khaliqgant Apr 2, 2024
a6c639b
[nan-668] ignore mode
khaliqgant Apr 2, 2024
f9448fc
[nan-668] cd into nango integrations before trying to generate
khaliqgant Apr 2, 2024
9706481
[nan-668] verify version
khaliqgant Apr 3, 2024
97915e0
[nan-668] fail on purpose
khaliqgant Apr 3, 2024
720da7a
[nan-668] add expected version format
khaliqgant Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/cli-verification.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the cli published by running the publish.sh script in the previous step? why do we need to publish it again?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It attempts to publish it but fails because it is not scoped under our organization @nangohq which is why I rename the package and publish it separately.

- 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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not doing that directly then?
Also doesn't it will publish @nangohq/node and @nangohq/shared every time for nothing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not doing that directly then?

Easier to reuse the script which bumps the references and packages correctly.

Also doesn't it will publish @nangohq/node and @nangohq/shared every time for nothing?

Shared needs to be published, node is published again and not used as is frontend but there is no harm in publishing those packages.

- 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
npx nango version --debug
bodinsamuel marked this conversation as resolved.
Show resolved Hide resolved
bodinsamuel marked this conversation as resolved.
Show resolved Hide resolved
npx nango init --debug
cd nango-integrations
npx nango generate --debug
6 changes: 3 additions & 3 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-<commit hash>
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-<commit hash>"
exit 1
fi

Expand Down
Loading