1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Release
on:
push:
branches:
- master
workflow_dispatch:
inputs:
mode:
description: "Release workflow mode"
required: false
default: "full"
type: choice
options:
- full
- release-pr-only
permissions:
contents: write
pull-requests: write
jobs:
# Create release PR with version bumps and changelog
release-pr:
name: Release PR
runs-on: ubuntu-latest
if: github.repository == 'DecapodLabs/decapod'
environment: release
concurrency:
group: release-plz-${{ github.ref }}
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Generate GitHub App token
uses: actions/create-github-app-token@v2
id: generate-token
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Run release-plz
uses: release-plz/action@v0.5
with:
command: release-pr
config: .github/release.toml
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Update version file in release PR
run: |
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Poll for release-plz branch (it may take time for the PR to be created)
echo "Waiting for release-plz to create PR branch..."
PR_BRANCH=""
for i in {1..30}; do
git fetch origin
PR_BRANCH=$(git branch -r | grep "release-plz" | head -n1 | sed 's/origin\///' | xargs)
if [ -n "$PR_BRANCH" ]; then
echo "✓ Found release branch: $PR_BRANCH"
break
fi
echo " Attempt $i/30: No release-plz branch yet, waiting..."
sleep 2
done
if [ -z "$PR_BRANCH" ]; then
echo "⚠️ No release-plz branch found after 60 seconds"
echo "This may indicate release-plz didn't create a PR (no version bump needed)"
exit 0
fi
# Checkout the PR branch
git checkout "$PR_BRANCH"
# Get new version from Cargo.toml
NEW_VERSION=$(grep '^version = ' Cargo.toml | head -n1 | cut -d'"' -f2)
echo "Cargo.toml version: $NEW_VERSION"
# Update version file
mkdir -p .decapod/generated
echo "$NEW_VERSION" > .decapod/generated/decapod.version
# Check if there are changes
if git diff --quiet .decapod/generated/decapod.version 2>/dev/null; then
echo "Version file already up to date"
exit 0
fi
# Commit and push
git add .decapod/generated/decapod.version
git commit -m "chore: update version file to $NEW_VERSION"
git push origin "$PR_BRANCH"
echo "✅ Updated version file to $NEW_VERSION in $PR_BRANCH"
continue-on-error: true
# Tag and publish to crates.io when release PR is merged
release-publish:
name: Release & Publish
runs-on: ubuntu-latest
if: github.repository == 'DecapodLabs/decapod' && (github.event_name != 'workflow_dispatch' || github.event.inputs.mode != 'release-pr-only')
environment: release
concurrency:
group: release-publish
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Generate GitHub App token
uses: actions/create-github-app-token@v2
id: generate-token
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Run release-plz
uses: release-plz/action@v0.5
with:
command: release
config: .github/release.toml
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}