-
Notifications
You must be signed in to change notification settings - Fork 1
65 lines (59 loc) · 1.96 KB
/
Copy pathcreate-release.yml
File metadata and controls
65 lines (59 loc) · 1.96 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
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
permissions:
contents: write # create the GitHub release
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
# docs/CHANGELOG.md is the 1.x changelog and may have no entry for
# this tag; fall back to a plain name rather than failing the job.
run: |
VERSION="${{ steps.get_version.outputs.VERSION }}"
RELEASE_NAME=""
if [ -f docs/CHANGELOG.md ]; then
VERSION_LINE=$(grep -m1 -F "${VERSION#v}" docs/CHANGELOG.md || true)
RELEASE_NAME=$(echo "$VERSION_LINE" | grep -o '"[^"]*"' | head -n1 | tr -d '"' || true)
fi
if [ -z "$RELEASE_NAME" ]; then
RELEASE_NAME="Release"
fi
echo "Release name: ${RELEASE_NAME}"
echo "RELEASE_NAME=${RELEASE_NAME}" >> "$GITHUB_OUTPUT"
- name: Create Release
uses: softprops/action-gh-release@v2
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
permissions:
contents: read
id-token: write # publish.yml needs this for PyPI trusted publishing
with:
publish_test: ${{ inputs.publish_test == true }}
secrets: inherit