Skip to content

Commit d2ce7ae

Browse files
committed
ci: install labkit-generated release workflow
Cuts a tagged GitHub Release (v0.1.0 first) on push to main / dispatch. Source: operatorstack/intelligence-flow labs/21-interlock (labkit gen).
1 parent 497e8bb commit d2ce7ae

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Generated by labkit (python -m labkit gen). Do not edit by hand.
2+
# Edit labs/<lab>/publish.config.json and regenerate; drift fails `labkit doctor`.
3+
# Install into operatorstack/interlock at .github/workflows/release.yml (bootstrap step).
4+
name: Release Interlock
5+
6+
on:
7+
push:
8+
branches: [main]
9+
workflow_dispatch:
10+
inputs:
11+
bump:
12+
description: Version bump for a manual release
13+
type: choice
14+
options: [patch, minor, major]
15+
default: patch
16+
17+
permissions:
18+
contents: write
19+
pull-requests: read
20+
21+
concurrency:
22+
group: release-interlock
23+
cancel-in-progress: false
24+
25+
jobs:
26+
release:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- name: Resolve release policy
33+
id: policy
34+
env:
35+
GH_TOKEN: ${{ github.token }}
36+
MANUAL_BUMP: ${{ inputs.bump }}
37+
shell: bash
38+
run: |
39+
bump="${MANUAL_BUMP:-patch}"
40+
skip="false"
41+
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
42+
labels="$(gh api \
43+
-H 'Accept: application/vnd.github+json' \
44+
"/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls" \
45+
--jq '.[0].labels[].name' 2>/dev/null || true)"
46+
if grep -qx 'skip-release' <<<"$labels"; then skip="true"; fi
47+
if grep -qx 'major' <<<"$labels"; then
48+
bump="major"
49+
elif grep -qx 'minor' <<<"$labels"; then
50+
bump="minor"
51+
fi
52+
fi
53+
echo "bump=$bump" >> "$GITHUB_OUTPUT"
54+
echo "skip=$skip" >> "$GITHUB_OUTPUT"
55+
- name: Compute version
56+
if: steps.policy.outputs.skip != 'true'
57+
id: version
58+
env:
59+
BUMP: ${{ steps.policy.outputs.bump }}
60+
shell: bash
61+
run: |
62+
latest="$(git tag --list 'v[0-9]*' --sort=-v:refname | head -n 1)"
63+
if [[ -z "$latest" ]]; then
64+
next="v0.1.0"
65+
else
66+
raw="${latest#v}"
67+
IFS=. read -r major minor patch <<<"$raw"
68+
case "$BUMP" in
69+
major) major=$((major + 1)); minor=0; patch=0 ;;
70+
minor) minor=$((minor + 1)); patch=0 ;;
71+
patch) patch=$((patch + 1)) ;;
72+
*) echo "Invalid bump: $BUMP" >&2; exit 2 ;;
73+
esac
74+
next="v${major}.${minor}.${patch}"
75+
fi
76+
echo "version=$next" >> "$GITHUB_OUTPUT"
77+
- name: Publish release
78+
if: steps.policy.outputs.skip != 'true'
79+
env:
80+
GH_TOKEN: ${{ github.token }}
81+
VERSION: ${{ steps.version.outputs.version }}
82+
shell: bash
83+
run: |
84+
if git rev-parse --verify --quiet "refs/tags/$VERSION"; then
85+
echo "Tag $VERSION already exists; nothing to release."
86+
exit 0
87+
fi
88+
git tag "$VERSION" "$GITHUB_SHA"
89+
git push origin "$VERSION"
90+
gh release create "$VERSION" \
91+
--repo "$GITHUB_REPOSITORY" \
92+
--title "$VERSION" \
93+
--generate-notes \
94+
--verify-tag

0 commit comments

Comments
 (0)