-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (95 loc) · 3.05 KB
/
Copy pathrelease.yml
File metadata and controls
99 lines (95 loc) · 3.05 KB
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
name: Release Value Map
on:
push:
branches: [main]
workflow_dispatch:
inputs:
bump:
description: Version bump for a manual release
type: choice
options: [patch, minor, major]
default: patch
permissions:
contents: write
pull-requests: read
concurrency:
group: release-value-map
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve release policy
id: policy
env:
GH_TOKEN: ${{ github.token }}
MANUAL_BUMP: ${{ inputs.bump }}
shell: bash
run: |
bump="${MANUAL_BUMP:-patch}"
skip="false"
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
labels="$(gh api \
-H 'Accept: application/vnd.github+json' \
"/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls" \
--jq '.[0].labels[].name' 2>/dev/null || true)"
if grep -qx 'skip-release' <<<"$labels"; then skip="true"; fi
if grep -qx 'major' <<<"$labels"; then
bump="major"
elif grep -qx 'minor' <<<"$labels"; then
bump="minor"
fi
fi
echo "bump=$bump" >> "$GITHUB_OUTPUT"
echo "skip=$skip" >> "$GITHUB_OUTPUT"
- name: Compute version
if: steps.policy.outputs.skip != 'true'
id: version
env:
BUMP: ${{ steps.policy.outputs.bump }}
shell: bash
run: |
latest="$(git tag --list 'v[0-9]*' --sort=-v:refname | head -n 1)"
if [[ -z "$latest" ]]; then
next="v0.1.0"
else
raw="${latest#v}"
IFS=. read -r major minor patch <<<"$raw"
case "$BUMP" in
major) major=$((major + 1)); minor=0; patch=0 ;;
minor) minor=$((minor + 1)); patch=0 ;;
patch) patch=$((patch + 1)) ;;
*) echo "Invalid bump: $BUMP" >&2; exit 2 ;;
esac
next="v${major}.${minor}.${patch}"
fi
echo "version=$next" >> "$GITHUB_OUTPUT"
- name: Build release assets
if: steps.policy.outputs.skip != 'true'
shell: bash
run: |
mkdir -p dist
cp value-map/SKILL.md dist/value-map-SKILL.md
(
cd dist
sha256sum value-map-SKILL.md > value-map-SKILL.md.sha256
tar -czf value-map-skill.tar.gz value-map-SKILL.md
sha256sum value-map-skill.tar.gz > value-map-skill.tar.gz.sha256
)
- name: Publish release
if: steps.policy.outputs.skip != 'true'
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
shell: bash
run: |
git tag "$VERSION" "$GITHUB_SHA"
git push origin "$VERSION"
gh release create "$VERSION" dist/* \
--repo "$GITHUB_REPOSITORY" \
--title "$VERSION" \
--generate-notes \
--verify-tag