-
-
Notifications
You must be signed in to change notification settings - Fork 36
240 lines (206 loc) · 7.72 KB
/
unix.yml
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
name: Linux Build
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOCKER_REGISTRY: ghcr.io/maxrev-dev
DOTNET_VERSION: '8.0.x'
IS_PRE_RELEASE: ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' || contains(github.event.head_commit.message, '[prerelease]') }}
permissions:
packages: write
contents: read
jobs:
BuildNugetPackages-Linux:
strategy:
matrix:
include:
- os: linux/amd64
arch: x64
actions-runner: self-hosted-macos-x64
- os: linux/arm64
arch: arm64
actions-runner: self-hosted-macos-arm64
runs-on: ${{ matrix.actions-runner }}
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
defaults:
run:
working-directory: unix
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache restore
uses: maxnowack/local-cache@main
with:
path: |
${{ github.workspace }}/.dotnet
${{ github.workspace }}/ci/cache/
key: ${{ runner.os }}-buildx-${{ matrix.os }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: false
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKER_REGISTRY }}/gdal.netcore.builder.${{ matrix.arch }}
tags: |
type=sha
type=ref,event=branch
type=ref,event=pr
latest
- name: Build and push on GH runner
uses: docker/build-push-action@v5
if: ${{ !contains(matrix.actions-runner, 'self-hosted') }}
with:
push: true
context: .
file: ci/Dockerfile.unix
platforms: ${{ matrix.os }}
build-args: |
BUILD_NUMBER_TAIL=${{ github.run_number }}
PRERELEASE=${{ env.IS_PRE_RELEASE }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push on local runner
uses: docker/build-push-action@v5
if: ${{ contains(matrix.actions-runner, 'self-hosted') }}
with:
load: true
push: false
tags: ${{ env.DOCKER_REGISTRY }}/gdal.netcore.builder.${{ matrix.arch }}:latest
context: .
file: ci/Dockerfile.unix
platforms: ${{ matrix.os }}
build-args: |
BUILD_NUMBER_TAIL=${{ github.run_number }}
PRERELEASE=${{ env.IS_PRE_RELEASE }}
DOTNET_INSTALL_DIR=/build/ci/cache/.dotnet
VCPKG_DEFAULT_BINARY_CACHE=/build/ci/cache/vcpkg-archives/
- name: Extract artifacts
run: |
chmod +x '${{ github.workspace }}/ci/extract-container-artifacts.sh'
'${{ github.workspace }}/ci/extract-container-artifacts.sh' ${{ matrix.arch }}
- name: Store metadata as artifact
uses: actions/upload-artifact@v4
with:
name: metadata-unix-${{ matrix.arch }}
path: |
shared/bundle/targets/
package-build/*.csproj
overwrite: true
- name: Store packages as artifact
uses: actions/upload-artifact@v4
with:
name: packages-unix-${{ matrix.arch }}
path: nuget/*.nupkg
overwrite: true
TestPackages-Linux:
strategy:
matrix:
include:
- os: linux/amd64
arch: x64
actions-runner: ubuntu-latest
- os: linux/amd64
arch: x64
actions-runner: self-hosted-macos-x64
- os: linux/arm64
arch: arm64
actions-runner: self-hosted-macos-arm64
needs: BuildNugetPackages-Linux
runs-on: ${{ matrix.actions-runner }}
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
defaults:
run:
working-directory: unix
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: packages-unix-${{ matrix.arch }}
path: nuget/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build docker image
run: |
docker buildx build --load --platform=${{ matrix.os }} \
--progress=plain -t maxrev-dev/gdal.netcore.tester.${{ matrix.arch }}:latest \
--build-arg BUILD_NUMBER_TAIL=${{ github.run_number }} \
--build-arg BUILD_ARCH=${{ matrix.arch }} \
--build-arg PRERELEASE=${{ env.IS_PRE_RELEASE }} \
-f '${{ github.workspace }}/ci/Dockerfile.unix.test' \
${{ github.workspace }}
- name: Test packages
run: |
docker run \
--env BUILD_NUMBER_TAIL=${{ github.run_number }} \
--env BUILD_ARCH=${{ matrix.arch }} \
--env PRERELEASE=${{ env.IS_PRE_RELEASE }} \
-t maxrev-dev/gdal.netcore.tester.${{ matrix.arch }}:latest
PushPackages-Linux:
needs: TestPackages-Linux
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
defaults:
run:
working-directory: unix
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Download artifact - packages
uses: actions/download-artifact@v4
with:
pattern: packages-unix*
merge-multiple: true
path: nuget/
- name: Download artifact - metadata
uses: actions/download-artifact@v4
with:
pattern: metadata-unix*
merge-multiple: true
- run: ls -la ../nuget/
- name: NuGet - Update credentials
run: |
dotnet nuget update source github --store-password-in-clear-text -u ${{ secrets.API_USER_GITHUB }} -p ${{ secrets.API_KEY_GITHUB }}
dotnet nuget update source nuget.org --store-password-in-clear-text -u ${{ secrets.API_USER_NUGET }} -p ${{ secrets.API_KEY_NUGET }}
dotnet nuget remove source local || true
dotnet nuget remove source local.ci || true
dotnet nuget add source "${{ github.workspace}}/nuget/" --name local.ci --configfile ${{ github.workspace}}/nuget.config
- name: Build bundle
run: |
make -f publish-makefile pack-bundle-only CAT_NAME=unix PRERELEASE=${{ env.IS_PRE_RELEASE }} BUILD_NUMBER_TAIL=${{ github.run_number }}
- name: Store packages as artifact
uses: actions/upload-artifact@v4
with:
name: packages-unix-final
path: nuget/*.nupkg
overwrite: true
- name: Push packages
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
make -f push-packages-makefile PRERELEASE=${{ env.IS_PRE_RELEASE }} INCLUDE_CORE=1 \
BUILD_NUMBER_TAIL=${{ github.run_number }} API_KEY_GITHUB=${{ secrets.API_KEY_GITHUB }} API_KEY_NUGET=${{ secrets.API_KEY_NUGET }}