-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: improve version handling in cd pipeline
- automatically bump the version before publishing to npm - split release & pre-release pipelines to make them simpler to maintain
- Loading branch information
1 parent
ec7c6aa
commit 6c225eb
Showing
2 changed files
with
51 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,9 @@ on: | |
push: | ||
branches: | ||
- "main" | ||
- "release/*" | ||
|
||
jobs: | ||
deploy: | ||
permissions: | ||
packages: write | ||
contents: read | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
|
@@ -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 }} | ||
|
||
|
@@ -28,7 +24,7 @@ jobs: | |
|
||
- name: Compile Typescript | ||
run: yarn build | ||
|
||
- name: Run tests | ||
run: yarn test | ||
|
||
|
@@ -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') | ||
|
@@ -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 |