Skip to content
Merged
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
29 changes: 12 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,24 @@ jobs:
- name: Clone the repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Update embedded version numbers
- name: Check embedded version numbers
run: |
sed -E -i "/uses:/s/v[0-9]+\\.[0-9]+\\.[0-9]+/${GITHUB_REF_NAME}/" README.md
jq --arg v "${GITHUB_REF_NAME#v}" '.version = $v' package.json >package.json.tmp && mv package.json.tmp package.json
if [[ -n "$(git diff --stat)" ]]; then
git config user.name '${{ github.actor }}'
git config user.email '${{ github.actor }}@users.noreply.github.com'
git add README.md package.json
git commit --message "Bump version to ${GITHUB_REF_NAME}" || :
git push origin 'HEAD:${{ github.event.repository.default_branch }}'
git tag --force "${GITHUB_REF_NAME}" HEAD
git push origin "${GITHUB_REF_NAME}" --force
version="$(grep -F "uses: ${GITHUB.REPOSITORY}@" README.md | cut -d@ -f2)"
Copy link

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider ensuring that the grep command returns only a single version value. If multiple matches are possible, you might use a command like 'head -1' to avoid ambiguity.

Suggested change
version="$(grep -F "uses: ${GITHUB.REPOSITORY}@" README.md | cut -d@ -f2)"
version="$(grep -F "uses: ${GITHUB.REPOSITORY}@" README.md | head -1 | cut -d@ -f2)"

Copilot uses AI. Check for mistakes.
if [[ ${version} != "${GITHUB_REF_NAME}" ]]; then
line="$(grep -Fn "uses: ${GITHUB.REPOSITORY}@" README.md | cut -d: -f1)"
printf '::error file=README.md,line=%d::version does not match tag\n' "${line}"
rc=1
Copy link

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clarity and to ensure a consistent exit code variable, consider initializing 'rc' at the beginning of the block (e.g., 'rc=0') before any conditional checks.

Copilot uses AI. Check for mistakes.
fi
if [[ $(jq -r .version package.json) != "${GITHUB_REF_NAME}" ]]; then
line="$(grep -Fn '"version":' package.json | cut -d: -f1)"
printf '::error file=package.json,line=%d::version does not match tag\n' "${line}"
rc=1
fi
exit "${rc:-0}"

- name: Create the release
run: |
gh release create "${GITHUB_REF_NAME}" --fail-on-no-commits --notes-from-tag --verify-tag \
--draft # FIXME
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- if: false # FIXME
name: Move the major version tag
run: |-
git tag --force "${GITHUB_REF_NAME%%.*}" "${GITHUB_REF_NAME}^{}"
git push origin "${GITHUB_REF_NAME%%.*}" --force
Loading