Skip to content

Commit bf9a418

Browse files
committed
Add reusable GitHub Actions release workflow
Adds a workflow_call workflow that enables other repositories to perform releases using tenzir-ship. The workflow automates changelog management, version bumping, GPG signing, and tagging. Input parameters allow customization of version bump type, release intro, and optional pre/post-release hooks for quality gates and version bumping tasks.
1 parent bb670c1 commit bf9a418

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

.github/workflows/release.yaml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Release
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
bump:
7+
description: "Version bump type: major, minor, or patch"
8+
required: true
9+
type: string
10+
intro:
11+
description: "1-2 sentence release introduction"
12+
required: true
13+
type: string
14+
title:
15+
description: "User-facing release title (empty = auto-generated)"
16+
required: false
17+
default: ""
18+
type: string
19+
changelog-root:
20+
description: "Project root for --root flag"
21+
required: false
22+
default: "."
23+
type: string
24+
git-add-paths:
25+
description: "Space-separated extra paths to stage before publish"
26+
required: false
27+
default: ""
28+
type: string
29+
pre-create:
30+
description: "Shell script for quality gates (runs before release create)"
31+
required: false
32+
default: ""
33+
type: string
34+
post-create:
35+
description: "Shell script for version bumping (runs after release create)"
36+
required: false
37+
default: ""
38+
type: string
39+
40+
jobs:
41+
release:
42+
name: Release
43+
runs-on: ubuntu-latest
44+
permissions:
45+
contents: write
46+
47+
steps:
48+
- name: Validate bump input
49+
run: |
50+
case "${{ inputs.bump }}" in
51+
major|minor|patch) ;;
52+
*) echo "::error::Invalid bump value '${{ inputs.bump }}'. Must be major, minor, or patch." && exit 1 ;;
53+
esac
54+
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
with:
58+
fetch-depth: 0
59+
persist-credentials: false
60+
61+
- name: Set up Python
62+
uses: actions/setup-python@v5
63+
with:
64+
python-version: "3.x"
65+
66+
- name: Install uv
67+
uses: astral-sh/setup-uv@v4
68+
69+
- name: Install tenzir-ship
70+
run: uv tool install tenzir-ship
71+
72+
- name: Generate app token
73+
id: app-token
74+
uses: actions/create-github-app-token@v1
75+
with:
76+
app-id: ${{ vars.TENZIR_GITHUB_APP_ID }}
77+
private-key: ${{ secrets.TENZIR_GITHUB_APP_PRIVATE_KEY }}
78+
79+
- name: Set up GPG signing
80+
run: |
81+
echo "${{ secrets.TENZIR_BOT_GPG_SIGNING_KEY }}" | gpg --batch --import
82+
KEY_ID=$(gpg --list-secret-keys --keyid-format=long | grep sec | head -1 | awk '{print $2}' | cut -d'/' -f2)
83+
git config --global user.signingkey "$KEY_ID"
84+
git config --global commit.gpgsign true
85+
git config --global tag.gpgsign true
86+
87+
- name: Configure Git
88+
env:
89+
APP_TOKEN: ${{ steps.app-token.outputs.token }}
90+
run: |
91+
git config --global user.name "tenzir-bot"
92+
git config --global user.email "engineering@tenzir.com"
93+
git remote set-url origin "https://x-access-token:${APP_TOKEN}@github.com/${{ github.repository }}.git"
94+
95+
- name: Run pre-create script
96+
if: inputs.pre-create != ''
97+
run: ${{ inputs.pre-create }}
98+
99+
- name: Create release
100+
run: |
101+
TITLE_ARGS=()
102+
if [ -n "$RELEASE_TITLE" ]; then
103+
TITLE_ARGS=(--title "$RELEASE_TITLE")
104+
fi
105+
tenzir-ship --root "$CHANGELOG_ROOT" release create \
106+
"--${{ inputs.bump }}" \
107+
--intro "$RELEASE_INTRO" \
108+
"${TITLE_ARGS[@]}" \
109+
--yes
110+
env:
111+
CHANGELOG_ROOT: ${{ inputs.changelog-root }}
112+
RELEASE_TITLE: ${{ inputs.title }}
113+
RELEASE_INTRO: ${{ inputs.intro }}
114+
115+
- name: Run post-create script
116+
if: inputs.post-create != ''
117+
run: ${{ inputs.post-create }}
118+
119+
- name: Stage and publish
120+
run: |
121+
git add "$CHANGELOG_ROOT/changelog"
122+
if [ -n "$GIT_ADD_PATHS" ]; then
123+
# shellcheck disable=SC2086 # Intentional word splitting.
124+
git add $GIT_ADD_PATHS
125+
fi
126+
tenzir-ship --root "$CHANGELOG_ROOT" release publish --commit --tag --yes
127+
env:
128+
CHANGELOG_ROOT: ${{ inputs.changelog-root }}
129+
GIT_ADD_PATHS: ${{ inputs.git-add-paths }}
130+
131+
- name: Summary
132+
run: |
133+
VERSION=$(tenzir-ship --root "$CHANGELOG_ROOT" release version)
134+
{
135+
echo "## Release ${VERSION}"
136+
echo ""
137+
echo "Successfully released version **${VERSION}**."
138+
} >> "$GITHUB_STEP_SUMMARY"
139+
env:
140+
CHANGELOG_ROOT: ${{ inputs.changelog-root }}

0 commit comments

Comments
 (0)