Identify Target Version #16
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: 'Identify Target Version' | |
on: | |
workflow_dispatch: | |
workflow_call: | |
inputs: | |
boinc_app_description: | |
description: 'The BOINC app "description" value from the BOINC server / database' | |
required: true | |
type: string | |
specified_version: | |
description: 'Optionally specify a version number to override automatic incrementing' | |
required: false | |
type: string | |
outputs: | |
new_version: | |
description: 'Next version number to be applied to build artifacts' | |
value: ${{ jobs.define_target_version.outputs.new_version }} | |
jobs: | |
define_target_version: | |
runs-on: ubuntu-latest | |
outputs: | |
new_version: ${{ steps.new_version_number.outputs.new_version }} | |
steps: | |
- name: "Fetch latest published version number" | |
shell: bash | |
run: | | |
curl -O https://rnma.xyz/boinc/apps.php | |
- name: "Define new version number" | |
shell: bash | |
id: new_version_number | |
env: | |
BOINC_APP_DESCRIPTION: ${{ inputs.boinc_app_description }} | |
run: | | |
echo "BOINC_APP_DESCRIPTION: $BOINC_APP_DESCRIPTION" | |
echo "SPECIFIED_VERSION: $SPECIFIED_VERSION" | |
if [[ -n "$SPECIFIED_VERSION" ]]; then | |
NEW_VERSION="$SPECIFIED_VERSION" | |
echo "Using specified version: $NEW_VERSION" | |
else | |
VERSION=$(sed -n "/<th class=\"bg-primary\" colspan=4>$(printf '%s\n' "$BOINC_APP_DESCRIPTION" | sed 's/[\^$.|?*+{}]/\\&/g')<\/th>/,/<td>\([0-9].[0-9]\)/p" apps.php | sed -n 's/.*<td>\([0-9][0-9]*\.[0-9]*\)<\/td>.*/\1/ p') | |
if [ -z "$VERSION" ]; then | |
VERSION="1.0" | |
fi | |
echo "Last published version of $BOINC_APP_DESCRIPTION is $VERSION" | |
MAJOR_VERSION=$(echo $VERSION | cut -d '.' -f1) | |
MINOR_VERSION=$(echo $VERSION | cut -d '.' -f2) | |
if [ $MINOR_VERSION -eq 99 ]; then | |
NEW_MAJOR_VERSION=$((10#$MAJOR_VERSION + 1)) | |
NEW_MINOR_VERSION="00" | |
else | |
NEW_MAJOR_VERSION=$MAJOR_VERSION | |
NEW_MINOR_VERSION=$((10#$MINOR_VERSION + 1)) | |
fi | |
NEW_VERSION="$NEW_MAJOR_VERSION.$(printf "%02d" $NEW_MINOR_VERSION)" | |
echo "New version will be $NEW_VERSION" | |
fi | |
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
echo $NEW_VERSION > version | |
- name: "Upload version" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: version | |
path: version | |
overwrite: true | |
if-no-files-found: error |