-
Notifications
You must be signed in to change notification settings - Fork 47
72 lines (64 loc) · 2.18 KB
/
release.yml
File metadata and controls
72 lines (64 loc) · 2.18 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. v1.0.0)'
required: true
type: string
prerelease:
description: 'Mark as pre-release'
required: false
type: boolean
default: false
permissions:
contents: write
jobs:
release:
name: Create GitHub Release
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate version format
run: |
if ! echo "${{ inputs.version }}" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then
echo "ERROR: Version must match vX.Y.Z or vX.Y.Z-suffix format"
exit 1
fi
- name: Check tag does not already exist
run: |
if git rev-parse "refs/tags/${{ inputs.version }}" >/dev/null 2>&1; then
echo "ERROR: Tag ${{ inputs.version }} already exists"
exit 1
fi
- name: Generate release notes
id: notes
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "${PREVIOUS_TAG}" ]; then
echo "Previous tag: ${PREVIOUS_TAG}"
CHANGELOG=$(git log "${PREVIOUS_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges)
else
echo "No previous tag found, using full history"
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges -50)
fi
{
echo "notes<<EOF"
echo "## What's Changed"
echo ""
echo "${CHANGELOG}"
echo ""
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_TAG:-$(git rev-list --max-parents=0 HEAD | head -1)}...${{ inputs.version }}"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.version }}
name: ${{ inputs.version }}
body: ${{ steps.notes.outputs.notes }}
prerelease: ${{ inputs.prerelease }}
generate_release_notes: false