-
Notifications
You must be signed in to change notification settings - Fork 2
112 lines (101 loc) · 4.35 KB
/
_buildpacks-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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: _buildpacks-prepare-release
on:
workflow_call:
inputs:
app_id:
description: Application ID of GitHub application (e.g.; the Linguist App)
type: string
required: true
app_email:
description: The email address of the GitHub application bot user (e.g.; the Linguist App)
type: string
required: false
default: ${{ vars.LINGUIST_GH_APP_EMAIL }}
app_username:
description: The username of the GitHub application bot user (e.g.; the Linguist App)
type: string
required: false
default: ${{ vars.LINGUIST_GH_APP_USERNAME }}
bump:
description: Which component of the version to increment (major, minor, or patch)
required: true
type: string
declarations_starting_version:
description: |
Only needed if existing releases have been published but there is no matching release tag in Git. If this is
the case, the first git tag that matches a version from your CHANGELOG should be supplied.
type: string
required: false
ip_allowlisted_runner:
description: The GitHub Actions runner to use to run jobs that require IP allow-list privileges
type: string
required: false
default: pub-hk-ubuntu-24.04-ip
languages_cli_branch:
description: The branch to install the Languages CLI from (FOR TESTING)
type: string
required: false
default: main
secrets:
app_private_key:
description: Private key of GitHub application (Linguist)
required: true
defaults:
run:
# Setting an explicit bash shell ensures GitHub Actions enables pipefail mode too,
# rather than only error on exit (improving failure UX when pipes are used). See:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
shell: bash
env:
CARGO_TERM_COLOR: always
jobs:
prepare-release:
name: Prepare Release
runs-on: ${{ inputs.ip_allowlisted_runner }}
steps:
- name: Get token for GH application (Linguist)
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ inputs.app_id }}
private-key: ${{ secrets.app_private_key }}
- name: Checkout
uses: actions/checkout@v4
with:
# Using the GH application token here will configure the local git config for this repo with credentials
# that can be used to make signed commits that are attributed to the GH application user
token: ${{ steps.generate-token.outputs.token }}
- name: Install Languages CLI
uses: heroku/languages-github-actions/.github/actions/install-languages-cli@main
with:
branch: ${{ inputs.languages_cli_branch }}
- name: Bump versions and update changelogs
id: prepare
run: |
actions prepare-release \
--bump ${{ inputs.bump }} \
--repository-url https://github.com/${{ github.repository }} \
${{ inputs.declarations_starting_version && format('--declarations-starting-version {0}', inputs.declarations_starting_version) }}
- name: Generate changelog
id: generate-changelog
run: actions generate-changelog --version ${{ steps.prepare.outputs.to_version }}
- name: Create pull request
id: pr
uses: peter-evans/[email protected]
with:
token: ${{ steps.generate-token.outputs.token }}
title: Prepare release v${{ steps.prepare.outputs.to_version }}
body: ${{ steps.generate-changelog.outputs.changelog }}
commit-message: |
Prepare release v${{ steps.prepare.outputs.to_version }}
${{ steps.generate-changelog.outputs.changelog }}
branch: prepare-release
delete-branch: true
# This will ensure commits made from this workflow are attributed to the GH application user
committer: ${{ inputs.app_username }} <${{ inputs.app_email }}>
author: ${{ inputs.app_username }} <${{ inputs.app_email }}>
- name: Configure pull request
if: steps.pr.outputs.pull-request-operation == 'created'
run: gh pr merge --auto --squash "${{ steps.pr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}