1
0
reusable-workflows/.gitea/workflows/parseVersion.yaml

65 lines
2.0 KiB
YAML
Raw Normal View History

2024-10-18 06:46:44 +00:00
name: Parse Version Number
on:
workflow_call:
inputs:
version:
required: true
type: string
outputs:
major:
description: "Major number"
value: ${{ jobs.parse.outputs.major }}
minor:
description: "Minor number"
value: ${{ jobs.parse.outputs.minor }}
patch:
description: "Patch number"
value: ${{ jobs.parse.outputs.patch }}
build:
description: "Build number"
value: ${{ jobs.parse.outputs.build }}
2024-10-18 22:49:08 +00:00
simpleVersion:
description: "Simple Version output"
value: ${{ jobs.parse.outputs.simpleVersion }}
buildVersion:
description: "Build Version Output"
value: ${{ jobs.parse.outputs.buildVersion }}
2024-10-18 06:46:44 +00:00
jobs:
parse:
runs-on: ubuntu-latest
outputs:
major: ${{ steps.parseStep.outputs.major }}
minor: ${{ steps.parseStep.outputs.minor }}
patch: ${{ steps.parseStep.outputs.patch }}
build: ${{ steps.parseStep.outputs.build }}
steps:
- id: parseStep
run: |
2024-10-18 23:14:03 +00:00
input="${{ inputs.version }}"
input="${VERSION#refs/tags/}"
2024-10-18 22:42:58 +00:00
2024-10-18 23:14:03 +00:00
if [[ "$input" == *"/"* ]]; then
prefix=$(echo "$input" | cut -d'/' -f1)
version=$(echo "$input" | cut -d'/' -f2)
else
prefix="beta"
version="$input"
fi
version=$(echo ${{ inputs.version }} | sed 's|.*/||')
IFS='.' read -r major minor patch build <<< "$version"
2024-10-18 06:46:44 +00:00
if [ -z "$build" ]; then
build="0"
fi
2024-10-18 22:49:08 +00:00
SIMPLE_VERSION=$(echo $major.$minor.$patch.$build)
BUILD_VERSION=$(echo $major.$minor.$patch-build.$build)
2024-10-18 06:46:44 +00:00
echo "major=$major" >> $GITHUB_OUTPUT
echo "minor=$minor" >> $GITHUB_OUTPUT
echo "patch=$patch" >> $GITHUB_OUTPUT
2024-10-18 22:49:08 +00:00
echo "build=$build" >> $GITHUB_OUTPUT
echo "simpleVersion=$SIMPLE_VERSION" >> $GITHUB_OUTPUT
echo "buildVersion=$BUILD_VERSION" >> $GITHUB_OUTPUT