on: workflow_call: inputs: version_file: required: false type: string outputs: stability: description: "branch stability (stable, testing, unstable, canary)" value: ${{ jobs.get-version.outputs.stability }} version: description: "version" value: ${{ jobs.get-version.outputs.version }} release: description: "release number" value: ${{ jobs.get-version.outputs.release }} jobs: get-version: runs-on: ubuntu-22.04 outputs: stability: ${{ steps.get_environment.outputs.stability }} version: ${{ steps.get_environment.outputs.version }} release: ${{ steps.get_environment.outputs.release }} steps: - name: Checkout sources uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - id: get_environment run: | if [[ -z "$GITHUB_HEAD_REF" ]]; then BRANCHNAME="$GITHUB_REF_NAME" else BRANCHNAME="$GITHUB_HEAD_REF" fi case "$BRANCHNAME" in develop) STABILITY="unstable" ;; release* | hotfix*) STABILITY="testing" ;; master) STABILITY="stable" ;; *) STABILITY="canary" ;; esac echo "stability=$STABILITY" >> $GITHUB_OUTPUT if [[ "${{ inputs.version_file }}" == "" ]]; then VERSION=$(date '+%Y%m%d') elif [[ "${{ inputs.version_file }}" == */*.yaml ]]; then VERSION=$(grep 'version: ' ${{ inputs.version_file }} | cut -d' ' -f2 | tr -d '"') else VERSION=$(grep VERSION ${{ inputs.version_file }} | cut -d "'" -f 2) fi echo "version=$(echo $VERSION)" >> $GITHUB_OUTPUT RELEASE=$(date '+%H%M%S') echo "release=$(echo $RELEASE)" >> $GITHUB_OUTPUT shell: bash