Skip to content

Derive CLI version from package metadata (#77) #2

Derive CLI version from package metadata (#77)

Derive CLI version from package metadata (#77) #2

name: Sync package versions on release
on:
push:
tags:
- 'v*.*.*'
- 'v*.*.*-*'
concurrency:
group: sync-package-versions
cancel-in-progress: true
permissions:
contents: write
jobs:
sync:
name: Sync package versions from release tag
runs-on: ubuntu-latest
steps:
- name: Extract version from tag
id: extract
env:
TAG_NAME: ${{ github.ref_name }}
run: |
VERSION="${TAG_NAME#v}"
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid release tag: $TAG_NAME" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Release version: $VERSION"
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
fetch-tags: true
token: ${{ secrets.PUSH_TOKEN || secrets.GITHUB_TOKEN }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Update versioned files
env:
VERSION: ${{ steps.extract.outputs.version }}
run: node scripts/set-release-version.mjs "$VERSION"
- name: Commit and push if changed
env:
VERSION: ${{ steps.extract.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add packages/cli/package.json packages/core/package.json
if git diff --cached --quiet; then
echo "No version changes to commit"
exit 0
fi
git commit -m "chore(release): sync package version to $VERSION [skip ci]"
git push