Skip to content

Identify Target Version #11

Identify Target Version

Identify Target Version #11

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
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: |
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"
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