-
Notifications
You must be signed in to change notification settings - Fork 13
87 lines (71 loc) · 2.64 KB
/
Copy pathprepare-release-pr.yml
File metadata and controls
87 lines (71 loc) · 2.64 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
name: Prepare release PR
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
prepare-release-pr:
if: ${{ !startsWith(github.event.head_commit.message, 'chore(release):') }}
runs-on: ubuntu-latest
steps:
- name: Check out sources
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for changelog
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
make \
python3 python3-pip
- name: Install git-cliff
run: pip install git-cliff
- name: Determine release version
id: version
run: |
BASE_VERSION=$(cd source && make -B baseversion)
DATE=$(TZ="America/Chicago" date +'%Y-%m-%d')
git fetch --tags
COUNT=$(git tag --list "${BASE_VERSION}.${DATE}*" | wc -l)
if [ "$COUNT" -gt 0 ]; then
VERSION="${BASE_VERSION}.${DATE}.$((COUNT+1))"
else
VERSION="${BASE_VERSION}.${DATE}"
fi
echo "$VERSION" > VERSION
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Generate changelog
run: |
CHANGELOG_MD=true git cliff --config .github/cliff.toml \
--tag ${{ steps.version.outputs.version }} \
--output CHANGELOG.md
- name: Generate release notes preview
id: release_notes_preview
run: |
{
echo 'release_notes<<EOF'
git cliff --config .github/cliff.toml \
--tag ${{ steps.version.outputs.version }} \
--unreleased
echo 'EOF'
} >> $GITHUB_OUTPUT
- name: Create or update release PR
uses: peter-evans/create-pull-request@v6
with:
branch: release/next
delete-branch: true
commit-message: "chore(release): v${{ steps.version.outputs.version }}"
title: "Release v${{ steps.version.outputs.version }}"
body: >
This PR was created by the [prepare-release-pr](/${{ github.repository }}/blob/main/.github/workflows/prepare-release-pr.yml)
GitHub action. When you're ready to release, simply merge it — the corresponding GitHub release will be
published automatically.
If you're not ready yet, no problem. This PR will continue to update as you push changes to `main`,
and you can merge it whenever you're ready.
# Release notes
${{ steps.release_notes_preview.outputs.release_notes }}
labels: release
token: ${{ secrets.GITHUB_TOKEN }}