-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (72 loc) · 2.71 KB
/
Copy pathrelease.yml
File metadata and controls
80 lines (72 loc) · 2.71 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
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Tag name to create release for (e.g. v3.1.0)"
required: true
permissions:
contents: write # Required to create the GitHub Release
# Serialize releases per ref; never cancel an in-flight release (a half-cancelled
# release is worse than a queued one).
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
name: Create GitHub Release
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0 # Full history for changelog generation
- name: Determine tag name
id: tag
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_TAG: ${{ inputs.tag }}
REF_NAME: ${{ github.ref_name }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
echo "name=$INPUT_TAG" >> "$GITHUB_OUTPUT"
else
echo "name=$REF_NAME" >> "$GITHUB_OUTPUT"
fi
- name: Verify tag exists
env:
TAG: ${{ steps.tag.outputs.name }}
run: |
set -euo pipefail
if ! git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
echo "Tag '$TAG' does not exist in this checkout. Push the tag first or choose an existing tag."
exit 1
fi
- name: Generate changelog excerpt
id: changelog
env:
TAG: ${{ steps.tag.outputs.name }}
run: |
# Extract entries since the previous tag
PREV_TAG=$(git describe --tags --abbrev=0 "${TAG}^" 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
LOG=$(git log "${PREV_TAG}..${TAG}" --oneline --no-merges | head -50)
else
LOG=$(git log "${TAG}" --oneline --no-merges | head -50)
fi
# Write to file to handle multiline safely
echo "$LOG" > /tmp/changelog.txt
echo "file=/tmp/changelog.txt" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
tag_name: ${{ steps.tag.outputs.name }}
name: "Research Project Template ${{ steps.tag.outputs.name }}"
body_path: ${{ steps.changelog.outputs.file }}
draft: false
prerelease: ${{ contains(steps.tag.outputs.name, '-rc') || contains(steps.tag.outputs.name, '-beta') || contains(steps.tag.outputs.name, '-alpha') }}
# Omit generate_release_notes — avoids duplicating narrative vs body_path excerpt.
generate_release_notes: false