Skip to content

Commit 7cd3ddf

Browse files
committed
add worker to publish release candidate packages and related artefacts
1 parent eefc7da commit 7cd3ddf

2 files changed

Lines changed: 71 additions & 2 deletions

File tree

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ jobs:
5656
run: yarn build:all
5757
- name: Create jest results
5858
# only use for final releases because it is necessary only in addition to storybook
59-
if: inputs.onlyNpmPush != true
59+
if: inputs.onlyNpmPush != true && inputs.sectionChangelog != "Unreleased"
6060
run: yarn test:generate-output
6161
- name: Publish to Chromatic
6262
# publish storybook only for final releases -- for other pre-releases the storybook has a link in PR
63-
if: inputs.onlyNpmPush != true
63+
if: inputs.onlyNpmPush != true && inputs.sectionChangelog != "Unreleased"
6464
id: chromatic-upload
6565
uses: chromaui/action@v11
6666
with:

0 commit comments

Comments
 (0)