-
Notifications
You must be signed in to change notification settings - Fork 583
161 lines (155 loc) · 4.97 KB
/
workflow.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: CI workflow
on:
push:
branches:
- 'release/v*'
tags:
- '*'
paths-ignore:
- '**.md'
- 'CODEOWNERS'
- 'LICENSE'
- 'docs/**'
pull_request:
branches:
- 'release/v*'
paths-ignore:
- '**.md'
- 'CODEOWNERS'
- 'LICENSE'
- 'docs/**'
jobs:
ci:
permissions:
contents: read
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
- name: Run CI
run: |
./scripts/ci
ls -lR build/bin
env:
CROSS: 1
TAG: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || '' }}
- name: Generate sha256 file for release
if: github.event_name == 'push' && github.ref_type == 'tag'
run: |
upload_folder="./build/bin"
for filename in $upload_folder/*; do
sum_file=$(sha256sum $filename)
sum=$(echo $sum_file | awk '{print $1}')
file_path=$(echo $sum_file | awk '{print $2}')
file=${file_path#"$upload_folder/"}
echo "$sum $file" >> ./build/bin/sha256sum.txt
done
- name: Upload rke bin artifacts
if: github.event_name == 'push' && github.ref_type == 'tag'
uses: actions/upload-artifact@v4
with:
name: rke-binaries-${{ github.run_number }}-${{ github.run_attempt }}
path: build/bin/*
if-no-files-found: error
retention-days: 1
integration-ci:
permissions:
contents: read
runs-on: runs-on,runner=4cpu-linux-x64,run-id=${{ github.run_id }}
timeout-minutes: 30
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run CI
run: |
./scripts/integration-ci
github-pre-release:
permissions:
contents: write
runs-on: ubuntu-latest
timeout-minutes: 10
needs: ci
if: github.event_name == 'push' && github.ref_type == 'tag' && (contains(github.ref_name, 'rc') || contains(github.ref_name, 'alpha'))
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download rke bin artifacts
uses: actions/download-artifact@v4
with:
name: rke-binaries-${{ github.run_number }}-${{ github.run_attempt }}
path: build/bin
- name: Create pre-release
run: |
gh release create ${{ github.ref_name }} -p --verify-tag --title "Pre-release ${{ github.ref_name }}" --notes-file build/bin/rke-k8sversions.txt build/bin/*
env:
GH_TOKEN: ${{ github.token }}
github-release:
permissions:
contents: write
runs-on: ubuntu-latest
timeout-minutes: 10
needs: ci
if: github.event_name == 'push' && github.ref_type == 'tag' && !(contains(github.ref_name, 'rc') || contains(github.ref_name, 'alpha'))
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download rke bin artifacts
uses: actions/download-artifact@v4
with:
name: rke-binaries-${{ github.run_number }}-${{ github.run_attempt }}
path: build/bin
- name: Create release
run: |
gh release create ${{ github.ref_name }} --verify-tag --title "Release ${{ github.ref_name }}" --notes-file build/bin/rke-k8sversions.txt build/bin/*
env:
GH_TOKEN: ${{ github.token }}
dispatch:
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
timeout-minutes: 10
needs: ci
if: github.event_name == 'push' && github.ref_type == 'tag'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Retrieve token from vault
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/github-token/credentials token | PAT_TOKEN ;
- name: Run dispatch
run: |
case ${{ github.ref_name }} in
"v1.4"*)
ACTION_TARGET_BRANCH="release/v2.7"
;;
"v1.5"*)
ACTION_TARGET_BRANCH="release/v2.8"
;;
"v1.6"*)
ACTION_TARGET_BRANCH="release/v2.9"
;;
*)
echo "Not a valid tag, not dispatching event"
exit 0
esac
echo "Running on $ACTION_TARGET_BRANCH"
gh workflow run "Go get" --repo rancher/rancher --ref $ACTION_TARGET_BRANCH -F goget_module=github.com/rancher/rke -F goget_version=${{ github.ref_name }} -F source_author=${{ github.actor }}
env:
GH_TOKEN: ${{ env.PAT_TOKEN }}