-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add a workflow `create.yml` to create release branches and tags in a controlled manner, using a GitHub app that will have exceptions in the rulesets * change the `release.yml` workflow to be directly called by the main CI workflow * change `release.yml` to not validate the ref anymore, but instead rely on rulesets and environments * add support for prereleases * document workflow in `docs/maintainer.md`
- Loading branch information
1 parent
a3ee68c
commit 3055474
Showing
4 changed files
with
293 additions
and
65 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: Create release branch or tag | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
type: | ||
description: "What to create (branch or tag)" | ||
required: true | ||
type: choice | ||
options: | ||
- "branch" | ||
- "tag" | ||
version: | ||
description: "Version - major and minor for a branch (e.g. 0.3), semver for a tag (e.g. 0.3.1 or 0.3.1-rc.1)" | ||
required: true | ||
|
||
jobs: | ||
create-release: | ||
name: Create release branch from main | ||
if: github.event.inputs.type == 'branch' | ||
environment: create-release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check version | ||
id: version | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const semver = /^(0|[1-9]\d*)\.(0|[1-9]\d*)$/; | ||
const version = context.payload.inputs.version; | ||
const match = version.match(semver); | ||
if (match === null) { | ||
core.setFailed('Invalid version format. Expected "MAJOR.MINOR".'); | ||
} else { | ||
core.setOutput('branch', `release/${version}`); | ||
} | ||
- name: Generate an app token | ||
id: app-token | ||
uses: actions/create-github-app-token@v1 | ||
with: | ||
app-id: ${{ secrets.APP_ID }} | ||
private-key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
||
- name: Checkout main branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
token: ${{ steps.app-token.outputs.token }} | ||
|
||
- name: Push | ||
run: | | ||
branch=${{ steps.version.outputs.branch }} | ||
git checkout -b $branch | ||
git push origin $branch | ||
create-tag: | ||
name: Create release tag from release branch | ||
if: github.event.inputs.type == 'tag' | ||
environment: create-release | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Regex comes from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string | ||
- name: Check version | ||
id: version | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const semver = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; | ||
const version = context.payload.inputs.version; | ||
const match = version.match(semver); | ||
if (match === null) { | ||
core.setFailed('Invalid version format. Expected semver compliant version.'); | ||
} else { | ||
core.setOutput('tag', `v${version}`); | ||
core.setOutput('branch', `release/${match[1]}.${match[2]}`); | ||
} | ||
- name: Generate an app token | ||
id: app-token | ||
uses: actions/create-github-app-token@v1 | ||
with: | ||
app-id: ${{ secrets.APP_ID }} | ||
private-key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
||
- name: Checkout release branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ steps.version.outputs.branch }} | ||
token: ${{ steps.app-token.outputs.token }} | ||
|
||
- name: Push | ||
run: | | ||
tag=${{ steps.version.outputs.tag }} | ||
git tag $tag | ||
git push origin $tag |
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
Oops, something went wrong.