-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (76 loc) · 2.97 KB
/
prepare-release.yml
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
on:
workflow_dispatch:
inputs:
release-type:
description: 'Release type'
type: choice
required: true
options:
- major
- minor
- patch
- premajor
- preminor
- prepatch
- prerelease
default: patch
preid:
description: 'Pre-release identifier (only for pre-release builds)'
required: false
name: '[autorelease] Prepare release PR'
permissions:
contents: read
issues: write
pull-requests: write
jobs:
changelog:
name: Update changelog and create PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: tibdex/github-app-token@v2
id: generate-token
with:
app_id: ${{ secrets.RELEASEBOT_APP_ID }}
private_key: ${{ secrets.RELEASEBOT_PRIVATE_KEY }}
- name: 'Ensure autorelease label exists'
run: |
LABEL=$(gh api repos/$GITHUB_REPOSITORY/labels --jq '.[] | select(.name=="autorelease")')
if [[ -z "$LABEL" ]]; then
echo "Creating 'autorelease' label"
gh api --silent repos/$GITHUB_REPOSITORY/labels -f name="autorelease" -f color="baa938" -f description="This is an automatically-created PR to trigger a release"
else
echo "'autorelease' label exists"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update changelog
id: update-changelog
uses: ./
with:
command: bump
version: ${{ github.event.inputs.release-type }}
preid: ${{ github.event.inputs.preid }}
- name: Create Pull Request
id: create-release-pr
uses: peter-evans/create-pull-request@v6
with:
commit-message: 'chore: Update changelog for release ${{ steps.update-changelog.outputs.version }}'
committer: 'releasebot <noreply@github.com>'
branch: 'autorelease/${{ steps.update-changelog.outputs.version }}'
title: '[autorelease] Release ${{ steps.update-changelog.outputs.version }}'
# Be careful of newlines here. We need to use the literal block chomping style (|) so that the
# contents of the release notes don't get chomped. See https://yaml-multiline.info/
body: |
**This PR was created automatically by the releasebot**
**:warning: Approving this PR will trigger a workflow that generates a draft release. You need to publish this release when you are happy with it.**
The changes in this PR prepare for release ${{ steps.update-changelog.outputs.version }}. The release notes are:
---
${{ steps.update-changelog.outputs.release-notes }}
labels: autorelease
token: ${{ steps.generate-token.outputs.token }}
- name: Output summary
run: |
echo "::notice title=Release PR Prepared::A release PR has been created, please merge it to continue with the release process: ${{ steps.create-release-pr.outputs.pull-request-url }}"