-
Notifications
You must be signed in to change notification settings - Fork 24
198 lines (180 loc) · 7.99 KB
/
build.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
name: Build
on:
push:
branches:
- master
schedule:
- cron: '0 3 * * *'
jobs:
get-upstream-versions:
# This is a bit yucky - it feels like it should be possible to do this with a matrix.
runs-on: ${{ matrix.arch.os }}
outputs:
stable_version: ${{steps.version-stable.outputs.version}}
stable_semver_major: ${{steps.version-stable.outputs.semver_major}}
stable_semver_minor: ${{steps.version-stable.outputs.semver_minor}}
stable_semver_patch: ${{steps.version-stable.outputs.semver_patch}}
testing_version: ${{steps.version-testing.outputs.version}}
testing_semver_major: ${{steps.version-testing.outputs.semver_major}}
testing_semver_minor: ${{steps.version-testing.outputs.semver_minor}}
testing_semver_patch: ${{steps.version-testing.outputs.semver_patch}}
steps:
- name: Discover upstream stable version
uses: ropenttd/cdn_version_scraper@master
with:
channel: stable
id: version-stable
- name: Discover upstream testing version
uses: ropenttd/cdn_version_scraper@master
with:
channel: testing
id: version-stable
cri:
needs:
- get-upstream-versions
strategy:
matrix:
train:
- stable
- testing
arch:
- os: ubuntu-24.04
name: linux/amd64
label: linux-amd64
- os: ubuntu-24.04-arm
name: linux/arm64
label: linux-arm64
runs-on: ${{ matrix.arch.os }}
steps:
- name: Git checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Set target version environment variables
# Again, this is ewwy.
if: matrix.train == 'stable'
run: |
echo version=${{needs.get-upstream-versions.outputs.stable_version}} >> $GITHUB_ENV
echo semver_major=${{needs.get-upstream-versions.outputs.stable_semver_major}} >> $GITHUB_ENV
echo semver_minor=${{needs.get-upstream-versions.outputs.stable_semver_minor}} >> $GITHUB_ENV
echo semver_patch=${{needs.get-upstream-versions.outputs.stable_semver_patch}} >> $GITHUB_ENV
- name: Set target version environment variables (testing)
# Again, this is ewwy.
if: matrix.train == 'testing'
run: |
echo version=${{needs.get-upstream-versions.outputs.testing_version}} >> $GITHUB_ENV
echo semver_major=${{needs.get-upstream-versions.outputs.testing_semver_major}} >> $GITHUB_ENV
echo semver_minor=${{needs.get-upstream-versions.outputs.testing_semver_minor}} >> $GITHUB_ENV
echo semver_patch=${{needs.get-upstream-versions.outputs.testing_semver_patch}} >> $GITHUB_ENV
- name: Generate CRI metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository_owner }}/openttd
docker.io/redditopenttd/openttd
labels: |
org.opencontainers.image.title=OpenTTD
org.opencontainers.image.description=Lightweight build of OpenTTD, designed for server use, with some extra helping treats.
org.opencontainers.image.url=https://github.com/ropenttd/docker_openttd
org.opencontainers.image.source=https://github.com/openttd/openttd
org.opencontainers.image.vendor=Reddit OpenTTD
org.opencontainers.image.version=${{ env.version }}
tags: |
${{ env.version }}-${{ matrix.arch.label }}
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCI
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
build-args: |
OPENTTD_VERSION=${{ env.version }}
platforms: ${{ matrix.arch.name }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
provenance: false
release-bundle-manifest:
needs:
- get-upstream-versions
- cri
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
train:
- stable
- testing
container_store:
- docker
- ghcr
steps:
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set target version environment variables
# Again, this is ewwy.
if: matrix.train == 'stable'
run: |
echo version=${{needs.get-upstream-versions.outputs.stable_version}} >> $GITHUB_ENV
echo semver_major=${{needs.get-upstream-versions.outputs.stable_semver_major}} >> $GITHUB_ENV
echo semver_minor=${{needs.get-upstream-versions.outputs.stable_semver_minor}} >> $GITHUB_ENV
echo semver_patch=${{needs.get-upstream-versions.outputs.stable_semver_patch}} >> $GITHUB_ENV
- name: Set target version environment variables (testing)
# Again, this is ewwy.
if: matrix.train == 'testing'
run: |
echo version=${{needs.get-upstream-versions.outputs.testing_version}} >> $GITHUB_ENV
echo semver_major=${{needs.get-upstream-versions.outputs.testing_semver_major}} >> $GITHUB_ENV
echo semver_minor=${{needs.get-upstream-versions.outputs.testing_semver_minor}} >> $GITHUB_ENV
echo semver_patch=${{needs.get-upstream-versions.outputs.testing_semver_patch}} >> $GITHUB_ENV
- name: Create and push manifest (GHCR, stable)
uses: Noelware/docker-manifest-action@0.4.2
if: matrix.train == 'stable' && matrix.container_store == 'ghcr'
with:
inputs: ${{env.GHCR_REPO}}:latest,${{env.GHCR_REPO}}:stable,${{env.GHCR_REPO}}:${{env.version}},${{env.GHCR_REPO}}:${{env.semver_major}}
images: ${{env.GHCR_REPO}}:${{env.version}}-linux-amd64,${{env.GHCR_REPO}}:${{env.version}}-linux-arm64
push: true
- name: Create and push manifest (GHCR, testing)
uses: Noelware/docker-manifest-action@0.4.2
if: matrix.train == 'testing' && matrix.container_store == 'ghcr'
with:
inputs: ${{env.GHCR_REPO}}:testing,${{env.GHCR_REPO}}:${{env.version}}
images: ${{env.GHCR_REPO}}:${{env.version}}-linux-amd64,${{env.GHCR_REPO}}:${{env.version}}-linux-arm64
push: true
- name: Create and push manifest (Docker, stable)
uses: Noelware/docker-manifest-action@0.4.2
if: matrix.train == 'stable' && matrix.container_store == 'docker'
with:
inputs: ${{env.DOCKER_REPO}}:latest,${{env.DOCKER_REPO}}:stable,${{env.DOCKER_REPO}}:${{env.version}},${{env.DOCKER_REPO}}:${{ env.semver_major }}
images: ${{env.DOCKER_REPO}}:${{env.version}}-linux-amd64,${{env.DOCKER_REPO}}:${{env.version}}-linux-arm64
push: true
- name: Create and push manifest (Docker, testing)
uses: Noelware/docker-manifest-action@0.4.2
if: matrix.train == 'testing' && matrix.container_store == 'docker'
with:
inputs: ${{env.DOCKER_REPO}}:testing,${{env.DOCKER_REPO}}:${{env.version}}
images: ${{env.DOCKER_REPO}}:${{env.version}}-linux-amd64,${{env.DOCKER_REPO}}:${{env.version}}-linux-arm64
push: true