-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (71 loc) · 3.08 KB
/
Copy pathrelease-notes.yaml
File metadata and controls
82 lines (71 loc) · 3.08 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
name: release-notes
# Generates CHANGELOG.md and a dated docs/news/posts/ blog entry for a tagged
# release, then opens a PR with both. See .github/scripts/generate_release_notes.py for how
# entries are sourced (merged PR titles, parsed for a Conventional Commits prefix) and
# .github/workflows/pr-title-lint.yml for how those titles are kept in that shape.
#
# Cut a release by tagging the branch tip: `git tag v1.1.0 && git push origin v1.1.0` (or via
# `gh release create v1.1.0 --target 1.21.x`). Tag names must match `v*`.
on:
push:
tags:
- 'v*'
permissions:
contents: write
pull-requests: write
jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: '3.x'
- name: Determine the branch this tag was cut from
id: base
run: |
git fetch origin --prune
# --points-at (not --contains) requires the tag to sit exactly at a branch tip, not
# just be reachable from one - keeps this deterministic when a tag is reachable from
# several branches, and enforces the "tag the tip" invariant this workflow assumes.
BRANCH=$(git branch -r --points-at "${{ github.sha }}" \
| sed 's/^[* ]*origin\///' \
| grep -E '^[0-9]+\.[0-9]+\.x$|^main$' \
| head -n1)
if [ -z "$BRANCH" ]; then
echo "::error::Tag ${{ github.ref_name }} isn't at the tip of a recognized release branch (expected an N.N.x or main branch tip)."
exit 1
fi
echo "Releasing from $BRANCH"
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
- name: Generate changelog and news post
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python .github/scripts/generate_release_notes.py \
--repo "${{ github.repository }}" \
--new-tag "${{ github.ref_name }}" \
--changelog-path CHANGELOG.md \
--posts-dir docs/news/posts
- name: Open pull request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if git diff --quiet -- CHANGELOG.md docs/news/posts; then
echo "Nothing new to record since the previous tag - skipping PR."
exit 0
fi
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
BRANCH_NAME="release-notes/${{ github.ref_name }}"
git checkout -b "$BRANCH_NAME"
git add CHANGELOG.md docs/news/posts
git commit -m "docs: release notes for ${{ github.ref_name }}"
git push origin "$BRANCH_NAME"
gh pr create \
--base "${{ steps.base.outputs.branch }}" \
--head "$BRANCH_NAME" \
--title "docs: release notes for ${{ github.ref_name }}" \
--body "Auto-generated changelog and news post for [${{ github.ref_name }}](https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }})."