Skip to content

Commit

Permalink
Fix tag-release
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelburnham committed Sep 24, 2024
1 parent c1fb1a9 commit ec38308
Showing 1 changed file with 39 additions and 14 deletions.
53 changes: 39 additions & 14 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
# Workflow to create a new tag release when a release branch is merged
name: Tag release
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-bump:
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.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
Expand All @@ -29,7 +41,8 @@ jobs:
ref: release-workflow
- name: Create changelog config
run: |
printf '%s\n' "{
cat << 'EOF' > config.json
{
"template": "#{{CHANGELOG}}",
"categories": [
{
Expand All @@ -41,21 +54,31 @@ jobs:
"labels": ["fix", "bug"]
},
{
"title": "## 🤖 CI",
"labels": ["automated-issue", "ci"]
},
{
"title": "## Other",
"labels": []
}
],
"label_extractor": [
{
"pattern": "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)",
"target": "$1"
}
],
}" > config.json
]
}
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#*-}"
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:
Expand All @@ -64,5 +87,7 @@ jobs:
- name: Publish release
uses: ./ci-workflows/.github/actions/tag-release
with:
release-branch: ${{ env.RELEASE_BRANCH }}
version: ${{ env.VERSION }}
tag-prefix: sphinx
config-file: ./config.json
changelog-config-file: ./config.json

0 comments on commit ec38308

Please sign in to comment.