Skip to content

Commit cb5aa1e

Browse files
Merge branch 'bugfix/text-marking-autocomplete-CMEM-6577' of https://github.com/eccenca/gui-elements into bugfix/text-marking-autocomplete-CMEM-6577
2 parents c7f8826 + ed8d8f4 commit cb5aa1e

11 files changed

Lines changed: 245 additions & 121 deletions

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Release: Create release branch"
1+
name: "1️⃣ Create: release branch"
22

33
on:
44
workflow_dispatch:
@@ -23,16 +23,27 @@ jobs:
2323
- uses: actions/setup-node@main
2424
with:
2525
node-version: "18"
26+
- name: Check and save dispatched branch
27+
id: dispatched-branch
28+
run: |
29+
branchname=$(git describe --all --exact-match | sed 's=heads/==')
30+
echo "Dispatched on $branchname"
31+
if [[ ! "$branchname" =~ ^(main|next|legacy)$ ]]; then echo "Branch $branchname is not allowed to dispatch this action on, use it only on develop, next and legacy." && false; fi
32+
echo "targetbranch=(echo $branchname | sed 's=^develop$=main=')" >> $GITHUB_OUTPUT
2633
- name: Update package.json with new release candidate version
2734
id: create-version
2835
run: |
29-
yarn version --no-git-tag-version --preid "rc" --pre${{ github.event.inputs.releasetype }}
36+
yarn version --no-git-tag-version --${{ github.event.inputs.releasetype }}
3037
echo "version=$(node -p -e "require('./package.json').version.split('-').shift()")" >> $GITHUB_OUTPUT
38+
- name: Check if version already exists as package
39+
id: check-version-existence
40+
run: |
41+
if [ -n "$( npm view @eccenca/gui-elements versions | grep ${{ steps.create-version.outputs.version }} )" ] ; then echo "Stop: v${{ steps.create-version.outputs.version }} is already published!" && false; else echo "Continue: v${{ steps.create-version.outputs.version }} is not published."; fi
3142
- name: Create release branch
3243
id: create-branch
3344
run: |
3445
git checkout -b release/v${{ steps.create-version.outputs.version }}
35-
echo "label=release/v${{ steps.create-version.outputs.version }}" >> $GITHUB_OUTPUT
46+
echo "releasebranch=release/v${{ steps.create-version.outputs.version }}" >> $GITHUB_OUTPUT
3647
- name: Initialize mandatory git config
3748
# @see https://github.community/t/how-do-i-get-gh-username-based-on-actions-events/17882
3849
run: |
@@ -44,16 +55,16 @@ jobs:
4455
git commit package.json --message "Prepare release v${{ steps.create-version.outputs.version }}"
4556
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
4657
- name: Push release branch
47-
run: git push origin ${{ steps.create-branch.outputs.label }}
48-
- name: Create pull request into main
58+
run: git push origin ${{ steps.create-branch.outputs.releasebranch }}
59+
- name: Create pull request for release
4960
uses: thomaseizinger/create-pull-request@master
5061
with:
5162
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52-
head: ${{ steps.create-branch.outputs.label }}
53-
base: main
54-
title: Release v${{ steps.create-version.outputs.version }} into main branch
63+
head: ${{ steps.create-branch.outputs.releasebranch }}
64+
base: ${{ steps.dispatched-branch.outputs.targetbranch }}
65+
title: Release v${{ steps.create-version.outputs.version }} into ${{ steps.dispatched-branch.outputs.targetbranch }} branch
5566
draft: true
5667
reviewers: ${{ github.actor }}
5768
body: |
5869
Created by Github workflow to create release branches.
59-
Merge this PR will trigger a tag creation and package release.
70+
After merging this PR the "publish final release" action can be triggered on `${{ steps.dispatched-branch.outputs.targetbranch }}`.

.github/workflows/deployment-storybook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "CI_03: Storybook deployment"
1+
name: "⬆️ Push: Storybook"
22

33
on:
44
pull_request:
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: "0️⃣ Publish: feature/fix pre-release"
2+
3+
on:
4+
workflow_dispatch:
5+
branches:
6+
# allow dispatch only on a few branch types -- only documentation, it is not tested on workflow_dispatch
7+
- "feature/*"
8+
- "fix/*"
9+
- "bugfix/*"
10+
- "hotfix/*"
11+
inputs:
12+
confirmation:
13+
description: "Create feature tag and publish package"
14+
required: true
15+
default: false
16+
type: boolean
17+
18+
jobs:
19+
publish-featurefix-prerelease:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
ref: v${{ steps.package-version.outputs.version }}
23+
sha: ${{ steps.tag-revision.outputs.sha }}
24+
25+
steps:
26+
- name: Get branch name
27+
id: branch-name
28+
uses: tj-actions/branch-names@v8
29+
- name: Allow only for feature/fix branches
30+
run: |
31+
if [[ ! ${{ steps.branch-name.outputs.current_branch }} =~ ^(feature|fix|bugfix|hotfix)\/ ]] ;
32+
then
33+
echo "Only allowed to get triggered on feature and fix branches!"
34+
echo "You started it on '${{ steps.branch-name.outputs.current_branch }}'."
35+
exit 1
36+
fi
37+
- uses: actions/checkout@main
38+
- name: Initialize mandatory git config
39+
# @see https://github.community/t/how-do-i-get-gh-username-based-on-actions-events/17882
40+
run: |
41+
git config user.name "${{ github.actor }}"
42+
git config user.email "${{ github.actor }}@users.noreply.github.com"
43+
- uses: actions/setup-node@main
44+
with:
45+
node-version: "18"
46+
- name: Create pre-release version number
47+
run: |
48+
preid=$(echo ${{ steps.branch-name.outputs.current_branch }} | tr '[:upper:]' '[:lower:]' | sed 's=[^[:alnum:][:space:]"]==g')
49+
publishedversions=$(npm view @eccenca/gui-elements versions)
50+
yarn version --no-git-tag-version --new-version $(node -p -e "require('./package.json').version.split('-').shift()")-$preid.0
51+
while [ -n "$( echo $publishedversions | grep $(node -p -e "require('./package.json').version") )" ] ; do yarn version --no-git-tag-version --preid "$preid" --prerelease ; done
52+
- name: Get version
53+
id: package-version
54+
run: echo "version=$(node -p -e "require('./package.json').version")" >> $GITHUB_OUTPUT
55+
- name: Create tag for pre-release version and push
56+
id: tag-revision
57+
run: |
58+
git commit package.json --message "Bump version pre-release test package ${{ steps.package-version.outputs.version }}"
59+
git tag -a v${{ steps.package-version.outputs.version }} -m "tag pre-release v${{ steps.package-version.outputs.version }}"
60+
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
61+
git push origin v${{ steps.package-version.outputs.version }}
62+
publish-package:
63+
needs: publish-featurefix-prerelease
64+
uses: ./.github/workflows/push-tagged-release.yml
65+
with:
66+
ref: ${{ needs.publish-featurefix-prerelease.outputs.ref }}
67+
sha: ${{ needs.publish-featurefix-prerelease.outputs.sha }}
68+
sectionChangelog: Unreleased
69+
onlyNpmPush: true
70+
secrets:
71+
chromaticToken: None
72+
npmjsToken: ${{ secrets.NPMJS_REGISTRY_TOKEN }}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: "3️⃣ 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=^main$=develop=')" >> $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 }}
Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
name: "Release: Create release candidate"
1+
name: "2️⃣ Publish: release candidate"
22

33
on:
44
workflow_dispatch:
55
branches:
6-
- "release/*" # only documentation, it is not tested on workflow_dispatch
6+
# allow dispatch only on release branches -- only documentation, it is not tested on workflow_dispatch
7+
- "release/*"
78
inputs:
89
confirmation:
9-
description: "Create release tag and publish package"
10+
description: "Create candidate tag and publish package"
1011
required: true
1112
default: false
1213
type: boolean
1314

1415
jobs:
15-
create-release-candidate:
16+
publish-release-candidate:
1617
runs-on: ubuntu-latest
1718
outputs:
1819
ref: v${{ steps.package-version.outputs.version }}
@@ -22,9 +23,9 @@ jobs:
2223
- name: Get branch name
2324
id: branch-name
2425
uses: tj-actions/branch-names@v8
25-
- name: Allow only for release branch
26+
- name: Allow only release branches
2627
run: |
27-
if [[ ${{ steps.branch-name.outputs.current_branch }} != release* ]] ;
28+
if [[ ! ${{ steps.branch-name.outputs.current_branch }} =~ ^(release)\/ ]] ;
2829
then
2930
echo "Only allowed to get triggered on release branches!"
3031
echo "You started it on '${{ steps.branch-name.outputs.current_branch }}'."
@@ -39,29 +40,30 @@ jobs:
3940
- uses: actions/setup-node@main
4041
with:
4142
node-version: "18"
43+
- name: Create release candidate version number
44+
run: |
45+
preid="rc"
46+
publishedversions=$(npm view @eccenca/gui-elements versions)
47+
yarn version --no-git-tag-version --new-version $(node -p -e "require('./package.json').version.split('-').shift()")-$preid.0
48+
while [ -n "$( echo $publishedversions | grep $(node -p -e "require('./package.json').version") )" ] ; do yarn version --no-git-tag-version --preid "$preid" --prerelease ; done
4249
- name: Get version
4350
id: package-version
4451
run: echo "version=$(node -p -e "require('./package.json').version")" >> $GITHUB_OUTPUT
45-
- name: Create version tag
52+
- name: Create tag for release candidate and push
4653
id: tag-revision
4754
run: |
55+
git commit package.json --message "Bump version release candidate ${{ steps.package-version.outputs.version }}"
4856
git tag -a v${{ steps.package-version.outputs.version }} -m "tag release candidate v${{ steps.package-version.outputs.version }}"
4957
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
50-
- name: Bump release candidate version in package.json
51-
run: |
52-
yarn version --no-git-tag-version --preid "rc" --prerelease
53-
git commit package.json --message "Bump release version to next release candidate $(node -p -e "require('./package.json').version")"
54-
- name: Push tag and changes
55-
run: |
56-
git push
5758
git push origin v${{ steps.package-version.outputs.version }}
5859
publish-package:
59-
needs: create-release-candidate
60-
uses: ./.github/workflows/release-publish.yml
60+
needs: publish-release-candidate
61+
uses: ./.github/workflows/push-tagged-release.yml
6162
with:
62-
ref: ${{ needs.create-release-candidate.outputs.ref }}
63-
sha: ${{ needs.create-release-candidate.outputs.sha }}
63+
ref: ${{ needs.publish-release-candidate.outputs.ref }}
64+
sha: ${{ needs.publish-release-candidate.outputs.sha }}
6465
sectionChangelog: Unreleased
66+
onlyNpmPush: false
6567
secrets:
6668
chromaticToken: None
6769
npmjsToken: ${{ secrets.NPMJS_REGISTRY_TOKEN }}
Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Release: Publish tagged version"
1+
name: "⬆️ Push: package & tagged release"
22

33
on:
44
workflow_call:
@@ -11,21 +11,25 @@ on:
1111
type: string
1212
sectionChangelog:
1313
type: string
14+
onlyNpmPush:
15+
type: boolean
16+
default: false
1417
secrets:
1518
chromaticToken:
1619
required: true
1720
npmjsToken:
1821
required: true
1922

2023
jobs:
21-
publish-tagged-release:
24+
push-tagged-release:
2225
runs-on: "ubuntu-latest"
2326
steps:
2427
- name: Check input vars
2528
run: |
2629
echo ${{ inputs.ref }}
2730
echo ${{ inputs.sha }}
2831
echo ${{ inputs.sectionChangelog }}
32+
echo ${{ inputs.onlyNpmPush }}
2933
- uses: actions/checkout@main
3034
with:
3135
fetch-depth: 0
@@ -41,6 +45,8 @@ jobs:
4145
echo "tag=${{ inputs.ref }}" >> $GITHUB_OUTPUT
4246
echo "version=$(echo ${{ inputs.ref }} | cut -c2-)" >> $GITHUB_OUTPUT
4347
- name: Get changelog entry
48+
# only use for final releases -- for other pre-releases the changelog is visible in the PR
49+
if: inputs.onlyNpmPush != true
4450
id: info-changelog
4551
uses: mindsers/changelog-reader-action@v2
4652
with:
@@ -50,11 +56,12 @@ jobs:
5056
- name: Create dist JS
5157
run: yarn build:all
5258
- name: Create jest results
59+
# only use for final releases because it is necessary only in addition to storybook
60+
if: ${{ inputs.onlyNpmPush != true && inputs.sectionChangelog != 'Unreleased' }}
5361
run: yarn test:generate-output
5462
- name: Publish to Chromatic
55-
# publish storybook only for final releases because of chromaui/action bug
56-
# @see https://github.com/chromaui/chromatic-cli/issues/551
57-
if: inputs.sectionChangelog != 'Unreleased'
63+
# publish storybook only for final releases -- for other pre-releases the storybook has a link in PR
64+
if: ${{ inputs.onlyNpmPush != true && inputs.sectionChangelog != 'Unreleased' }}
5865
id: chromatic-upload
5966
uses: chromaui/action@v11
6067
with:
@@ -65,13 +72,20 @@ jobs:
6572
run: yarn publish --access public
6673
env:
6774
NODE_AUTH_TOKEN: ${{ secrets.npmjsToken }}
75+
- name: Prepare release info
76+
# only use for final releases and RCs -- other pre-releases do not need an official announcement
77+
if: inputs.onlyNpmPush != true
78+
run: |
79+
touch ./releasecontent.md
80+
echo "* NPM package: https://www.npmjs.com/package/@eccenca/gui-elements/v/${{ steps.info-vars.outputs.version }}" >> ./releasecontent.md
81+
$( if [[ ! "${{ inputs.sectionChangelog }}" =~ ^(Unreleased)$ ]]; then echo "* Storybook: ${{ steps.chromatic-upload.outputs.storybookUrl }}" >> ./releasecontent.md; fi )
82+
$( if [[ ! "${{ inputs.sectionChangelog }}" =~ ^(Unreleased)$ ]]; then echo "${{ steps.info-changelog.outputs.changes }}" >> ./releasecontent.md; else echo "* Changelog: https://github.com/eccenca/gui-elements/blob/${{ inputs.ref }}/CHANGELOG.md#unreleased" >> ./releasecontent.md; fi )
6883
- name: Publish release
84+
# only use for final releases and RCs -- other pre-releases do not need an official announcement
85+
if: inputs.onlyNpmPush != true
6986
uses: ncipollo/release-action@v1
7087
with:
7188
tag: ${{ steps.info-vars.outputs.tag }}
72-
body: |
73-
NPM package: https://www.npmjs.com/package/@eccenca/gui-elements/v/${{ steps.info-vars.outputs.version }}
74-
Storybook: ${{ steps.chromatic-upload.outputs.storybookUrl }}
75-
${{ steps.info-changelog.outputs.changes }}
89+
bodyFile: ./releasecontent.md
7690
prerelease: ${{ steps.info-changelog.outputs.status == 'unreleased' }}
7791
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)