-
Notifications
You must be signed in to change notification settings - Fork 55
41 lines (39 loc) · 1.26 KB
/
version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Calculate release version (reusable workflow)
on:
workflow_call:
inputs:
preferred:
description: "preferred release version"
required: false
type: string
suffix:
description: "version suffix (defaults to branch name)"
required: false
type: string
outputs:
release_version:
description: "The computed release version"
value: ${{ jobs.compute.outputs.result }}
jobs:
compute:
name: Compute
runs-on: ubuntu-latest
outputs:
result: ${{ steps.release_version.outputs.release_version }}
steps:
- name: Calculate release version
id: release_version
run: |
if [ "${{ inputs.preferred }}" == "" ]; then
echo "Using computed value"
SUFFIX=${{ inputs.suffix }}
BRANCH=$(echo ${{ github.ref }} | sed -e 's/refs\/heads\///' -e 's/\//-/g')
if [ "${SUFFIX}" == "" ]; then
SUFFIX="-${BRANCH}"
fi
echo "SUFFIX=${SUFFIX}" >> $GITHUB_ENV
echo "release_version=1.0.$(date +'%g%m%d%H%M')${SUFFIX}" >> $GITHUB_OUTPUT
else
echo "Using provided input"
echo "release_version=${{ inputs.preferred }}" >> $GITHUB_OUTPUT
fi