-
Notifications
You must be signed in to change notification settings - Fork 1
93 lines (83 loc) · 3.07 KB
/
create-release.yml
File metadata and controls
93 lines (83 loc) · 3.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Create Release
on:
push:
tags:
- "*"
workflow_call:
inputs:
publish_test:
description: "Whether to publish to test PyPI instead of main PyPI"
required: false
type: boolean
default: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Extract release name from changelog
id: get_release_name
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
echo "Looking for version: ${VERSION}"
# First find the line containing our version (using awk for more precise matching)
VERSION_LINE=$(awk -v ver="$VERSION" '/version.*{ver}/ { print; exit }' docs/CHANGELOG.md)
if [ -z "$VERSION_LINE" ]; then
echo "Could not find version line for ${VERSION}"
VERSION_LINE=$(head -n 5 docs/CHANGELOG.md | grep "version")
echo "Using first version line instead: ${VERSION_LINE}"
fi
echo "Found version line: ${VERSION_LINE}"
# Then extract the text between quotes
RELEASE_NAME=$(echo "$VERSION_LINE" | grep -o '"[^"]*"' | tr -d '"')
if [ -z "$RELEASE_NAME" ]; then
echo "Could not extract release name, using default"
RELEASE_NAME="Release"
fi
echo "Extracted release name: ${RELEASE_NAME}"
# Set the output (using the new GITHUB_OUTPUT syntax)
{
echo "RELEASE_NAME<<EOF"
echo "${RELEASE_NAME}"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Generate Release Notes
id: release_notes
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
CHANGES=$(git log --pretty=format:"- %s" ${{ steps.get_version.outputs.VERSION }})
else
CHANGES=$(git log --pretty=format:"- %s" ${PREVIOUS_TAG}..${{ steps.get_version.outputs.VERSION }})
fi
{
echo "CHANGES<<EOF"
echo "$CHANGES"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Debug Outputs
run: |
echo "Version: ${{ steps.get_version.outputs.VERSION }}"
echo "Release Name: ${{ steps.get_release_name.outputs.RELEASE_NAME }}"
echo "Changes: ${{ steps.release_notes.outputs.CHANGES }}"
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: "${{ steps.get_version.outputs.VERSION }} - ${{ steps.get_release_name.outputs.RELEASE_NAME }}"
draft: false
prerelease: false
generate_release_notes: true
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
needs: release
uses: ./.github/workflows/publish.yml
with:
publish_test: ${{ inputs.publish_test == 'true' }}
secrets: inherit