Create tag release #51
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
# Workflow to create a new tag release when a release branch is merged | |
name: Create tag release | |
on: | |
pull_request: | |
types: [ closed ] | |
branches: | |
- release/* | |
workflow_dispatch: | |
inputs: | |
release-branch: | |
description: 'Branch to release' | |
type: 'string' | |
required: true | |
version: | |
description: 'SemVer release version, e.g. `1.0.0`' | |
type: 'string' | |
required: true | |
jobs: | |
tag-release: | |
if: | | |
(github.event.pull_request.merged == true && | |
(startsWith(github.event.pull_request.head.ref, 'release-pr') || | |
startsWith(github.event.pull_request.head.ref, 'patch/'))) || | |
github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git config | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/checkout@v4 | |
with: | |
repository: argumentcomputer/ci-workflows | |
path: ci-workflows | |
ref: release-workflow | |
- name: Create changelog config | |
run: | | |
cat << 'EOF' > config.json | |
{ | |
"template": "#{{CHANGELOG}}", | |
"categories": [ | |
{ | |
"title": "## Feature", | |
"labels": ["feat", "feature"] | |
}, | |
{ | |
"title": "## Fix", | |
"labels": ["fix", "bug"] | |
}, | |
{ | |
"title": "## 🤖 CI", | |
"labels": ["automated-issue", "ci"] | |
}, | |
{ | |
"title": "## Other", | |
"labels": [] | |
} | |
] | |
} | |
EOF | |
- name: Get branch and version info | |
run: | | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
RELEASE_BRANCH=${{ github.event.pull_request.base.ref }} | |
# Get tag and version from PR title | |
TAG=$(echo '${{ github.event.pull_request.title }}' | awk '/Release/ {print $NF}' | tr -d '`') | |
VERSION="${TAG#*-v}" | |
else | |
RELEASE_BRANCH=${{ inputs.release-branch }} | |
VERSION=${{ inputs.version }} | |
fi | |
echo "RELEASE_BRANCH=$RELEASE_BRANCH" | tee -a $GITHUB_ENV | |
echo "VERSION=$VERSION" | tee -a $GITHUB_ENV | |
# - uses: tibdex/github-app-token@v2 | |
# id: generate-token | |
# with: | |
# app_id: ${{ secrets.TOKEN_APP_ID }} | |
# private_key: ${{ secrets.TOKEN_APP_PRIVATE_KEY }} | |
- name: Publish release | |
uses: ./ci-workflows/.github/actions/tag-release | |
with: | |
release-branch: ${{ env.RELEASE_BRANCH }} | |
version: ${{ env.VERSION }} | |
tag-prefix: sphinx | |
changelog-config-file: ./config.json |