Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/check-version-update-on-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- 'release/*'

defaults:
run:
shell: bash -o pipefail {0}

jobs:
check:
runs-on: ubuntu-latest
Expand Down
53 changes: 34 additions & 19 deletions .github/workflows/test-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
branches:
- main

defaults:
run:
shell: bash -o pipefail {0}

jobs:
audit:
name: Audit
Expand Down Expand Up @@ -74,40 +78,51 @@ jobs:
name: coverage
path: coverage

publish:
detect_version_update:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
name: Publish on version update
needs:
- test
permissions:
contents: read
id-token: write
name: Detect version update
runs-on: ubuntu-latest
outputs:
detected: ${{ steps.detect.outputs.detected }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version-file: '/.nvmrc'
registry-url: 'https://registry.npmjs.org'
fetch-depth: 2

- name: Check for version update
id: check_version
- id: detect
run: |
CURRENT_VERSION=$(jq -r .version package.json)
PREVIOUS_VERSION=$(git show HEAD~1:package.json | jq -r .version)

if [[ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]]; then
echo "version_updated=true" >> $GITHUB_OUTPUT
echo "Version has been updated. Proceeding to publish."
echo "detected=true" >> $GITHUB_OUTPUT
else
echo "Version has not changed. Skipping publish."
echo "detected=false" >> $GITHUB_OUTPUT
fi

- if: steps.check_version.outputs.version_updated
run: npm ci
publish:
name: Publish
needs:
- test
- detect_version_update
if: needs.detect_version_update.outputs.detected == 'true'
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version-file: '/.nvmrc'
registry-url: 'https://registry.npmjs.org'

- if: steps.check_version.outputs.version_updated
run: npm run build
- run: npm ci
- run: npm run build

- if: steps.check_version.outputs.version_updated
name: Publish
- name: Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
Expand Down