Skip to content

Commit

Permalink
Prevent publish job if version does not change (#104)
Browse files Browse the repository at this point in the history
## Description

<!-- Describe your changes in detail -->
<!-- Does this fix a bug, implement a new feature, etc? -->
This should prevent the publish job from failing when I don't actually
intend for it to run. Not all merges should trigger a deploy/publish.

### Related Issue(s)

<!-- Reference the issue this PR relates to -->
<!-- Use keywords if possible (ex. Closes #10 ) -->
<!--
https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests
-->

## Screenshots

<!-- (if applicable) -->
  • Loading branch information
riccjohn authored Feb 23, 2025
2 parents d5ebd19 + 28a3bcd commit 74931d8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,21 @@ jobs:
run: pnpm lint
- name: Build project
run: pnpm run build
- name: Extract package version
id: extract_version
run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- name: Check if version matches tag
id: check_version
run: |
tag_name="${{ github.ref_name }}"
package_version="${{ steps.extract_version.outputs.version }}"
if [[ "$tag_name" == "$package_version" || "$tag_name" == *"$package_version-alpha"* || "$tag_name" == *"$package_version-beta"* || "$tag_name" == *"$package_version-canary"* ]]; then
echo "::set-output name=should_publish::true"
else
echo "::set-output name=should_publish::false"
fi
- name: Publish package to NPM
if: steps.check_version.outputs.should_publish == 'true'
run: |
if [[ "${{ github.ref_name }}" == *-alpha* ]]; then
pnpm publish --access public --tag alpha
Expand Down

0 comments on commit 74931d8

Please sign in to comment.