-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (85 loc) · 3.2 KB
/
Copy pathrelease.yml
File metadata and controls
98 lines (85 loc) · 3.2 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
name: Release
on:
workflow_dispatch:
permissions:
contents: write
# Only one release run at a time — concurrent runs cause duplicate cog bump commits
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Cocogitto
uses: cocogitto/cocogitto-action@v4
with:
command: bump
args: --auto
git-user: 'github-actions[bot]'
git-user-email: 'github-actions[bot]@users.noreply.github.com'
- name: Resolve new tag
id: tag
run: echo "tag=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT"
- name: Check if release already exists
id: release_check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh release view "${{ steps.tag.outputs.tag }}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Generate changelog
if: steps.release_check.outputs.exists == 'false'
run: cog changelog --at "${{ steps.tag.outputs.tag }}" > RELEASE_NOTES.md
- name: Push version commit and tag
if: steps.release_check.outputs.exists == 'false'
run: |
TAG="${{ steps.tag.outputs.tag }}"
git push origin HEAD:main
# Push the tag explicitly; tolerate "already exists" from concurrent runs
git push origin "refs/tags/${TAG}" || {
git fetch --tags
if git ls-remote --tags origin "refs/tags/${TAG}" | grep -q "${TAG}"; then
echo "Tag ${TAG} already on remote — skipping tag push"
else
echo "Tag push failed for unknown reason" && exit 1
fi
}
- name: Determine release parity
id: parity
run: |
TAG="${{ steps.tag.outputs.tag }}"
MINOR=$(echo "$TAG" | sed 's/^v[0-9]*\.\([0-9]*\)\..*/\1/')
if [ $(( MINOR % 2 )) -eq 0 ]; then
echo "is_stable=true" >> "$GITHUB_OUTPUT"
else
echo "is_stable=false" >> "$GITHUB_OUTPUT"
fi
- name: Create GitHub Release (stable even minor)
if: steps.release_check.outputs.exists == 'false' && steps.parity.outputs.is_stable == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.tag.outputs.tag }}" \
--title "${{ steps.tag.outputs.tag }} (stable)" \
--notes-file RELEASE_NOTES.md \
--latest
- name: Create GitHub Pre-release (dev odd minor)
if: steps.release_check.outputs.exists == 'false' && steps.parity.outputs.is_stable == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.tag.outputs.tag }}" \
--title "${{ steps.tag.outputs.tag }} (dev/experimental)" \
--notes-file RELEASE_NOTES.md \
--prerelease