Skip to content

Commit adbb8b8

Browse files
committed
add workflow to publish final release, switch to manual dispatcher to separate process from merge
1 parent d53bd4b commit adbb8b8

5 files changed

Lines changed: 98 additions & 6 deletions

File tree

.github/workflows/create-release-branch.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
id: create-branch
4444
run: |
4545
git checkout -b release/v${{ steps.create-version.outputs.version }}
46-
echo "label=release/v${{ steps.create-version.outputs.version }}" >> $GITHUB_OUTPUT
46+
echo "releasebranch=release/v${{ steps.create-version.outputs.version }}" >> $GITHUB_OUTPUT
4747
- name: Initialize mandatory git config
4848
# @see https://github.community/t/how-do-i-get-gh-username-based-on-actions-events/17882
4949
run: |
@@ -55,16 +55,16 @@ jobs:
5555
git commit package.json --message "Prepare release v${{ steps.create-version.outputs.version }}"
5656
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
5757
- name: Push release branch
58-
run: git push origin ${{ steps.create-branch.outputs.label }}
58+
run: git push origin ${{ steps.create-branch.outputs.releasebranch }}
5959
- name: Create pull request for release
6060
uses: thomaseizinger/create-pull-request@master
6161
with:
6262
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63-
head: ${{ steps.create-branch.outputs.label }}
63+
head: ${{ steps.create-branch.outputs.releasebranch }}
6464
base: ${{ steps.dispatched-branch.outputs.targetbranch }}
6565
title: Release v${{ steps.create-version.outputs.version }} into ${{ steps.dispatched-branch.outputs.targetbranch }} branch
6666
draft: true
6767
reviewers: ${{ github.actor }}
6868
body: |
6969
Created by Github workflow to create release branches.
70-
Merging this PR will trigger tag creation and package release.
70+
After merging this PR the "publish final release" action can be triggered on `${{ steps.dispatched-branch.outputs.targetbranch }}`.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: "Publish: final release"
2+
3+
on:
4+
workflow_dispatch:
5+
branches:
6+
# allow dispatch only main branches -- only documentation, it is not tested on workflow_dispatch
7+
- "main"
8+
- "next"
9+
- "legacy"
10+
inputs:
11+
confirmation:
12+
description: "Create release tag and publish package"
13+
required: true
14+
default: false
15+
type: boolean
16+
17+
jobs:
18+
publish-final-release:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
version: ${{ steps.package-version.outputs.version }}
22+
sha: ${{ steps.tag-revision.outputs.sha }}
23+
24+
steps:
25+
- name: Get branch name
26+
id: branch-name
27+
uses: tj-actions/branch-names@v8
28+
- name: Allow only for feature/fix branches
29+
id: dispatched-branch
30+
run: |
31+
if [[ ! ${{ steps.branch-name.outputs.current_branch }} =~ ^(main|next|legacy)$ ]] ;
32+
then
33+
echo "Only allowed to get triggered on main branches!"
34+
echo "You started it on '${{ steps.branch-name.outputs.current_branch }}'."
35+
exit 1
36+
fi
37+
echo "targetbranch=(echo ${{ steps.branch-name.outputs.current_branch }} | sed 's=^develop$=main=')" >> $GITHUB_OUTPUT
38+
- uses: actions/checkout@main
39+
- name: Initialize mandatory git config
40+
# @see https://github.community/t/how-do-i-get-gh-username-based-on-actions-events/17882
41+
run: |
42+
git config user.name "${{ github.actor }}"
43+
git config user.email "${{ github.actor }}@users.noreply.github.com"
44+
- uses: actions/setup-node@main
45+
with:
46+
node-version: "18"
47+
- name: Get version
48+
id: package-version
49+
run: echo "version=$(node -p -e "require('./package.json').version.split('-').shift()")" >> $GITHUB_OUTPUT
50+
- name: Check if version already exists as package
51+
id: check-version-existence
52+
run: |
53+
if [ -n "$( npm view @eccenca/gui-elements versions | grep ${{ steps.package-version.outputs.version }} )" ] ; then echo "Stop: v${{ steps.package-version.outputs.version }} is already published!" && false; else echo "Continue: v${{ steps.package-version.outputs.version }} is not published."; fi
54+
- name: Update version in repository
55+
run: |
56+
yarn version --no-git-tag-version --new-version ${{ steps.package-version.outputs.version }}
57+
sed -i "s/## \[Unreleased\]/## \[Unreleased\]\n\n## [${{ steps.package-version.outputs.version }}] - $(date -I)/g" ./CHANGELOG.md
58+
git commit package.json CHANGELOG.md --message "Update changelog section to ${{ steps.package-version.outputs.version }}"
59+
- name: Create version tag
60+
id: tag-revision
61+
run: |
62+
git tag -a v${{ steps.package-version.outputs.version }} -m "tag final release v${{ steps.package-version.outputs.version }}"
63+
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
64+
- name: Push tag and changes
65+
run: |
66+
git push origin v${{ steps.package-version.outputs.version }}
67+
git push origin maintain/mergeReleaseTag-v${{ steps.package-version.outputs.version }}
68+
- name: Create pull request merge back release process changes
69+
uses: thomaseizinger/create-pull-request@master
70+
with:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
head: maintain/mergeReleaseTag-v${{ steps.package-version.outputs.version }}
73+
base: ${{ steps.dispatched-branch.outputs.targetbranch }}
74+
title: Release process changes from v${{ steps.create-version.outputs.version }}
75+
draft: true
76+
reviewers: ${{ github.actor }}
77+
body: |
78+
Created by Github workflow.
79+
After merging this PR the "publish final release" action can be triggered on `${{ steps.dispatched-branch.outputs.targetbranch }}`.
80+
81+
publish-package:
82+
needs: publish-final-release
83+
uses: ./.github/workflows/push-tagged-release.yml
84+
with:
85+
ref: v${{ needs.publish-final-release.outputs.version }}
86+
sha: ${{ needs.publish-final-release.outputs.sha }}
87+
sectionChangelog: ${{ needs.publish-final-release.outputs.version }}
88+
onlyNpmPush: false
89+
secrets:
90+
chromaticToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
91+
npmjsToken: ${{ secrets.NPMJS_REGISTRY_TOKEN }}

.github/workflows/publish-release-candidate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- "release/*"
88
inputs:
99
confirmation:
10-
description: "Create feature tag and publish package"
10+
description: "Create candidate tag and publish package"
1111
required: true
1212
default: false
1313
type: boolean

.github/workflows/push-tagged-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
echo ${{ inputs.ref }}
3030
echo ${{ inputs.sha }}
3131
echo ${{ inputs.sectionChangelog }}
32+
echo ${{ inputs.onlyNpmPush }}
3233
- uses: actions/checkout@main
3334
with:
3435
fetch-depth: 0

.github/workflows/test-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: finleyfamily/action-enforce-branch-name@master
1919
with:
2020
regex: '([a-z])+\/([a-z]).([aA-zZ\.\-\d])+'
21-
allowed_prefixes: "feature,release,fix,bugfix,hotfix,change,temp,test,dependabot"
21+
allowed_prefixes: "feature,release,fix,bugfix,hotfix,change,temp,test,dependabot,maintain"
2222
exclude: "main,develop,next,legacy"
2323
test-documentation:
2424
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)