Skip to content

Commit 1a1f6b9

Browse files
authored
refactor: simplify release flow (#425)
* refactor: simplify release flow — remove CHANGELOG.md, .changes files, draft release - release-assistant.yml: rename release-gate→release-assistant, remove .changes validation - gen-release-pr.yml: remove CHANGELOG.md updates, .changes processing, draft release creation; trigger after Build completes; always update existing release-prep PR - release.yml: create release from scratch, reconstruct notes from git/API - docs.yml: manual dispatch only - generate_quickstart.sh: accept PLUGIN_VERSION/PLUGIN_SHA env vars - Contributing.md, AGENTS.md: updated release flow docs * fix PR * fix PR
1 parent 8560e24 commit 1a1f6b9

7 files changed

Lines changed: 801 additions & 104 deletions

File tree

.github/workflows/docs.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
name: Docs
2+
3+
concurrency: docs-regeneration
4+
25
defaults:
36
run:
47
shell: bash
@@ -11,12 +14,10 @@ env:
1114
DOTNET_VERSION: '8.0.x'
1215

1316
on:
14-
release:
15-
types: [ published ]
1617
workflow_dispatch:
1718

1819
jobs:
19-
generate-and-push-docs:
20+
generate-docs:
2021
runs-on: ubuntu-latest
2122

2223
steps:
@@ -30,7 +31,7 @@ jobs:
3031
with:
3132
dotnet-version: ${{ env.DOTNET_VERSION }}
3233

33-
- name: Updating docs
34+
- name: Regenerate docs
3435
run: ./docs/scripts/generate_all_docs.sh
3536

3637
- name: Create Pull Request
@@ -43,4 +44,4 @@ jobs:
4344
commit-message: update docs
4445
branch: update-docs
4546
branch-suffix: timestamp
46-
delete-branch: true
47+
delete-branch: true
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: Generate Release PR
2+
3+
concurrency: release-prep-${{ github.ref_name }}
4+
5+
on:
6+
workflow_run:
7+
workflows: [Build]
8+
types: [completed]
9+
branches: [main]
10+
workflow_dispatch:
11+
inputs:
12+
release-type:
13+
type: choice
14+
description: Override release type
15+
options:
16+
- auto
17+
- major
18+
- minor
19+
- patch
20+
21+
permissions:
22+
contents: write
23+
pull-requests: write
24+
25+
jobs:
26+
accumulate-changes:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
with:
32+
token: ${{ secrets.GITHUB_TOKEN }}
33+
fetch-depth: 0
34+
ref: ${{ github.event.workflow_run.head_sha || github.ref }}
35+
36+
- name: Check if this is a release commit
37+
id: check-release
38+
run: |
39+
COMMIT_MSG=$(git log -1 --pretty=%B)
40+
echo "Commit message: $COMMIT_MSG"
41+
if echo "$COMMIT_MSG" | grep -q "Release Prep v"; then
42+
echo "This is a release commit, skipping workflow"
43+
echo "is-release=true" >> $GITHUB_OUTPUT
44+
else
45+
echo "Not a release commit, continuing workflow"
46+
echo "is-release=false" >> $GITHUB_OUTPUT
47+
fi
48+
49+
- name: Get all unreleased merged PRs and determine version
50+
if: steps.check-release.outputs.is-release == 'false'
51+
id: unreleased
52+
env:
53+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
run: |
55+
OWNER="${{ github.repository_owner }}"
56+
REPO="${{ github.event.repository.name }}"
57+
58+
LATEST_TAG=$(gh api repos/$OWNER/$REPO/releases/latest --jq '.tag_name' 2>/dev/null || echo "")
59+
echo "LATEST_TAG: $LATEST_TAG"
60+
61+
if [ -z "$LATEST_TAG" ]; then
62+
COMMITS=$(git log --oneline --grep="Merge pull request" --grep="#[0-9]" -E)
63+
else
64+
COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="Merge pull request" --grep="#[0-9]" -E)
65+
fi
66+
67+
PATCH_COUNT=0
68+
MINOR_COUNT=0
69+
MAJOR_COUNT=0
70+
LABELED_PR_LIST=""
71+
MAJOR_PRS=""
72+
MINOR_PRS=""
73+
PATCH_PRS=""
74+
75+
while IFS= read -r commit; do
76+
PR_NUM=$(echo "$commit" | grep -oE '#[0-9]+' | tr -d '#' || echo "")
77+
if [ -n "$PR_NUM" ]; then
78+
LABELS=$(gh api repos/$OWNER/$REPO/pulls/$PR_NUM --jq '.labels[].name' 2>/dev/null || echo "")
79+
PR_TITLE=$(gh api repos/$OWNER/$REPO/pulls/$PR_NUM --jq '.title' 2>/dev/null || echo "PR #$PR_NUM")
80+
81+
LABELED_PR_LIST="$LABELED_PR_LIST #$PR_NUM"
82+
83+
if echo "$LABELS" | grep -qx "major"; then
84+
MAJOR_COUNT=$((MAJOR_COUNT + 1))
85+
MAJOR_PRS="$MAJOR_PRS\n- $PR_TITLE (#$PR_NUM)"
86+
elif echo "$LABELS" | grep -qx "minor"; then
87+
MINOR_COUNT=$((MINOR_COUNT + 1))
88+
MINOR_PRS="$MINOR_PRS\n- $PR_TITLE (#$PR_NUM)"
89+
elif echo "$LABELS" | grep -qx "patch"; then
90+
PATCH_COUNT=$((PATCH_COUNT + 1))
91+
PATCH_PRS="$PATCH_PRS\n- $PR_TITLE (#$PR_NUM)"
92+
fi
93+
fi
94+
done <<< "$COMMITS"
95+
96+
if [ "$MAJOR_COUNT" -gt 0 ]; then
97+
RELEASE_TYPE="major"
98+
elif [ "$MINOR_COUNT" -gt 0 ]; then
99+
RELEASE_TYPE="minor"
100+
elif [ "$PATCH_COUNT" -gt 0 ]; then
101+
RELEASE_TYPE="patch"
102+
else
103+
RELEASE_TYPE="none"
104+
fi
105+
106+
if [ "${{ github.event.inputs.release-type }}" != "" ] && [ "${{ github.event.inputs.release-type }}" != "auto" ]; then
107+
RELEASE_TYPE="${{ github.event.inputs.release-type }}"
108+
echo "Release type overridden by workflow dispatch: $RELEASE_TYPE"
109+
fi
110+
111+
echo "Final release type: $RELEASE_TYPE"
112+
echo "release-type=$RELEASE_TYPE" >> $GITHUB_OUTPUT
113+
echo "labeled-pr-list=$LABELED_PR_LIST" >> $GITHUB_OUTPUT
114+
115+
- name: Compute new version
116+
if: steps.unreleased.outputs.release-type != 'none' && steps.unreleased.outputs.release-type != ''
117+
id: version-update
118+
run: |
119+
CURRENT_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "v0.0.0")
120+
echo "Current version: $CURRENT_VERSION"
121+
122+
BASE_VERSION=$(echo "$CURRENT_VERSION" | grep -o -E '[0-9]+\.[0-9]+\.[0-9]+' || echo "0.0.0")
123+
echo "Base version: $BASE_VERSION"
124+
125+
IFS='.' read -r major minor patch <<< "$BASE_VERSION"
126+
127+
RELEASE_TYPE="${{ steps.unreleased.outputs.release-type }}"
128+
echo "Release type: $RELEASE_TYPE"
129+
130+
if [ "$RELEASE_TYPE" = "major" ]; then
131+
NEW_BASE_VERSION="$((major+1)).0.0"
132+
elif [ "$RELEASE_TYPE" = "minor" ]; then
133+
NEW_BASE_VERSION="$major.$((minor+1)).0"
134+
else
135+
NEW_BASE_VERSION="$major.$minor.$((patch+1))"
136+
fi
137+
138+
NEW_VERSION="v${NEW_BASE_VERSION}"
139+
echo "New version: $NEW_VERSION"
140+
echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT
141+
142+
- name: Download wasm artifact for sha computation
143+
if: steps.version-update.outputs.new-version != ''
144+
uses: dawidd6/action-download-artifact@v6
145+
with:
146+
github_token: ${{ secrets.GITHUB_TOKEN }}
147+
workflow: build.yml
148+
workflow_conclusion: success
149+
branch: main
150+
name: wasm-file
151+
152+
- name: Compute sha and regenerate docs
153+
if: steps.version-update.outputs.new-version != ''
154+
id: doc-gen
155+
env:
156+
PLUGIN_VERSION: ${{ steps.version-update.outputs.new-version }}
157+
run: |
158+
SHA256_HASH=$(sha256sum plugin.wasm | awk '{ print $1 }')
159+
echo "Computed sha256: $SHA256_HASH"
160+
echo "plugin-sha=$SHA256_HASH" >> $GITHUB_OUTPUT
161+
162+
export PLUGIN_VERSION="${{ steps.version-update.outputs.new-version }}"
163+
export PLUGIN_SHA="$SHA256_HASH"
164+
./docs/scripts/generate_all_docs.sh
165+
166+
echo "Re-generated documentation"
167+
git status
168+
169+
- name: Create release PR
170+
if: steps.version-update.outputs.new-version != ''
171+
uses: peter-evans/create-pull-request@v5
172+
with:
173+
token: ${{ secrets.GITHUB_TOKEN }}
174+
commit-message: "chore: prepare release ${{ steps.version-update.outputs.new-version }}"
175+
title: "Release Prep ${{ steps.version-update.outputs.new-version }}"
176+
body: |
177+
## Automated Release Prep
178+
179+
**Release Type:** ${{ steps.unreleased.outputs.release-type }}
180+
**New Version:** ${{ steps.version-update.outputs.new-version }}
181+
182+
This PR was created automatically. It updates documentation with the release version and sha.
183+
184+
When merged, the Release workflow will create the GitHub release with the accumulated release notes.
185+
branch: release-prep
186+
base: ${{ github.ref_name }}
187+
labels: |
188+
release
189+
automated

0 commit comments

Comments
 (0)