Skip to content

Commit

Permalink
Add workflow to create new tag after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
nwiltsie committed Jul 30, 2024
1 parent 6f118a6 commit c858905
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .github/workflows/create-new-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
on:
workflow_call:

jobs:
release-tag:
runs-on: ubuntu-latest

steps:
- id: parse-version
uses: actions/github-script@v7
with:
script: |
// Sanity-check that this was called from an appropriate merge event and
// extract the version number embedded in the branch name.
if (context.eventName !== 'pull_request') {
core.setFailed('Workflow requires pull_request events')
process.exit()
}
if (!context.payload.pull_request.merged || context.payload.pull_request.state !== 'closed') {
core.setFailed('Workflow should only be called on merged and closed PRs')
process.exit()
}
if (context.payload.pull_request.user.type !== 'bot') {
core.setFailed('Workflow should only be called for bot-generated release PRs')
process.exit()
}
// This regex needs to kept in-sync with the pattern in create-release-pr.yaml
const regex = /^automation-create-release-(.*)$/i
const parsed_version = context.payload.pull_request.head.label.match(regex)
if (!parsed_version || !parsed_version[1].length) {
core.setFailed('Workflow not called from an appropriate branch name')
process.exit()
}
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `v${new_version}`,
target_commitish: context.payload.pull_request.merge_commit_sha,
name: `Release ${new_version}`,
draft: true,
generate_release_notes: true,
body: `Automatically generated after merging #${context.payload.number}.`
})
4 changes: 3 additions & 1 deletion .github/workflows/create-release-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ jobs:
with:
path: caller
add-paths: ${{ inputs.changelog }}
branch: automation-create-release-${{ steps.get-next-version.outputs.next_version }}
commit-message: ${{ steps.bump-changelog.outputs.commit_message }}
title: ${{ steps.bump-changelog.outputs.pr_title }}
body-path: ${{ steps.bump-changelog.outputs.pr_bodyfile }}
# This branch name format needs to be kept in-sync with the parser in
# create-new-tag.yaml
branch: automation-create-release-${{ steps.get-next-version.outputs.next_version }}

0 comments on commit c858905

Please sign in to comment.