Release #3
Workflow file for this run
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: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: "Branch to release from" | |
required: true | |
default: "master" | |
latest: | |
description: "Whether to set the release as the latest" | |
required: true | |
type: boolean | |
default: false | |
release_type: | |
description: "Release type" | |
type: choice | |
required: true | |
default: "patch" | |
options: | |
- major | |
- minor | |
- patch | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
artifact_name: task-tracker-cli-linux | |
extension: "" | |
- os: macos-latest | |
artifact_name: task-tracker-cli-macos | |
extension: "" | |
- os: windows-latest | |
artifact_name: task-tracker-cli-windows | |
extension: ".exe" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.branch }} | |
- name: Build | |
run: cargo build --release --verbose | |
- name: Archive Binary | |
if: startsWith(matrix.os, 'windows') == false | |
run: | | |
mkdir -p artifacts | |
cp target/release/task-tracker-cli${{ matrix.extension }} artifacts/ | |
- name: Archive Binary (Windows) | |
if: startsWith(matrix.os, 'windows') | |
run: | | |
mkdir artifacts | |
copy target\release\task-tracker-cli${{ matrix.extension }} artifacts\ | |
- name: Upload Release Assets | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.artifact_name }} | |
path: artifacts/task-tracker-cli${{ matrix.extension }} | |
create-release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get Latest Tag | |
id: get_latest_tag | |
run: | | |
latest_tag=$(git describe --tags --abbrev=0 || echo "v0.0.0") | |
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT | |
- name: Determine Next Version | |
id: determine_version | |
run: | | |
latest_version=${{ steps.get_latest_tag.outputs.latest_tag }} | |
version_without_v=${latest_version#v} | |
IFS='.' read -ra parts <<< "$version_without_v" | |
major=${parts[0]} | |
minor=${parts[1]} | |
patch=${parts[2]} | |
if [ "${{ inputs.release_type }}" == "major" ]; then | |
major=$((major + 1)) | |
minor=0 | |
patch=0 | |
elif [ "${{ inputs.release_type }}" == "minor" ]; then | |
minor=$((minor + 1)) | |
patch=0 | |
else | |
patch=$((patch + 1)) | |
fi | |
new_version="v${major}.${minor}.${patch}" | |
echo "new_version=$new_version" >> $GITHUB_OUTPUT | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./artifacts | |
- name: Create Git Tag | |
run: | | |
git tag ${{ steps.determine_version.outputs.new_version }} | |
git push origin ${{ steps.determine_version.outputs.new_version }} | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ steps.determine_version.outputs.new_version }} | |
files: ./artifacts/* | |
make_latest: ${{ inputs.latest }} |