-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: "Release TapToQR" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release-type: | ||
type: choice | ||
description: Which type of release to create? | ||
required: true | ||
default: patch | ||
options: | ||
- patch | ||
- minor | ||
- major | ||
|
||
concurrency: | ||
group: ${{ github.workflow }} | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
# Get the Current Version and Bump it depending on the release-type input | ||
update-version: | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
outputs: | ||
new_version: ${{ steps.bump_version.outputs.new_version }} | ||
steps: | ||
- name: Ensure branch is main | ||
if: github.ref != 'refs/heads/main' | ||
run: | | ||
text="Publish a new version can only be done from the main branch." | ||
echo "::error title=Wrong Branch::$text" | ||
exit 1 | ||
- name: Read current version | ||
run: | | ||
echo "Current version: ${{ vars.VERSION }}" | ||
- name: Bump version | ||
id: bump_version | ||
run: | | ||
# Retrieve the increment type from the GitHub Actions input | ||
increment="${{ inputs.release-type }}" | ||
# Split the VERSION variable into its major, minor, and patch components | ||
IFS='.' read -r -a parts <<< "${{ vars.VERSION }}" | ||
# Check if the VERSION variable was split correctly | ||
if [ "${#parts[@]}" -ne 3 ]; then | ||
echo "Invalid version format" | ||
exit 1 | ||
fi | ||
major=${parts[0]} | ||
minor=${parts[1]} | ||
patch=${parts[2]} | ||
# Increment the appropriate version component | ||
if [ "$increment" = "major" ]; then | ||
major=$((major + 1)) | ||
minor=0 | ||
patch=0 | ||
elif [ "$increment" = "minor" ]; then | ||
minor=$((minor + 1)) | ||
patch=0 | ||
elif [ "$increment" = "patch" ]; then | ||
patch=$((patch + 1)) | ||
else | ||
echo "Invalid increment type" | ||
exit 1 | ||
fi | ||
# Construct the new version string | ||
new_version="$major.$minor.$patch" | ||
# Output the new version | ||
echo "New version: $new_version" | ||
# Set the output variable for GitHub Actions | ||
echo "new_version=$new_version" >> $GITHUB_OUTPUT | ||
- name: Update version var | ||
id: write_version | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh variable set VERSION --body "${{ steps.bump_version.outputs.new_version }}" |