Skip to content

Commit

Permalink
chore(ci): support semver prerelease (#1484)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocorradini authored Aug 13, 2023
1 parent feaa447 commit 5143050
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: ci
on:
push:
branches: [master]
tags: ['^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$']
tags: ['^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)-?.*$']
pull_request:
branches: [master]

Expand Down Expand Up @@ -134,6 +134,24 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Read package.json version
uses: sergeysova/jq-action@v2
id: version
with:
cmd: jq --raw-output .version package.json

- name: Determine if version is prerelease
id: prerelease
run: |
_prerelease=
if printf "%s\n" "${{ steps.version.outputs.value }}" | grep -q -P '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$'; then
_prerelease=false
else
_prerelease=true
fi
printf 'value=%s\n' "$_prerelease" >> "$GITHUB_OUTPUT"
- name: Setup Node.js
uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -168,10 +186,18 @@ jobs:
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.changelog.outputs.changelog }}
prerelease: ${{ steps.prerelease.outputs.value == 'true' }}

- name: Publish
run: |
npm publish --ignore-scripts
_tag=
if [ "${{ steps.prerelease.outputs.value }}" = "true" ];
_tag="next"
else
_tag="latest"
fi
npm publish --ignore-scripts --tag "$_tag"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down

0 comments on commit 5143050

Please sign in to comment.