Create Release Version - develop #4
Workflow file for this run
This file contains hidden or 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 | |
run-name: Create Release Version - ${{ github.ref_name }} | |
on: | |
push: | |
tags: | |
- "v*" | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "Tag for the release (e.g., v1.0.0)" | |
required: true | |
default: "v1.0.0" | |
notes: | |
description: "Additional release notes" | |
required: false | |
default: "" | |
draft: | |
description: "Mark the release as a draft" | |
required: true | |
default: "false" | |
prerelease: | |
description: "Mark the release as a prerelease" | |
required: true | |
default: "false" | |
permissions: | |
contents: write | |
jobs: | |
release: | |
name: Create Release for ${{ github.ref_name || github.event.inputs.tag }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if tag is valid | |
run: | | |
if [[ ! "${{ github.ref_name }}" =~ ^refs/tags/v.* ]]; then | |
echo "Auto Cancel: The event was triggered by a branch push or an invalid tag." | |
exit 78 | |
fi | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Determine tag and notes | |
id: set_inputs | |
run: | | |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_ENV | |
echo "additional_notes=${{ github.event.inputs.notes }}" >> $GITHUB_ENV | |
echo "draft=${{ github.event.inputs.draft }}" >> $GITHUB_ENV | |
echo "prerelease=${{ github.event.inputs.prerelease }}" >> $GITHUB_ENV | |
else | |
echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV | |
echo "additional_notes=" >> $GITHUB_ENV | |
echo "draft=false" >> $GITHUB_ENV | |
echo "prerelease=false" >> $GITHUB_ENV | |
fi | |
- name: Build changelog | |
id: build_changelog | |
uses: mikepenz/release-changelog-builder-action@main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create release | |
run: | | |
release_notes=$(printf "%s\n\n%s" \ | |
"${{ steps.build_changelog.outputs.changelog }}" \ | |
"${{ env.additional_notes }}") | |
gh release create "$tag" \ | |
--title "$tag" \ | |
--notes "$release_notes" \ | |
--draft=${{ env.draft }} \ | |
--prerelease=${{ env.prerelease }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |