-
Notifications
You must be signed in to change notification settings - Fork 2
62 lines (61 loc) · 2.68 KB
/
go-versions.yml
File metadata and controls
62 lines (61 loc) · 2.68 KB
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
# The following chunk of yml boils down to pulling two Go version numbers out of a file and
# making them available to the other workflows in a convenient fashion.
#
# It's a reusable workflow instead of an action so that its output can be used in a matrix strategy
# of another job.
#
# The idea is to define the most recent, and penultimate, Go versions that should be used to test Relay.
# Ideally we'd define these in a single place - otherwise we'd need to update many different places in
# each workflow. This single place is .github/variables/go-versions.env.
#
# This reusable workflow grabs them out of the file, then sets them as outputs. As a convenience, it
# also wraps each version in an array, so it can be directly used in a matrix strategy. Single-item matrices
# are nice because you can tell instantly in the Github UI which version is being tested without needing
# to inspect logs.
#
# To use a matrix output, e.g. latest version, do:
# strategy:
# matrix: ${{ fromJSON(this-job.outputs.latest-matrix) }}
#
name: Go Versions
on:
workflow_call:
outputs:
latest:
description: 'The most recent Go version to test'
value: ${{ jobs.go-versions.outputs.latest }}
penultimate:
description: 'The second most recent Go version to test'
value: ${{ jobs.go-versions.outputs.penultimate }}
min:
description: 'The minimum Go version to test'
value: ${{ jobs.go-versions.outputs.min }}
matrix:
description: 'All Go versions to test as a matrix'
value: ${{ jobs.go-versions.outputs.all }}
jobs:
go-versions:
runs-on: ubuntu-slim
outputs:
latest: ${{ steps.set-env.outputs.latest }}
penultimate: ${{ steps.set-env.outputs.penultimate }}
all: ${{ steps.set-matrix.outputs.all }}
steps:
- uses: actions/checkout@v6
with:
persist-credentials: 'false'
- name: Set Go Versions
id: set-env
run: cat ./.github/variables/go-versions.env > $GITHUB_OUTPUT
- name: Set Go Version Matrices
id: set-matrix
run: |
if [ "${STEPS_SET_ENV_OUTPUTS_PENULTIMATE}" == "${STEPS_SET_ENV_OUTPUTS_MIN}" ]; then
echo "all=[\"${STEPS_SET_ENV_OUTPUTS_LATEST}\",\"${STEPS_SET_ENV_OUTPUTS_PENULTIMATE}\"]" >> $GITHUB_OUTPUT
else
echo "all=[\"${STEPS_SET_ENV_OUTPUTS_LATEST}\",\"${STEPS_SET_ENV_OUTPUTS_PENULTIMATE}\",\"${STEPS_SET_ENV_OUTPUTS_MIN}\"]" >> $GITHUB_OUTPUT
fi
env:
STEPS_SET_ENV_OUTPUTS_PENULTIMATE: ${{ steps.set-env.outputs.penultimate }}
STEPS_SET_ENV_OUTPUTS_MIN: ${{ steps.set-env.outputs.min }}
STEPS_SET_ENV_OUTPUTS_LATEST: ${{ steps.set-env.outputs.latest }}