Create Release #1
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 | |
on: | |
workflow_dispatch: | |
inputs: | |
version_bump: | |
description: 'Which part of the version to bump (major, minor, patch)' | |
required: true | |
default: 'patch' | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout selected branch | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref_name }} | |
- name: Get latest tag | |
id: get_tag | |
run: | | |
latest_tag=$(git tag --sort=-v:refname | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+' | head -n1) | |
echo "Latest tag: $latest_tag" | |
if [[ -z "$latest_tag" ]]; then | |
echo "tag=0.0.0" >> $GITHUB_OUTPUT | |
else | |
echo "tag=${latest_tag#v}" >> $GITHUB_OUTPUT | |
fi | |
- name: Calculate next version | |
id: bump_version | |
run: | | |
IFS='.' read -r major minor patch <<< "${{ steps.get_tag.outputs.tag }}" | |
case "${{ github.event.inputs.version_bump }}" in | |
major) | |
((major+=1)); minor=0; patch=0;; | |
minor) | |
((minor+=1)); patch=0;; | |
patch) | |
((patch+=1));; | |
esac | |
new_version="v$major.$minor.$patch" | |
echo "New version: $new_version" | |
echo "new_tag=$new_version" >> $GITHUB_OUTPUT | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ steps.bump_version.outputs.new_tag }} | |
target_commitish: ${{ github.ref_name }} | |
generate_release_notes: true | |
draft: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |