Skip to content

.github/workflows/finalize-release.yml #3

.github/workflows/finalize-release.yml

.github/workflows/finalize-release.yml #3

name: Finalize Release (Stable)
on:
workflow_dispatch:
inputs:
target:
description: 'Release base version x.y.z (without v prefix)'
required: true
dry_run:
description: 'Dry run (no tag push / PR)'
required: false
default: 'false'
permissions:
contents: write
pull-requests: write
jobs:
finalize:
runs-on: ubuntu-latest
env:
WASM_PACK_VERSION: 0.12.1
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate release branch context
run: |
TARGET='${{ inputs.target }}'
if [[ ! $TARGET =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Target must be x.y.z"; exit 1; fi
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
EXPECT="release/${TARGET}"
if [ "$CURRENT_BRANCH" != "$EXPECT" ]; then
echo "Must run on $EXPECT branch (current $CURRENT_BRANCH)"; exit 1; fi
- name: Ensure Cargo.toml uses stable version (no pre)
run: |
TARGET='${{ inputs.target }}'
for FILE in crates/source_map_parser/Cargo.toml crates/node_sdk/Cargo.toml; do
CUR=$(grep '^version' "$FILE" | head -1 | cut -d '"' -f2)
if echo "$CUR" | grep -qE 'alpha|beta|rc'; then
echo "Updating $FILE -> $TARGET"
awk -v ver="$TARGET" 'BEGIN{done=0} /^version *=/ && done==0 {print "version = \"" ver "\""; done=1; next} {print}' "$FILE" > /tmp/_tmp && mv /tmp/_tmp "$FILE"
fi
done
# sync dependency version
sed -i.bak -E "s/source_map_parser = \{ version = \"[^\"]+\"/source_map_parser = { version = \"$TARGET\"/" crates/node_sdk/Cargo.toml || true
rm -f crates/node_sdk/Cargo.toml.bak
git diff --name-only || true
- name: Commit stable bump
run: |
TARGET='${{ inputs.target }}'
if [ -n "$(git status --porcelain)" ]; then
git config user.name 'github-actions'
git config user.email 'github-actions@users.noreply.github.com'
git add crates/*/Cargo.toml
git commit -m "chore(release): v$TARGET stable"
git push origin HEAD
else
echo "No version bump needed"
fi
- name: Generate CHANGELOG
run: |
chmod +x scripts/generate-changelog.sh || true
./scripts/generate-changelog.sh '${{ inputs.target }}' "${{ github.server_url }}/${{ github.repository }}" || echo 'No changelog script'
- name: Create tag
if: inputs.dry_run != 'true'
run: |
TARGET='${{ inputs.target }}'
git tag "v$TARGET"
git push origin "v$TARGET"
- name: Open PR back to main
if: inputs.dry_run != 'true'
uses: peter-evans/create-pull-request@v6
with:
branch: chore/merge-release-v${{ inputs.target }}
title: 'chore: merge release v${{ inputs.target }} into main'
body: 'Stable release v${{ inputs.target }} merge back to main'
base: main
labels: release