Skip to content

Commit

Permalink
Extra Workflow Options
Browse files Browse the repository at this point in the history
  • Loading branch information
CaymanFreeman committed Dec 7, 2024
1 parent 217cc10 commit 07c2f0e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 33 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,28 @@ on:
workflow_dispatch:
inputs:
release_type:
description: 'Release Type'
description: "Release Type"
required: true
type: choice
options:
- Patch (0.0.x)
- Minor (0.x.0)
- Major (x.0.0)
beta:
description: 'Beta Version'
description: "Beta Version"
required: true
type: boolean
default: false
version_override:
description: "Version Override"
required: false
type: string
default: ""
release_changes:
description: "Release Changes"
required: false
type: string
default: "- Changed lorem ipsum"

permissions:
contents: write
Expand All @@ -27,6 +37,7 @@ jobs:
with:
release_type: ${{ inputs.release_type }}
beta: ${{ inputs.beta }}
version_override: ${{ inputs.version_override }}

pyinstaller-build:
needs: release-version
Expand Down Expand Up @@ -63,7 +74,7 @@ jobs:
### Changes
- Changed lorem ipsum
${{ inputs.release_changes }}
generate_release_notes: true
prerelease: ${{ inputs.beta }}
draft: true
Expand Down
37 changes: 7 additions & 30 deletions .github/workflows/release-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
beta:
required: true
type: boolean
version_override:
required: true
type: string
outputs:
release_version:
value: ${{ jobs.determine-version.outputs.release_version }}
Expand All @@ -20,38 +23,12 @@ jobs:
release_version: ${{ steps.version.outputs.release_version }}

steps:
- uses: actions/checkout@v4

- name: Determine Release Version
id: version
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
LATEST_VERSION=$(gh release list --limit 1 --json tagName | jq -r '.[] | .tagName' | sed 's/^v//')
if [[ -z "$LATEST_VERSION" ]]; then
LATEST_VERSION="0.1.0"
fi
IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_VERSION"
case "${{ inputs.release_type }}" in
"Major (x.0.0)")
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
"Minor (0.x.0)")
MINOR=$((MINOR + 1))
PATCH=0
;;
"Patch (0.0.x)")
PATCH=$((PATCH + 1))
;;
esac
VERSION="${MAJOR}.${MINOR}.${PATCH}"
if [[ "${{ inputs.beta }}" == "true" ]]; then
VERSION="${VERSION}b"
fi
echo "release_version=$VERSION" >> $GITHUB_OUTPUT
sudo chmod +x .github/workflows/scripts/ubuntu/release_version.sh
.github/workflows/scripts/ubuntu/release_version.sh "${{ inputs.release_type }}" "${{ inputs.version_override }}" "${{ inputs.beta }}"
39 changes: 39 additions & 0 deletions .github/workflows/scripts/ubuntu/release_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
RELEASE_TYPE=$1
VERSION_OVERRIDE=$2
BETA=$3

LATEST_VERSION=$(gh release list --limit 1 --json tagName | jq -r '.[] | .tagName' | sed 's/^v//')

if [[ -z "$LATEST_VERSION" ]]; then
LATEST_VERSION="0.1.0"
fi

IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_VERSION"

case "$RELEASE_TYPE" in
"Major (x.0.0)")
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
"Minor (0.x.0)")
MINOR=$((MINOR + 1))
PATCH=0
;;
"Patch (0.0.x)")
PATCH=$((PATCH + 1))
;;
esac

VERSION="${MAJOR}.${MINOR}.${PATCH}"

if [[ -n "$VERSION_OVERRIDE" ]]; then
LATEST_VERSION="$VERSION_OVERRIDE"
fi

if [[ "$BETA" == "true" ]]; then
VERSION="${VERSION}b"
fi

echo "release_version=$VERSION" >> $GITHUB_OUTPUT

0 comments on commit 07c2f0e

Please sign in to comment.