-
Notifications
You must be signed in to change notification settings - Fork 1
260 lines (223 loc) · 6.65 KB
/
Copy pathtest-igo.yml
File metadata and controls
260 lines (223 loc) · 6.65 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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: Manage IGO Package
on:
push:
branches:
- master
pull_request:
branches: [ master, develop, 'release/**' ]
workflow_dispatch:
inputs:
run_macos_tests:
description: 'Run macOS tests'
required: false
type: boolean
default: false
create_release:
description: 'Create release branch from develop'
required: false
type: boolean
default: false
promote_to_master:
description: 'Promote release to master'
required: false
type: boolean
default: false
jobs:
version-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # This fetches all history and tags
- name: Check VERSION is greater than latest tag
run: |
chmod +x .github/workflows/scripts/check_version.sh
source .github/workflows/scripts/check_version.sh
shell: bash
test-go-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24.2
- name: Install dependencies
run: |
go mod download
go mod tidy
go mod vendor
shell: bash
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test
run: |
set -euo pipefail
go test -v ./...
shell: bash
release-check:
if: startsWith(github.ref, 'refs/heads/release/') || inputs.create_release || inputs.promote_to_master
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Extract version from VERSION file
id: version
run: |
VERSION=$(cat VERSION | tr -d '\n')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Version extracted: $VERSION"
# Additional release validation steps
- name: Validate release requirements
run: |
# Add any additional validation for releases
# For example, verify changelog entries, documentation, etc.
echo "Validating release requirements for $VERSION"
# Add your validation logic here
exit 0
create-release-branch:
if: inputs.create_release == true
needs: [version-check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: develop
- name: Extract version from VERSION file
id: extract_version
run: |
VERSION=$(cat VERSION | tr -d '\n')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Version extracted: $VERSION"
- name: Create release branch
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "actions@github.com"
git checkout -b release/$VERSION
git push origin release/$VERSION
- name: Create PR from release to master
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: master
head: release/${{ env.VERSION }}
title: "Release ${{ env.VERSION }}"
body: |
## Release ${{ env.VERSION }}
This PR is automatically created to merge the release branch into master.
Please review and approve to proceed with the release.
Release notes:
- [Add release notes here]
promote-to-master:
if: inputs.promote_to_master == true && startsWith(github.ref, 'refs/heads/release/')
needs: [version-check, release-check, test-linux, test-macos]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Extract version
run: |
VERSION=$(cat VERSION | tr -d '\n')
RELEASE_BRANCH=${GITHUB_REF#refs/heads/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "RELEASE_BRANCH=$RELEASE_BRANCH" >> $GITHUB_ENV
- name: Merge to master
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "actions@github.com"
git checkout master
git merge --no-ff $RELEASE_BRANCH -m "Merge release $VERSION to master"
git tag -a $VERSION -m "Release $VERSION"
git push origin master
git push origin $VERSION
test-linux:
needs: version-check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [
ubuntu-22.04,
ubuntu-24.04,
ubuntu-24.04-arm,
ubuntu-22.04-arm
]
include:
- os: ubuntu-latest
platform: linux
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.24.2
- name: Install dependencies
run: |
go mod download
go mod tidy
go mod vendor
shell: bash
- name: Build binary
run: |
go build -o igo
chmod +x igo
export PATH=$PATH:$(pwd)
chmod +x ./testing/tester.sh
touch .profile
rm go.mod
rm go.sum
./testing/tester.sh
shell: bash
test-macos:
needs: version-check
if: (github.ref == 'refs/heads/master' ||
github.event_name == 'pull_request' ||
startsWith(github.ref, 'refs/heads/hotfix/') ||
startsWith(github.ref, 'refs/heads/release/') ) ||
inputs.run_macos_tests == true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [
macos-15,
macos-14,
macos-13
]
include:
- os: macos-latest
platform: darwin
- os: macos-13
platform: darwin-arm64
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.24.2
- name: Install dependencies
run: |
brew install bc
go mod download
go mod tidy
go mod vendor
shell: bash
- name: Build binary
run: |
go build -o igo
chmod +x igo
export PATH=$PATH:$(pwd)
chmod +x ./testing/tester.sh
rm go.mod
rm go.sum
touch ~/.profile
./testing/tester.sh --verbose true --debug true
shell: bash