-
Notifications
You must be signed in to change notification settings - Fork 263
112 lines (99 loc) · 3.96 KB
/
release-against-rancher.yml
File metadata and controls
112 lines (99 loc) · 3.96 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Release Fleet against rancher/rancher
on:
workflow_dispatch:
inputs:
fleet_branch:
description: "Fleet branch to release from (main = next unreleased minor version)"
required: true
default: "main"
type: choice
options:
- main
- release/v0.15
- release/v0.14
- release/v0.13
- release/v0.12
- release/v0.11
env:
GOARCH: amd64
CGO_ENABLED: 0
jobs:
create-rancher-pr:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
path: fleet
persist-credentials: false
- name: Compute versions
id: versions
env:
GH_TOKEN: ${{ github.token }}
FLEET_BRANCH: ${{ inputs.fleet_branch }}
run: fleet/.github/scripts/compute-rancher-versions.sh
- name: Checkout rancher/rancher
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
repository: rancher/rancher
ref: ${{ steps.versions.outputs.rancher_ref }}
path: rancher
persist-credentials: false
- name: Pre-flight checks
env:
NEW_FLEET: ${{ steps.versions.outputs.new_fleet }}
run: |
set -euo pipefail
# Skip all checks for pre-releases.
if [[ "${NEW_FLEET}" =~ - ]]; then
echo "Pre-release version ${NEW_FLEET}; skipping pre-flight checks"
exit 0
fi
# For a new final minor version, pkg/apis must be tagged in the fleet repo.
if [[ "${NEW_FLEET}" =~ \.0$ ]]; then
if ! git -C fleet tag -l "pkg/apis/v${NEW_FLEET}" | grep -q .; then
{
printf 'ERROR: pkg/apis/v%s tag not found in the fleet repo!\n' "${NEW_FLEET}"
printf 'For a new final minor version, pkg/apis must be bumped first.\n'
printf 'Please create the tag: git tag pkg/apis/v%s\n' "${NEW_FLEET}"
} >&2
exit 1
fi
fi
# For any final version, rancher/rancher must not reference a pre-release Fleet API
# so there must be a Fleet `pkg/apis/v<VERSION>` tag that the api is bumped in this action
if ! git -C fleet tag -l "pkg/apis/v${NEW_FLEET}" | grep -q .; then
# Tag doesn't exist; check if rancher/rancher has a pre-release version that does not need to be bumped.
RANCHER_FLEET_API_VERSION=$(grep 'github.com/rancher/fleet/pkg/apis' rancher/pkg/apis/go.mod | awk '{print $NF}')
if [[ "${RANCHER_FLEET_API_VERSION:-}" =~ - ]]; then
{
printf 'ERROR: rancher/rancher uses pre-release Fleet API %s, but pkg/apis/v%s tag not found\n' "${RANCHER_FLEET_API_VERSION}" "${NEW_FLEET}"
printf 'Please create the tag: git tag pkg/apis/v%s\n' "${NEW_FLEET}"
} >&2
exit 1
fi
fi
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: ./rancher/go.mod
cache-dependency-path: ./rancher/go.sum
- name: Install controller-gen
run: go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.17.2
- name: Run release script
run: |
./fleet/.github/scripts/release-against-rancher.sh \
"${{ steps.versions.outputs.new_fleet }}" \
"${{ steps.versions.outputs.new_chart }}"
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.PUSH_TO_FORKS_SUBMIT_PRS }}
working-directory: ./rancher/
run: |
../fleet/.github/scripts/create-pr.sh \
"${{ steps.versions.outputs.rancher_ref }}" \
"${{ steps.versions.outputs.new_fleet }}" \
"${{ steps.versions.outputs.new_chart }}" \
rancher