Skip to content

Commit

Permalink
ci: improve version handling in cd pipeline
Browse files Browse the repository at this point in the history
- automatically bump the version before publishing to npm
- split release & pre-release pipelines to make them simpler
to maintain
  • Loading branch information
ebomcke-awell committed Jun 5, 2023
1 parent ec7c6aa commit 6c225eb
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 16 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish pre-release package

on:
push:
branches:
- "release/*"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: yarn install
run: yarn

- name: Compile Typescript
run: yarn build

- name: Setup .yarnrc.yml
run: |
yarn config set npmAlwaysAuth true
yarn config set npmAuthToken $NPM_AUTH_TOKEN
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AWELL_EXTENSIONS_CI }}

- name: Publish to NPM Registry
run: |
pkg_version=$(cat package.json | jq -r '.version')
yarn version "$pkg_version-beta$GITHUB_RUN_NUMBER"
yarn npm publish --tag beta --access public
28 changes: 12 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ on:
push:
branches:
- "main"
- "release/*"

jobs:
deploy:
permissions:
packages: write
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -19,7 +15,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: "18"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -28,7 +24,7 @@ jobs:

- name: Compile Typescript
run: yarn build

- name: Run tests
run: yarn test

Expand All @@ -41,15 +37,8 @@ jobs:

- name: Publish to NPM Registry
run: |
pkg_version=$(cat package.json | jq -r '.version')
branch=${GITHUB_REF##*/}
if [[ $branch != "main" ]]; then
yarn version "$pkg_version-beta$GITHUB_RUN_NUMBER"
yarn npm publish --tag beta --access public
else
yarn npm publish --access public
fi
yarn version -i patch
yarn npm publish --access public
- name: Redeploy the extension server
run: |
CURRENT_VERSION=$(cat package.json | jq -r '.version')
Expand All @@ -60,4 +49,11 @@ jobs:
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/awell-health/awell-extension-server/actions/workflows/update-dependency.yml/dispatches \
-d '{"ref":"main","inputs":{"dependency":"@awell-health/awell-extensions","version":"'"$CURRENT_VERSION"'"}}'
- name: Commit and push updated version
run: |
git config --global user.name "Awell CI"
git config --global user.email "[email protected]"
git add package.json .yarn/versions
git commit -m "ci: bump version"
git push

0 comments on commit 6c225eb

Please sign in to comment.