|
| 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 }} |
0 commit comments