Added many, many more actions.
This commit is contained in:
38
utils/version-parse/action.yaml
Normal file
38
utils/version-parse/action.yaml
Normal file
@@ -0,0 +1,38 @@
|
||||
name: version-parse
|
||||
description: "Parse a semantic version."
|
||||
inputs:
|
||||
version:
|
||||
description: "The version to parse."
|
||||
required: true
|
||||
outputs:
|
||||
version:
|
||||
description: "The version of the package."
|
||||
value: ${{ steps.parse.outputs.version }}
|
||||
major:
|
||||
description: "The major version of the package."
|
||||
value: ${{ steps.parse.outputs.major }}
|
||||
minor:
|
||||
description: "The minor version of the package."
|
||||
value: ${{ steps.parse.outputs.minor }}
|
||||
patch:
|
||||
description: "The patch version of the package."
|
||||
value: ${{ steps.parse.outputs.patch }}
|
||||
revision:
|
||||
description: "The patch revision version of the package. The suffix treated as a number seperated by a '.'"
|
||||
value: ${{ steps.parse.outputs.revision }}
|
||||
metadata:
|
||||
description: "The of the package."
|
||||
value: ${{ steps.parse.outputs.metadata }}
|
||||
suffix:
|
||||
description: "The suffix of the package."
|
||||
value: ${{ steps.parse.outputs.suffix }}
|
||||
isPrerelease:
|
||||
description: "Whether or not the package is a prerelease package."
|
||||
value: ${{ steps.parse.outputs.isPrerelease }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Parse version."
|
||||
id: parse
|
||||
run: bash ${{ github.action_path }}/parse_version.sh "${{ inputs.version }}"
|
||||
shell: bash
|
||||
30
utils/version-parse/parse_version.sh
Normal file
30
utils/version-parse/parse_version.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
VERSION="$1"
|
||||
|
||||
if [[ ! -f "$GITHUB_OUTPUT" ]]; then
|
||||
# Write to stdout if the output file doesn't exist.
|
||||
GITHUB_OUTPUT="/dev/fd/1"
|
||||
fi
|
||||
|
||||
IS_PRERELEASE=$(echo "$VERSION" | grep -c '-')
|
||||
if [[ "$IS_PRERELEASE" == 0 ]]; then
|
||||
IS_PRERELEASE=false
|
||||
else
|
||||
IS_PRERELEASE=true
|
||||
fi
|
||||
echo "isPrerelease=$IS_PRERELEASE" >> "$GITHUB_OUTPUT"
|
||||
|
||||
MAJOR=$(echo "$VERSION" | cut -d '.' -f 1 | cut -d '+' -f 1 | xargs printf %d 2> /dev/null)
|
||||
MINOR=$(echo "$VERSION" | cut -d '.' -f 2 | cut -d '+' -f 1 | xargs printf %d 2> /dev/null)
|
||||
PATCH=$(echo "$VERSION" | cut -d '.' -f 3 | cut -d '-' -f 1 | xargs | cut -d '+' -f 1 | xargs printf %d 2> /dev/null)
|
||||
REVISION=$(echo "$VERSION" | cut -d '.' -f 4 | cut -d '-' -f 1 | cut -d '+' -f 1 | xargs printf %d 2> /dev/null)
|
||||
SUFFIX=$(echo "$VERSION" | sed "s|^$MAJOR.$MINOR.$PATCH||" | sed "s|^.$REVISION||" | sed "s|^-||" | cut -d '+' -f 1 | xargs)
|
||||
METADATA=$(echo "$VERSION" | cut -d '+' -sf 2 | xargs) # Empty if no delimeter '+' present.
|
||||
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "major=$MAJOR" >> "$GITHUB_OUTPUT"
|
||||
echo "minor=$MINOR" >> "$GITHUB_OUTPUT"
|
||||
echo "patch=$PATCH" >> "$GITHUB_OUTPUT"
|
||||
echo "revision=$REVISION" >> "$GITHUB_OUTPUT"
|
||||
echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT"
|
||||
echo "metadata=$METADATA" >> "$GITHUB_OUTPUT"
|
||||
Reference in New Issue
Block a user