Skip to content

Commit c70d571

Browse files
authored
ci: add release workflow (#837)
Works for both v0.2.+ and v0.3 rc's Signed-off-by: Bailey Hayes <[email protected]>
1 parent 11aadfe commit c70d571

File tree

9 files changed

+748
-47
lines changed

9 files changed

+748
-47
lines changed

.github/RELEASE.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# WASI Release Process
2+
3+
┌─────────────────┐ ┌──────────────┐ ┌─────────────┐
4+
│ release.sh │────►│ release.yml │────►│ Creates PR │
5+
│ (manual trigger)│ │ (workflow) │ │ for review │
6+
└─────────────────┘ └──────────────┘ └──────┬──────┘
7+
8+
┌──────────────┐ │ merge
9+
│ publish.yml │◄───────────┘
10+
│ (on release) │
11+
└──────┬───────┘
12+
13+
┌──────────────────────┼──────────────────────┐
14+
▼ ▼ ▼
15+
┌─────────┐ ┌─────────┐ ┌─────────┐
16+
│ wasi:io │ │wasi:cli │ ... │wasi:http
17+
│ → GHCR │ │ → GHCR │ │ → GHCR │
18+
└─────────┘ └─────────┘ └─────────┘
19+
20+
## Usage
21+
22+
The unified `release.sh` script in `.github/scripts/` handles both patch and RC releases:
23+
24+
```bash
25+
# Patch release (0.2.x stable)
26+
.github/scripts/release.sh --type patch --prev 0.2.8 --next 0.2.9
27+
28+
# RC release (0.3.0-rc-YYYY-MM-DD)
29+
.github/scripts/release.sh --type rc --prev-rc-date 2025-09-16
30+
.github/scripts/release.sh --type rc # First RC, no previous date
31+
```
32+
33+
## What the Script Does
34+
35+
The script automates the entire release process:
36+
37+
1. Triggers `release.yml` to bump version numbers and create a PR
38+
2. Waits for the PR to be created and CI to pass
39+
3. Awaits manual review and merge of the PR
40+
4. Creates a GitHub release (with `--prerelease` flag for RC)
41+
5. Waits for `publish.yml` to publish packages to GHCR
42+
6. Validates all packages were published successfully

.github/actions/install-tools/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ runs:
1515
using: 'composite'
1616
steps:
1717
- name: Setup wasm-tools
18-
uses: bytecodealliance/actions/wasm-tools/setup@v1
18+
uses: bytecodealliance/actions/wasm-tools/setup@d742827944dcb656569399571a8a45261b5089f6 # v1.1.0
1919
with:
2020
version: ${{ inputs.wasm-tools-version }}
2121

2222
- name: Cache wit-deps
2323
id: cache-wit-deps
24-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
24+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
2525
with:
2626
path: ~/.local/bin/wit-deps
2727
key: wit-deps-${{ inputs.wit-deps-version }}

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
groups:
8+
github-actions:
9+
patterns:
10+
- "*"

.github/scripts/release.sh

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
#!/bin/bash
2+
3+
# Unified release script for WASI releases
4+
#
5+
# This script automates the release process for both patch (0.2.x) and RC (0.3.0-rc) releases:
6+
# 1. Triggers the release.yml workflow to update versions and create PR
7+
# 2. Waits for PR to be filed and CI to pass
8+
# 3. Waits for manual PR review and merge
9+
# 4. Creates a GitHub release to trigger publishing
10+
# 5. Waits for publish workflow to complete (validates packages in CI)
11+
#
12+
# Usage:
13+
# Patch release: ./release.sh --type patch --prev 0.2.8 --next 0.2.9
14+
# RC release: ./release.sh --type rc [--prev-rc-date 2025-09-16]
15+
16+
set -e
17+
set -x
18+
19+
# Parse arguments
20+
RELEASE_TYPE=""
21+
PREV_VERSION=""
22+
NEXT_VERSION=""
23+
PREV_RC_DATE=""
24+
25+
while [[ $# -gt 0 ]]; do
26+
case $1 in
27+
--type) RELEASE_TYPE="$2"; shift 2 ;;
28+
--prev) PREV_VERSION="$2"; shift 2 ;;
29+
--next) NEXT_VERSION="$2"; shift 2 ;;
30+
--prev-rc-date) PREV_RC_DATE="$2"; shift 2 ;;
31+
-h|--help)
32+
echo "Usage:"
33+
echo " Patch release: $0 --type patch --prev <prev_version> --next <next_version>"
34+
echo " RC release: $0 --type rc [--prev-rc-date <YYYY-MM-DD>]"
35+
echo ""
36+
echo "Examples:"
37+
echo " $0 --type patch --prev 0.2.8 --next 0.2.9"
38+
echo " $0 --type rc --prev-rc-date 2025-09-16"
39+
echo " $0 --type rc # First RC, no previous date"
40+
exit 0
41+
;;
42+
*)
43+
echo "Unknown option: $1"
44+
echo "Use --help for usage information"
45+
exit 1
46+
;;
47+
esac
48+
done
49+
50+
# Configuration
51+
DATE="$(date +'%Y-%m-%d')"
52+
REPO="WebAssembly/WASI"
53+
54+
# Configure based on release type
55+
if [ "$RELEASE_TYPE" == "patch" ]; then
56+
if [ -z "$PREV_VERSION" ] || [ -z "$NEXT_VERSION" ]; then
57+
echo "Error: Patch release requires --prev and --next"
58+
echo "Example: $0 --type patch --prev 0.2.8 --next 0.2.9"
59+
exit 1
60+
fi
61+
TAG="v$NEXT_VERSION"
62+
PRERELEASE_FLAG=""
63+
RELEASE_LABEL="Patch"
64+
elif [ "$RELEASE_TYPE" == "rc" ]; then
65+
NEXT_VERSION="0.3.0-rc-$DATE"
66+
TAG="v$NEXT_VERSION"
67+
PRERELEASE_FLAG="--prerelease"
68+
RELEASE_LABEL="RC"
69+
else
70+
echo "Error: --type must be 'patch' or 'rc'"
71+
echo "Use --help for usage information"
72+
exit 1
73+
fi
74+
75+
echo "============================================"
76+
echo "WASI $RELEASE_LABEL Release"
77+
echo "============================================"
78+
if [ "$RELEASE_TYPE" == "patch" ]; then
79+
echo "Previous version: $PREV_VERSION"
80+
else
81+
echo "Previous RC date: ${PREV_RC_DATE:-'(none/first RC)'}"
82+
fi
83+
echo "Next version: $NEXT_VERSION"
84+
echo "Tag: $TAG"
85+
echo "Repository: $REPO"
86+
echo "============================================"
87+
88+
# Ensure we're operating on the correct repo
89+
gh repo set-default "$REPO"
90+
91+
# Check if release already exists
92+
if gh release view "$TAG" &>/dev/null; then
93+
echo "Error: Release $TAG already exists!"
94+
echo "If you need to re-run, delete the release first:"
95+
echo " gh release delete $TAG --yes"
96+
exit 1
97+
fi
98+
99+
# Step 1: Trigger the release workflow
100+
echo ""
101+
echo "Step 1: Triggering release.yml workflow..."
102+
103+
if [ "$RELEASE_TYPE" == "patch" ]; then
104+
gh workflow run "release.yml" \
105+
-f release_type="patch" \
106+
-f prev_version="$PREV_VERSION" \
107+
-f next_version="$NEXT_VERSION"
108+
else
109+
if [ -n "$PREV_RC_DATE" ]; then
110+
gh workflow run "release.yml" \
111+
-f release_type="rc" \
112+
-f prev_rc_date="$PREV_RC_DATE"
113+
else
114+
gh workflow run "release.yml" \
115+
-f release_type="rc"
116+
fi
117+
fi
118+
119+
# Wait for workflow to start
120+
echo "Waiting for workflow to start..."
121+
sleep 10
122+
123+
# Get the run ID
124+
RUN_ID="$(gh run list --workflow "release.yml" --created "$DATE" --json databaseId --limit 1 | jq -r '.[0].databaseId')"
125+
if [ -z "$RUN_ID" ] || [ "$RUN_ID" == "null" ]; then
126+
echo "Error: Could not find workflow run"
127+
exit 1
128+
fi
129+
130+
echo "Workflow run ID: $RUN_ID"
131+
echo "Waiting for workflow to complete..."
132+
gh run watch "$RUN_ID" --exit-status || {
133+
echo "Error: Workflow failed!"
134+
gh run view "$RUN_ID" --log-failed
135+
exit 1
136+
}
137+
138+
# Step 2: Wait for PR and CI
139+
echo ""
140+
echo "Step 2: Waiting for PR..."
141+
sleep 5
142+
143+
PR_NUMBER="$(gh pr list --head "release-v$NEXT_VERSION" --json number --limit 1 | jq -r '.[0].number')"
144+
if [ -z "$PR_NUMBER" ] || [ "$PR_NUMBER" == "null" ]; then
145+
echo "Error: Could not find PR for release-v$NEXT_VERSION"
146+
exit 1
147+
fi
148+
149+
echo "PR #$PR_NUMBER created"
150+
151+
# Close and reopen to trigger CI (workaround for some CI configurations)
152+
echo "Retriggering CI..."
153+
gh pr close "$PR_NUMBER"
154+
gh pr reopen "$PR_NUMBER"
155+
156+
echo "Waiting for CI checks to pass..."
157+
sleep 10
158+
gh pr checks "$PR_NUMBER" --watch || {
159+
echo "Warning: Some checks may have failed. Continuing anyway..."
160+
}
161+
162+
# Step 3: Wait for manual PR review and merge
163+
echo ""
164+
echo "Step 3: PR ready for review"
165+
echo "============================================"
166+
echo "PR #$PR_NUMBER: https://github.com/$REPO/pull/$PR_NUMBER"
167+
echo "============================================"
168+
echo ""
169+
read -r -p "Press Enter after the PR has been reviewed and merged..."
170+
171+
# Verify PR was actually merged
172+
STATE="$(gh pr view "$PR_NUMBER" --json state --jq '.state')"
173+
if [ "$STATE" != "MERGED" ]; then
174+
echo "Error: PR #$PR_NUMBER is not merged (state: $STATE)"
175+
exit 1
176+
fi
177+
178+
# Step 4: Create GitHub release
179+
echo ""
180+
echo "Step 4: Creating GitHub release $TAG..."
181+
sleep 5
182+
183+
gh release create "$TAG" --generate-notes $PRERELEASE_FLAG
184+
gh release view "$TAG"
185+
186+
# Step 5: Wait for publish workflow
187+
echo ""
188+
echo "Step 5: Waiting for publish workflow to complete..."
189+
sleep 10
190+
191+
PUBLISH_RUN_ID="$(gh run list --workflow "publish.yml" --created "$DATE" --json databaseId --limit 1 | jq -r '.[0].databaseId')"
192+
if [ -z "$PUBLISH_RUN_ID" ] || [ "$PUBLISH_RUN_ID" == "null" ]; then
193+
echo "Warning: Could not find publish workflow run. It may not have started yet."
194+
sleep 30
195+
PUBLISH_RUN_ID="$(gh run list --workflow "publish.yml" --created "$DATE" --json databaseId --limit 1 | jq -r '.[0].databaseId')"
196+
fi
197+
198+
if [ -n "$PUBLISH_RUN_ID" ] && [ "$PUBLISH_RUN_ID" != "null" ]; then
199+
echo "Publish workflow run ID: $PUBLISH_RUN_ID"
200+
gh run watch "$PUBLISH_RUN_ID" --exit-status || {
201+
echo "Error: Publish workflow failed!"
202+
gh run view "$PUBLISH_RUN_ID" --log-failed
203+
exit 1
204+
}
205+
fi
206+
207+
echo ""
208+
echo "============================================"
209+
echo "✓ Release $NEXT_VERSION ($RELEASE_LABEL) completed successfully!"
210+
echo "============================================"

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: Validate WIT
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
2525

2626
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
2727
id: changes

.github/workflows/lint-gh.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ jobs:
1717
name: Lint GitHub Actions
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
2121
- uses: rhysd/actionlint@a443f344ff32813837fa49f7aa6cbc478d770e62 # v1.7.9

0 commit comments

Comments
 (0)