-
Notifications
You must be signed in to change notification settings - Fork 22
71 lines (66 loc) · 2.83 KB
/
release-version.yaml
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# This workflow can be used to resolve the combination of the inputs candidate and candidate name
# to a release version. The release version is then used in the subsequent steps of the release workflow.
# The release version base is fetched from the VERSION file in the repository root.
name: Derive Release Version from VERSION file
on:
workflow_call:
inputs:
release_candidate:
type: boolean
description: "Release Candidate"
required: false
default: true
release_candidate_name:
type: string
description: "Release Candidate Name, adjust after every succinct release candidate (e.g. to rc.2, rc.3...)"
required: false
default: "rc.1"
outputs:
version:
description: "The release version to use, e.g. v0.18.0"
value: ${{ jobs.get-release-version.outputs.release-version }}
version_no_prefix:
description: "The release version to use without the 'v' prefix, e.g. v0.18.0 => 0.18.0"
value: ${{ jobs.get-release-version.outputs.release-version-no-prefix }}
version_no_suffix:
description: "The base version to use, without any suffix, e.g. v0.18.0-rc.1 => v0.18.0"
value: ${{ jobs.get-release-version.outputs.base-version }}
jobs:
get-release-version:
name: Get Release Version
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
base-version: ${{ steps.set-base-version.outputs.BASE_VERSION }}
release-version: ${{ steps.export-version.outputs.RELEASE_VERSION }}
release-version-no-prefix: ${{ steps.export-version.outputs.RELEASE_VERSION_NO_PREFIX }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: '${{ github.workspace }}/go.mod'
cache: false
- name: Generate Base Version
id: set-base-version
run: |
BASE_VERSION=v$(go run $GITHUB_WORKSPACE/api/version/generate print-version)
echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_ENV
echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_OUTPUT
- name: Set Version for Release Candidate
if: inputs.release_candidate == true
run: |
RELEASE_VERSION=v$(go run $GITHUB_WORKSPACE/api/version/generate --no-dev print-rc-version ${{ inputs.release_candidate_name }})
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: Set Version
if: inputs.release_candidate == false
run: |
RELEASE_VERSION=${{env.BASE_VERSION}}
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: Export Version
id: export-version
run: |
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION_NO_PREFIX=${RELEASE_VERSION#v}" >> $GITHUB_OUTPUT