Repository navigation
81 lines (72 loc) · 2.74 KB
/
Copy pathrelease-draft.yml
File metadata and controls
81 lines (72 loc) · 2.74 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
name: Release draft
# The recommendation was "automate releases with release-please or semantic-release". This
# project cannot take either: the CHANGELOG is hand-written and machine-verified (Keep a
# Changelog 2.0.0 with `[Unreleased]`), and release-please would own the file and rewrite the
# history of the entries. What is left is the mechanical part — the release body — and that is
# what this workflow automates, as a DRAFT release:
#
# * a draft is not published, so `publish.yml` (triggered by `release: published`) does not
# fire and nothing reaches PyPI by accident;
# * the body is generated by `ghagent changelog notes <version>` from the CHANGELOG, so it
# cannot drift from the file;
# * a human reads the draft and presses Publish, which is the irreversible step.
#
# Signed commits are a repository setting (`git commit -S` + a key); automation cannot grant it,
# so it stays a documented requirement in docs/PACKAGING.md rather than a workflow step.
on:
workflow_dispatch:
inputs:
tag:
description: "Existing tag to build the draft for (for example v1.3.0)"
required: true
prerelease:
description: "Mark as a pre-release"
type: boolean
default: false
permissions:
contents: write
jobs:
draft:
name: Draft the release notes from CHANGELOG
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: "3.13"
- name: Check out the tag
run: git checkout "${{ inputs.tag }}"
- name: The CHANGELOG knows this version
run: python tools/ghagent.py changelog check
- name: Render the body
run: |
set -euo pipefail
VERSION="${TAG#v}"
python tools/ghagent.py changelog notes "$VERSION" > release-notes.md
test -s release-notes.md
{
echo "## What changed"
echo
cat release-notes.md
echo
echo "## Verification"
echo
echo '```bash'
echo "ghagent --version # github-agent $VERSION"
echo "python tests/run_tests.py"
echo '```'
} > body.md
env:
TAG: ${{ inputs.tag }}
- name: Create the draft release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
FLAGS=""
if [ "${{ inputs.prerelease }}" = "true" ]; then FLAGS="--prerelease"; fi
gh release create "${{ inputs.tag }}" --draft $FLAGS \
--title "${{ inputs.tag }}" --notes-file body.md
echo "::notice::Draft created. Read it, then press Publish to start publish.yml (PyPI)."