Skip to content

2️⃣ Publish: release candidate #9

2️⃣ Publish: release candidate

2️⃣ Publish: release candidate #9

name: "2️⃣ Publish: release candidate"
on:
workflow_dispatch:
branches:
# allow dispatch only on release branches -- only documentation, it is not tested on workflow_dispatch
- "release/*"
inputs:
confirmation:
description: "Create candidate tag and publish package"
required: true
default: false
type: boolean
jobs:
publish-release-candidate:
runs-on: ubuntu-latest
outputs:
ref: v${{ steps.package-version.outputs.version }}
sha: ${{ steps.tag-revision.outputs.sha }}
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v8
- name: Allow only release branches
run: |
if [[ ! ${{ steps.branch-name.outputs.current_branch }} =~ ^(release)\/ ]] ;
then
echo "Only allowed to get triggered on release branches!"
echo "You started it on '${{ steps.branch-name.outputs.current_branch }}'."
exit 1
fi
- uses: actions/checkout@main
- name: Initialize mandatory git config
# @see https://github.community/t/how-do-i-get-gh-username-based-on-actions-events/17882
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- uses: actions/setup-node@main
with:
node-version: "18"
- name: Create release candidate version number
run: |
preid="rc"
publishedversions=$(npm view @eccenca/gui-elements versions)
yarn version --no-git-tag-version --new-version $(node -p -e "require('./package.json').version.split('-').shift()")-$preid.0
while [ -n "$( echo $publishedversions | grep \'$(node -p -e "require('./package.json').version")\' )" ] ; do yarn version --no-git-tag-version --preid "$preid" --prerelease ; done
- name: Get version
id: package-version
run: echo "version=$(node -p -e "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Create tag for release candidate and push
id: tag-revision
run: |
git commit package.json --message "Bump version release candidate ${{ steps.package-version.outputs.version }}"
git tag -a v${{ steps.package-version.outputs.version }} -m "tag release candidate v${{ steps.package-version.outputs.version }}"
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
git push origin v${{ steps.package-version.outputs.version }}
publish-package:
needs: publish-release-candidate
uses: ./.github/workflows/push-tagged-release.yml
with:
ref: ${{ needs.publish-release-candidate.outputs.ref }}
sha: ${{ needs.publish-release-candidate.outputs.sha }}
sectionChangelog: Unreleased
onlyNpmPush: false
secrets:
chromaticToken: None
npmjsToken: ${{ secrets.NPMJS_REGISTRY_TOKEN }}