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
50 changes: 50 additions & 0 deletions .github/workflows/alpha-bootstrap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Alpha Bootstrap

on:
create:

permissions:
contents: write
pull-requests: write

jobs:
bootstrap:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Filter only alpha/*.*.* branch creation
id: guard
run: |
RAW_REF="${GITHUB_REF_NAME}" # created branch name
if [[ "$RAW_REF" != alpha/*.*.* ]]; then
echo "Not an alpha/*.*.* branch: $RAW_REF. Exiting."; echo "continue=false" >> $GITHUB_OUTPUT; exit 0; fi
echo "continue=true" >> $GITHUB_OUTPUT
- name: Stop if not alpha pattern
if: steps.guard.outputs.continue != 'true'
run: echo "Skipped"
- name: Derive release branch name
if: steps.guard.outputs.continue == 'true'
id: names
run: |
RAW_REF="${GITHUB_REF_NAME}" # alpha/x.x.x
BASE=${RAW_REF#alpha/}
echo "release_branch=release/$BASE" >> $GITHUB_OUTPUT
- name: Create release branch
if: steps.guard.outputs.continue == 'true'
run: |
git config user.name 'github-actions'
git config user.email 'github-actions@users.noreply.github.com'
git checkout -b "${{ steps.names.outputs.release_branch }}"
git push origin "${{ steps.names.outputs.release_branch }}"
- name: Comment info
if: steps.guard.outputs.continue == 'true'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: 1
body: |
Created release branch `${{ steps.names.outputs.release_branch }}` for alpha `${{ github.ref_name }}`.
(Adjust this workflow to post elsewhere if desired.)
86 changes: 86 additions & 0 deletions .github/workflows/alpha-merge-beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Alpha Merge -> Beta Publish

on:
pull_request:
types: [closed]
branches:
- 'alpha/**'

permissions:
contents: write
packages: write

jobs:
beta-publish:
if: github.event.pull_request.merged == true && startsWith(github.base_ref, 'alpha/')
runs-on: ubuntu-latest
env:
WASM_PACK_VERSION: 0.12.1
steps:
- name: Checkout full history
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Derive base version
id: base
run: |
# base branch name alpha/x.y.z
BASE_BRANCH="${GITHUB_BASE_REF}" # alpha/1.2.3
RAW=${BASE_BRANCH#alpha/}
echo "raw=$RAW" >> $GITHUB_OUTPUT
- name: Find latest beta tag
id: find
run: |
RAW=${{ steps.base.outputs.raw }}
# list existing beta tags vRAW-beta.N
LAST=$(git tag --list "v${RAW}-beta.*" | sed -E 's/.*-beta\.([0-9]+)/\1/' | sort -n | tail -1)
if [ -z "$LAST" ]; then NEXT=0; else NEXT=$((LAST+1)); fi
echo "next=$NEXT" >> $GITHUB_OUTPUT
echo "Will create beta index $NEXT for $RAW"
- name: Bump Cargo.toml versions (beta)
run: |
RAW=${{ steps.base.outputs.raw }}
BETA_IDX=${{ steps.find.outputs.next }}
VERSION="${RAW}-beta.${BETA_IDX}"
for FILE in crates/source_map_parser/Cargo.toml crates/node_sdk/Cargo.toml; do
awk -v ver="$VERSION" 'BEGIN{done=0} /^version *=/ && done==0 {print "version = \"" ver "\""; done=1; next} {print}' "$FILE" > /tmp/_tmp && mv /tmp/_tmp "$FILE"
done
# sync dependency inside node_sdk
sed -i.bak -E "s/source_map_parser = \{ version = \"[^\"]+\"/source_map_parser = { version = \"$VERSION\"/" crates/node_sdk/Cargo.toml || true
rm -f crates/node_sdk/Cargo.toml.bak
echo "Updated versions to $VERSION"
- name: Commit version bump to alpha & cherry-pick to release
run: |
git config user.name 'github-actions'
git config user.email 'github-actions@users.noreply.github.com'
RAW=${{ steps.base.outputs.raw }}
BETA_IDX=${{ steps.find.outputs.next }}
VERSION="${RAW}-beta.${BETA_IDX}"
git add crates/*/Cargo.toml
git commit -m "chore(release): v$VERSION" || echo "No changes"
# push to alpha
git push origin "${GITHUB_BASE_REF}" || true
# update release branch
REL_BRANCH="release/${RAW}"
git fetch origin "$REL_BRANCH":"$REL_BRANCH" || true
git checkout "$REL_BRANCH"
git cherry-pick "${GITHUB_BASE_REF}" || echo "Cherry-pick skipped"
git push origin "$REL_BRANCH" || true
# back to alpha
git checkout "${GITHUB_BASE_REF}"
- name: Generate CHANGELOG fragment
run: |
chmod +x scripts/generate-changelog.sh || true
RAW=${{ steps.base.outputs.raw }}
BETA_IDX=${{ steps.find.outputs.next }}
VERSION="${RAW}-beta.${BETA_IDX}"
./scripts/generate-changelog.sh "$VERSION" "${{ github.server_url }}/${{ github.repository }}" || echo "No changelog script"
- name: Create beta tag & push
run: |
RAW=${{ steps.base.outputs.raw }}
BETA_IDX=${{ steps.find.outputs.next }}
VERSION="${RAW}-beta.${BETA_IDX}"
git tag "v$VERSION"
git push origin "v$VERSION"
- name: Trigger release workflow (uses tag push)
run: echo "Tag pushed triggers existing Release workflow"
80 changes: 80 additions & 0 deletions .github/workflows/finalize-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
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
145 changes: 145 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Prepare Release

on:
workflow_dispatch:
inputs:
bump_type:
description: 'Version bump type (major|minor|patch|premajor|preminor|prepatch|prerelease)'
required: true
default: patch
preid:
description: 'Pre-release identifier (beta|rc|alpha)'
required: false
default: beta
dry_run:
description: 'Dry run (true = no branch/PR)'
required: false
default: 'false'

permissions:
contents: write
pull-requests: write

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
next_version: ${{ steps.calc.outputs.next_version }}
is_prerelease: ${{ steps.calc.outputs.is_prerelease }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq

- name: Calculate next version
id: calc
env:
BUMP: ${{ github.event.inputs.bump_type }}
PREID: ${{ github.event.inputs.preid }}
run: |
set -e
CORE_FILE=crates/source_map_parser/Cargo.toml
NODE_FILE=crates/node_sdk/Cargo.toml
CURRENT=$(grep '^version' $CORE_FILE | head -1 | cut -d '"' -f2)
echo "Current version: $CURRENT"

base_version() {
echo "$1" | sed -E 's/(-|\+).*//'
}

inc_semver() {
local ver=$1 part=$2
IFS='.' read -r MA MI PA <<<"$ver"
case $part in
major) MA=$((MA+1)); MI=0; PA=0;;
minor) MI=$((MI+1)); PA=0;;
patch) PA=$((PA+1));;
*) echo "Unknown bump" >&2; exit 1;;
esac
echo "${MA}.${MI}.${PA}"
}

is_prerelease=false
case $BUMP in
premajor|preminor|prepatch|prerelease)
is_prerelease=true
;;
esac

BASE=$(base_version "$CURRENT")

if [[ $BUMP == premajor || $BUMP == preminor || $BUMP == prepatch ]]; then
case $BUMP in
premajor) BASE=$(inc_semver "$BASE" major);;
preminor) BASE=$(inc_semver "$BASE" minor);;
prepatch) BASE=$(inc_semver "$BASE" patch);;
esac
NEXT_BASE=$BASE
SEQ=0
elif [[ $BUMP == prerelease ]]; then
NEXT_BASE=$BASE
# find last prerelease with same base
LAST=$(git tag --list "v${BASE}-${PREID}.*" | sed -E 's/^v[0-9]+\.[0-9]+\.[0-9]+-'"$PREID"'\.([0-9]+)$/\1/' | sort -n | tail -1)
if [[ -z $LAST ]]; then SEQ=0; else SEQ=$((LAST+1)); fi
else
# normal bump
NEXT_BASE=$(inc_semver "$BASE" $BUMP)
fi

if [[ $is_prerelease == true ]]; then
NEXT_VERSION="${NEXT_BASE}-${PREID}.${SEQ:-0}"
else
NEXT_VERSION="$NEXT_BASE"
fi

echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "is_prerelease=$is_prerelease" >> $GITHUB_OUTPUT
echo "Next: $NEXT_VERSION"

- name: Update versions in Cargo.toml
run: |
NV=${{ steps.calc.outputs.next_version }}
for f in crates/source_map_parser/Cargo.toml crates/node_sdk/Cargo.toml; do
awk -v ver="$NV" 'BEGIN{done=0} /^version *=/ && done==0 {print "version = \"" ver "\""; done=1; next} {print}' "$f" > /tmp/_tmp && mv /tmp/_tmp "$f"
done
# sync dependency in node_sdk
sed -i "s/version = \"[0-9A-Za-z.-]*\" }/version = \"$NV\" }/" crates/node_sdk/Cargo.toml
echo "Updated versions to $NV"
grep '^version' crates/source_map_parser/Cargo.toml | head -1
grep '^version' crates/node_sdk/Cargo.toml | head -1

- name: Generate changelog (preview)
run: |
chmod +x scripts/generate-changelog.sh || true
./scripts/generate-changelog.sh ${{ steps.calc.outputs.next_version }} "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" || echo "Changelog script skipped"
head -100 CHANGELOG.md || true

- name: Dry run stop
if: github.event.inputs.dry_run == 'true'
run: |
echo "Dry run requested. No branch or PR created."; exit 0

- name: Create release branch & commit
run: |
NV=${{ steps.calc.outputs.next_version }}
BR=chore/release-v$NV
git config user.name 'github-actions'
git config user.email 'github-actions@users.noreply.github.com'
git checkout -b "$BR"
git add crates/*/Cargo.toml CHANGELOG.md || true
git commit -m "chore(release): v$NV"
git push origin "$BR"

- name: Open PR
uses: peter-evans/create-pull-request@v6
with:
branch: chore/release-v${{ steps.calc.outputs.next_version }}
title: 'chore(release): v${{ steps.calc.outputs.next_version }}'
body: |
Prepare release v${{ steps.calc.outputs.next_version }}
- bump type: ${{ github.event.inputs.bump_type }}
- prerelease: ${{ steps.calc.outputs.is_prerelease }} (preid=${{ github.event.inputs.preid }})
labels: release
Loading
Loading