centreon-plugins/.github/workflows/get-environment.yml

65 lines
1.7 KiB
YAML

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@v3
- 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')
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