Tag release #28
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: Tag release | |
on: | |
pull_request: | |
types: [ closed ] | |
branches: | |
- release/* | |
workflow_dispatch: | |
inputs: | |
light-client: | |
description: 'Light client to release' | |
type: 'string' | |
required: true | |
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-bump: | |
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 | |
# TODO: Refine changelog categories | |
- 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 '`') | |
LIGHT_CLIENT=${TAG%%-v*} | |
VERSION="${TAG#*-v}" | |
else | |
LIGHT_CLIENT=${{ inputs.light-client }} | |
RELEASE_BRANCH=${{ inputs.release-branch }} | |
VERSION=${{ inputs.version }} | |
fi | |
echo "LIGHT_CLIENT=$LIGHT_CLIENT" | tee -a $GITHUB_ENV | |
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: ${{ env.LIGHT_CLIENT }} | |
changelog-config-file: ./config.json |