-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (63 loc) · 2.07 KB
/
release.yml
File metadata and controls
71 lines (63 loc) · 2.07 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
name: Release
on:
workflow_dispatch:
inputs:
bump:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine versions
id: version
run: |
LATEST=$(git tag --list 'v*.*.*' --sort=-v:refname | head -n 1)
if [ -z "$LATEST" ]; then
LATEST="v0.0.0"
fi
echo "previous=$LATEST" >> "$GITHUB_OUTPUT"
# Strip 'v' prefix, split, bump, reassemble
IFS='.' read -r MAJOR MINOR PATCH <<< "${LATEST#v}"
case "${{ inputs.bump }}" in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
patch) PATCH=$((PATCH + 1)) ;;
esac
NEXT="v${MAJOR}.${MINOR}.${PATCH}"
echo "next=$NEXT" >> "$GITHUB_OUTPUT"
echo "major=v${MAJOR}" >> "$GITHUB_OUTPUT"
echo "Releasing $NEXT (previous: $LATEST)"
- name: Generate release notes
id: notes
uses: github/copilot-release-notes@v1
with:
base-ref: ${{ steps.version.outputs.previous }}
head-ref: ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ github.token }}
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.next }}
name: ${{ steps.version.outputs.next }}
body: ${{ steps.notes.outputs.release-notes }}
draft: true
target_commitish: ${{ github.sha }}
- name: Update major version tag
run: |
git tag -f "${{ steps.version.outputs.major }}" "${{ github.sha }}"
git push origin "refs/tags/${{ steps.version.outputs.major }}" --force