Skip to content

Commit 1b0bd76

Browse files
committed
chore: refine release and sync workflows
- Simplified the release workflow by removing unnecessary output steps and streamlining the version bump process. - Enhanced the sync-patch workflow to allow cherry-picking commits with improved handling of conflicts and commit messages. - Updated job names and descriptions for clarity and consistency.
1 parent 163ab19 commit 1b0bd76

File tree

2 files changed

+85
-74
lines changed

2 files changed

+85
-74
lines changed

.github/workflows/release-stable.yml

Lines changed: 16 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ jobs:
2525
release:
2626
needs: test
2727
runs-on: ubuntu-latest
28-
outputs:
29-
version: ${{ steps.get-version.outputs.version }}
30-
released: ${{ steps.semantic-release.outputs.new-release-published }}
3128
steps:
3229
- uses: actions/checkout@v4
3330
with:
@@ -53,80 +50,45 @@ jobs:
5350
echo "Ref name: ${{ github.ref_name }}"
5451
5552
- name: Release to latest channel
56-
id: semantic-release
5753
env:
5854
GITHUB_TOKEN: ${{ secrets.SUPERDOC_PAT }}
5955
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
6056
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
61-
run: |
62-
# Run semantic-release and capture output
63-
npx semantic-release 2>&1 | tee release.log
64-
65-
# Check if a new release was published
66-
if grep -q "Published release" release.log; then
67-
echo "new-release-published=true" >> $GITHUB_OUTPUT
68-
else
69-
echo "new-release-published=false" >> $GITHUB_OUTPUT
70-
fi
57+
run: npx semantic-release
7158

72-
- name: Get released version
73-
id: get-version
74-
if: steps.semantic-release.outputs.new-release-published == 'true'
75-
run: |
76-
# Extract version from the latest git tag
77-
VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')
78-
echo "version=$VERSION" >> $GITHUB_OUTPUT
79-
echo "Released version: $VERSION"
80-
81-
bump-next-version:
59+
# Simple addition: bump main to next minor after stable release
60+
bump-main:
8261
needs: release
83-
if: needs.release.outputs.released == 'true'
8462
runs-on: ubuntu-latest
8563
steps:
8664
- uses: actions/checkout@v4
8765
with:
8866
token: ${{ secrets.SUPERDOC_PAT }}
89-
fetch-depth: 0
9067
ref: main
91-
68+
9269
- uses: actions/setup-node@v4
9370
with:
9471
node-version: 22
9572
cache: npm
96-
97-
- name: Setup Git
98-
run: |
99-
git config --global user.name "github-actions[bot]"
100-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
101-
73+
10274
- name: Install dependencies
10375
run: npm ci
104-
105-
- name: Bump to next minor version
76+
77+
- name: Bump to next minor
10678
run: |
107-
# Parse the released version
108-
VERSION="${{ needs.release.outputs.version }}"
109-
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
79+
git config user.name "github-actions[bot]"
80+
git config user.email "github-actions[bot]@users.noreply.github.com"
11081
111-
# Calculate next minor version
112-
NEXT_MAJOR=$MAJOR
113-
NEXT_MINOR=$((MINOR + 1))
114-
NEXT_VERSION="${NEXT_MAJOR}.${NEXT_MINOR}.0-next.0"
115-
116-
echo "Current stable version: $VERSION"
117-
echo "Next development version: $NEXT_VERSION"
82+
# Get version from release branch name (e.g., release/v0.16 -> 0.17.0-next.0)
83+
BRANCH="${GITHUB_REF#refs/heads/release/v}"
84+
IFS='.' read -r MAJOR MINOR <<< "$BRANCH"
85+
NEXT_VERSION="$MAJOR.$((MINOR + 1)).0-next.0"
11886
11987
# Update package.json
12088
cd packages/superdoc
12189
npm version "$NEXT_VERSION" --no-git-tag-version
12290
123-
# Commit the change
91+
# Commit and push
12492
git add package.json
125-
git commit -m "chore: bump to v${NEXT_VERSION} [skip ci]
126-
127-
Begin development for v${NEXT_MAJOR}.${NEXT_MINOR}.0 after stable release v${VERSION}"
128-
129-
# Push to main
130-
git push origin main
131-
132-
echo "✅ Successfully bumped main branch to v${NEXT_VERSION}"
93+
git commit -m "chore: begin v$NEXT_VERSION development [skip ci]"
94+
git push origin main

.github/workflows/sync-patches.yml

Lines changed: 69 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,90 @@ on:
77
- 'packages/**'
88
workflow_dispatch:
99
inputs:
10-
version:
11-
description: 'Release branch (e.g., release/v0.21, release/v1.0)'
12-
required: true
10+
commit:
11+
description: 'Commit SHA to cherry-pick (optional, defaults to latest)'
12+
required: false
1313
type: string
1414

1515
permissions:
1616
contents: write
1717
pull-requests: write
18+
issues: write
1819

1920
jobs:
20-
create-sync-pr:
21-
runs-on: ubuntu-latest
21+
sync-patch:
22+
runs-on: ubuntu-latest
23+
# Skip if release commit (auto mode only)
24+
if: |
25+
github.event_name == 'workflow_dispatch' ||
26+
(!contains(github.event.head_commit.message, '[skip ci]') &&
27+
!contains(github.event.head_commit.message, 'chore(release)') &&
28+
(contains(github.event.head_commit.message, 'fix:') ||
29+
contains(github.event.head_commit.message, 'fix(')))
30+
2231
steps:
2332
- uses: actions/checkout@v4
2433
with:
2534
fetch-depth: 0
2635
token: ${{ secrets.SUPERDOC_PAT }}
27-
28-
- name: Create sync PR
36+
37+
- name: Cherry-pick to main
2938
env:
3039
GH_TOKEN: ${{ secrets.SUPERDOC_PAT }}
3140
run: |
32-
BRANCH=${{ inputs.version }}
41+
git config user.name "github-actions[bot]"
42+
git config user.email "github-actions[bot]@users.noreply.github.com"
43+
44+
# Determine commit to cherry-pick
45+
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.commit }}" ]; then
46+
COMMIT="${{ inputs.commit }}"
47+
else
48+
COMMIT="${{ github.sha }}"
49+
fi
3350
34-
# Create PR (or update existing)
35-
gh pr create \
36-
--base main \
37-
--head "$BRANCH" \
38-
--title "🔄 Sync: $BRANCH → main" \
39-
--body "Auto-sync patches from release branch.
51+
# Create patch branch from main
52+
git fetch origin main
53+
PATCH_BRANCH="patch-${COMMIT:0:7}"
54+
git checkout -b "$PATCH_BRANCH" origin/main
55+
56+
# Try cherry-pick
57+
if git cherry-pick "$COMMIT"; then
58+
# Success - push and create PR
59+
git push origin "$PATCH_BRANCH"
60+
61+
# Get commit message
62+
COMMIT_MSG=$(git log -1 --pretty=format:"%s" "$COMMIT")
4063
41-
**Branch:** $BRANCH
42-
**Commits:** ${{ github.event.head_commit.message }}
64+
gh pr create \
65+
--base main \
66+
--head "$PATCH_BRANCH" \
67+
--title "🔄 $COMMIT_MSG" \
68+
--body "Cherry-pick fix from ${{ github.ref_name }}
69+
70+
Original commit: $COMMIT
71+
72+
This PR cherry-picks a fix from the release branch to main." \
73+
--label "patch-sync" \
74+
--label "automerge"
75+
else
76+
# Conflict - create issue for manual resolution
77+
COMMIT_MSG=$(git log -1 --pretty=format:"%s" "$COMMIT" || echo "Unknown commit")
4378
44-
This PR will auto-merge after tests pass." \
45-
--label "patch-sync" \
46-
|| gh pr edit \
47-
--add-label "patch-sync"
79+
gh issue create \
80+
--title "🔄 Manual sync needed: $COMMIT_MSG" \
81+
--body "Failed to auto-sync patch from ${{ github.ref_name }} due to conflicts.
82+
83+
**Commit**: $COMMIT
84+
**Branch**: ${{ github.ref_name }}
85+
86+
Please manually cherry-pick this fix to main:
87+
\`\`\`bash
88+
git checkout main
89+
git pull
90+
git cherry-pick $COMMIT
91+
# Resolve conflicts, then:
92+
git push
93+
\`\`\`" \
94+
--label "patch-sync" \
95+
--label "needs-manual-sync"
96+
fi

0 commit comments

Comments
 (0)