Skip to content

Publish a Release

Publish a Release #1

name: Publish a Release
on:
workflow_dispatch:
inputs:
version:
description: 'The version tag to use in the form of x.x.x'
required: true
type: string
prerelease:
description: 'Check if this is to publish a pre-release.'
required: true
type: boolean
jobs:
make-tag-string:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag-string.outputs.tag }}
steps:
- name: Create tag
run: |
[ ${{ inputs.prerelease }} = false ] && echo "tag=${{ inputs.version }}" >> $GITHUB_OUTPUT || \
echo "tag=${{ inputs.version }}-$GITHUB_RUN_NUMBER-prerelease" >> $GITHUB_OUTPUT
id: tag-string
validate-no-tag:
runs-on: ubuntu-latest
needs: [make-tag-string]
steps:
- name: Fetch Code
continue-on-error: true
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
ref: refs/tags/${{ needs.make-tag-string.outputs.tag }}
- name: Fail if tag ${{ needs.make-tag-string.outputs.tag }} exists
run: |
[[ $(git describe --tags) == ${{ needs.make-tag-string.outputs.tag }} ]] && exit 1 || :
invoke-build-for-publish:
uses: ./.github/workflows/invoke-build.yml
with:
tag: ${{ needs.make-tag-string.outputs.tag }}
prerelease: ${{ inputs.prerelease }}
needs: [make-tag-string, validate-no-tag]