Create Release #45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Release | |
on: | |
workflow_dispatch: | |
inputs: | |
is_prerelease: | |
description: 'Create a prerelease:' | |
type: boolean | |
required: true | |
default: false | |
is_draft: | |
description: 'Set as a draft:' | |
type: boolean | |
required: true | |
default: false | |
env: | |
ALLOW_PRERELEASE: ${{ startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/hotfix/') }} | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check For Valid Prerelease | |
if: ${{ ( env.ALLOW_PRERELEASE == 'true' && github.event.inputs.is_prerelease == 'false' ) || ( github.ref == 'refs/heads/main' && github.event.inputs.is_prerelease == 'true' ) }} | |
run: | | |
echo "Prereleases should not be triggered on the main branch, please use development or hotfix" | |
exit 1 | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Get Current Version | |
id: get_version | |
shell: pwsh | |
run: | | |
Import-Module ./solution-helper.psm1 -Force | |
$version = Get-Version | |
if ("${{ github.event.inputs.is_prerelease }}" -eq "true") { | |
$version_tag = "$version-develop.$(date +'%y%m%d%H%M%S')" | |
} else { | |
$version_tag = $version | |
} | |
echo "version_tag=$version_tag" | Out-File -FilePath $env:GITHUB_ENV -Append | |
- name: Create Release | |
run: | | |
echo "🎁 Creating release ${{ env.version_tag }}" | |
gh release create ${{ env.version_tag }} \ | |
--target ${{ github.ref_name }} \ | |
--title ${{ env.version_tag }} \ | |
--generate-notes \ | |
$(if [[ "${{ github.event.inputs.is_draft }}" == "true" ]]; then echo "--draft"; fi) \ | |
$(if [[ "${{ github.event.inputs.is_prerelease }}" == "true" ]]; then echo "--prerelease"; fi) \ | |
$(if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then echo "--latest"; fi) | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |