Skip to content

Commit

Permalink
ci: retrieve next version from the real release attempt
Browse files Browse the repository at this point in the history
This allows us to see the output of `semantic-release` while also
capturing the version and exporting it for use in future steps.
  • Loading branch information
trezy committed Aug 1, 2024
1 parent 3e29c02 commit bbfd496
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/handle-release-branch-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,18 @@ jobs:
run: npm run build
shell: bash

- name: Get Next Release Version
- name: Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: get_release_version
id: release
run: |
export NEXT_TAG_VERSION=$(npx semantic-release --dry-run | grep 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/')
export NEXT_TAG_VERSION=$(npx semantic-release | grep 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/')
echo "new_tag_version=${NEXT_TAG_VERSION}" >> $GITHUB_OUTPUT
shell: bash

- name: Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ steps.get_release_version.outputs.new_tag_version != '' }}
run: npx semantic-release
shell: bash

- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ steps.get_release_version.outputs.new_tag_version != '' }}
if: ${{ steps.release.outputs.new_tag_version != '' }}
run: npm publish ./dist/*.tgz --tag ${{ (github.head_ref || github.ref_name) == 'main' && 'latest' || github.head_ref || github.ref_name }}
shell: bash

0 comments on commit bbfd496

Please sign in to comment.