[autorelease] Prepare release PR #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}" | |