-
Notifications
You must be signed in to change notification settings - Fork 72
229 lines (201 loc) · 6.62 KB
/
publish-packages.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
name: publish-packages
run-name: Publish packages
on:
push:
paths:
- .github/workflows/publish-packages.yml
- .github/packages/**
pull_request:
paths:
- .github/workflows/publish-packages.yml
- .github/packages/**
schedule:
# Monday at 5am EST
- cron: "0 10 * * 1"
concurrency:
group: "packages"
cancel-in-progress: true
jobs:
build-linux:
name: Publish package
env:
REGISTRY: ghcr.io
CONTAINERFILE: .github/packages/${{ matrix.target }}/Dockerfile
strategy:
matrix:
target: [ "build-linux", "gen-pages", "check-issues" ]
fail-fast: false
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Get image name
env:
REPO_NAME: ${{ github.repository }}
IMAGE_SUFFIX: ${{ matrix.target }}
run: |
result=$(echo "$REPO_NAME/$IMAGE_SUFFIX" | tr '[:upper:]' '[:lower:]')
echo "IMAGE=$result" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build package
id: build
uses: docker/build-push-action@v4
with:
context: .
file: ${{ env.CONTAINERFILE }}
target: ${{ matrix.target }}
load: true
tags: ${{ env.IMAGE }}:test
- name: Try building Melee (GENERATE_MAP=1)
if: startsWith(matrix.target, 'build-')
run: |
docker run --rm \
--volume "$PWD:/input:ro" \
--volume /tmp/output/generate_map:/output \
--env MAKE_FLAGS="GENERATE_MAP=1" \
"$IMAGE:test"
- name: Try building Melee (NON_MATCHING=1)
if: startsWith(matrix.target, 'build-')
run: |
docker run --rm \
--volume "$PWD":/input:ro \
--volume /tmp/output/non_matching:/output \
--env MAKE_FLAGS="NON_MATCHING=1" \
"$IMAGE:test"
- name: Try checking for code issues
if: matrix.target == 'check-issues'
run: |
docker run --rm \
--volume "$PWD:/input:ro" \
"$IMAGE:test"
- name: Try generating pages
if: matrix.target == 'gen-pages'
run: |
docker run --rm \
--volume "$PWD:/input:ro" \
--volume /tmp/output:/output \
"$IMAGE:test"
- name: Extract tags and labels
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE }}
tags: |
type=raw,priority=1000,value=latest,enable={{is_default_branch}}
type=schedule,pattern={{date 'YYYYMMDD'}}
type=ref,event=branch
type=ref,event=pr
type=edge
type=sha
- name: Log into container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push package
uses: docker/build-push-action@v4
if: github.event_name != 'pull_request'
with:
context: .
file: ${{ env.CONTAINERFILE }}
target: ${{ matrix.target }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-windows:
name: Publish package
env:
REGISTRY: ghcr.io
CONTAINERFILE: .github/packages/${{ matrix.target }}/Dockerfile
strategy:
matrix:
target: [ "build-windows" ]
fail-fast: false
runs-on: windows-latest
permissions:
contents: read
packages: write
steps:
- name: Get image name
env:
REPO_NAME: ${{ github.repository }}
IMAGE_SUFFIX: ${{ matrix.target }}
shell: bash
run: |
result=$(echo "$REPO_NAME/$IMAGE_SUFFIX" | tr '[:upper:]' '[:lower:]')
echo "IMAGE=$result" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v3
# build-push-action and buildx are not supported on Windows hosts
- name: Build package
env:
IMAGE_TARGET: ${{ matrix.target }}
shell: bash
run: |
docker build \
--target "$IMAGE_TARGET" \
--tag "$IMAGE:test" \
--file "$CONTAINERFILE" \
.
- name: Try building Melee (GENERATE_MAP=1)
if: startsWith(matrix.target, 'build-')
run: |
$output = New-Item `
-Path "$env:TEMP/Output/GenerateMap" `
-ItemType Directory `
-Force
# the container's user needs to be able to write to the runner's dir
icacls $output /T /grant 'Everyone:(OI)(CI)(F)'
docker run --rm `
--volume "${PWD}:C:/Input:ro" `
--volume "${output}:C:/Output" `
--env MAKE_FLAGS="GENERATE_MAP=1" `
"${env:IMAGE}:test"
- name: Try building Melee (NON_MATCHING=1)
if: startsWith(matrix.target, 'build-')
run: |
$output = New-Item `
-Path "$env:TEMP/Output/NonMatching" `
-ItemType Directory `
-Force
# the container's user needs to be able to write to the runner's dir
icacls $output /T /grant 'Everyone:(OI)(CI)(F)'
docker run --rm `
--volume "${PWD}:C:/Input:ro" `
--volume "${output}:C:/Output" `
--env MAKE_FLAGS="NON_MATCHING=1" `
${env:IMAGE}:test
- name: Extract tags and labels
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE }}
tags: |
type=raw,priority=1000,value=latest,enable={{is_default_branch}}
type=schedule,pattern={{date 'YYYYMMDD'}}
type=ref,event=branch
type=ref,event=pr
type=edge
type=sha
- name: Log into container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push package
if: github.event_name != 'pull_request'
shell: bash
run: |
echo $(
echo "$DOCKER_METADATA_OUTPUT_TAGS" | xargs -I{} echo --tag \'{}\'
echo "$DOCKER_METADATA_OUTPUT_LABELS" | xargs -I{} echo --label \'{}\'
) | xargs docker build -f "$CONTAINERFILE" .
docker push --all-tags "$REGISTRY/$IMAGE"