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
27 changes: 27 additions & 0 deletions .github/workflows/check-version-update-on-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Check Version update on release

on:
pull_request:
branches:
- 'release/*'

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- run: |
CHANGED_FILES=$(git diff --name-only "origin/${{ github.base_ref }}...HEAD")

if ! echo "${CHANGED_FILES}" | grep -qx "package.json"; then
echo "::error::Release PRs must include an update to package.json."
exit 1
fi

if ! echo "${CHANGED_FILES}" | grep -qx "package-lock.json"; then
echo "::error::Release PRs must include an update to package-lock.json."
exit 1
fi
26 changes: 19 additions & 7 deletions .github/workflows/test-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
Expand Down Expand Up @@ -77,25 +75,39 @@ jobs:
path: coverage

publish:
name: Publish
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
name: Publish on version update
needs:
- test
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version-file: '/.nvmrc'
registry-url: 'https://registry.npmjs.org'

- run: npm ci
- run: npm run build
- name: Check for version update
id: check_version
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
fi

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

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

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