Skip to content

Commit 9e7143d

Browse files
committed
Linux ARM64 build
1 parent 01f40ae commit 9e7143d

File tree

4 files changed

+89
-38
lines changed

4 files changed

+89
-38
lines changed

.github/workflows/build.yaml

+74-31
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os:
16-
- ubuntu-22.04
17-
- macos-12 # Intel
18-
- macos-13-xlarge # Apple silicon
16+
- ubuntu-24.04
17+
- macos-13 # Intel
18+
- macos-14 # Apple silicon
1919
- windows-2022
2020
ghc-version:
2121
- "8.8"
@@ -24,19 +24,19 @@ jobs:
2424
- "9.2"
2525
- "9.4"
2626
exclude:
27-
- os: macos-12
27+
- os: macos-13
2828
ghc-version: "8.10"
29-
- os: macos-12
29+
- os: macos-13
3030
ghc-version: "9.0"
31-
- os: macos-12
31+
- os: macos-13
3232
ghc-version: "9.2"
33-
- os: macos-13-xlarge
33+
- os: macos-14
3434
ghc-version: "8.8"
35-
- os: macos-13-xlarge
35+
- os: macos-14
3636
ghc-version: "8.10"
37-
- os: macos-13-xlarge
37+
- os: macos-14
3838
ghc-version: "9.0"
39-
- os: macos-13-xlarge
39+
- os: macos-14
4040
ghc-version: "9.2"
4141
- os: windows-2022
4242
ghc-version: "8.10"
@@ -70,6 +70,10 @@ jobs:
7070
%APPDATA%\cabal\store
7171
%APPDATA%\stack
7272
key: stack-${{ matrix.os }}-ghc-${{ matrix.version }}
73+
- name: Install dependencies (Linux)
74+
if: "startsWith(matrix.os, 'ubuntu-')"
75+
run: |
76+
sudo apt install libbz2-dev
7377
- name: Install Haskell Stack (if not installed)
7478
shell: bash
7579
run: |
@@ -178,9 +182,9 @@ jobs:
178182
fail-fast: false
179183
matrix:
180184
os:
181-
- ubuntu-22.04
182-
- macos-12 # Intel
183-
- macos-13-xlarge # Apple silicon
185+
- ubuntu-24.04
186+
- macos-13 # Intel
187+
- macos-14 # Apple silicon
184188
- windows-2022
185189
steps:
186190
- uses: actions/checkout@v4
@@ -266,12 +270,21 @@ jobs:
266270
267271
image:
268272
name: Docker image
269-
runs-on: ubuntu-22.04
273+
strategy:
274+
fail-fast: false
275+
matrix:
276+
os:
277+
- ubuntu-24.04
278+
- ubuntu-24.04-arm
279+
runs-on: ${{ matrix.os }}
270280
env:
271281
DOCKERHUB_IMAGE_NAME: seonbi
272282
outputs:
273283
image-ghcr: ghcr.io/${{ github.repository }}/bin@${{ steps.push-image.outputs.digest }}
274284
image-dockerhub: docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}@${{ steps.push-image.outputs.digest }}
285+
tag: ${{ steps.values.outputs.tag }}
286+
labels: ${{ steps.values.outputs.labels }}
287+
arch: ${{ steps.values.outputs.arch }}
275288
steps:
276289
- uses: actions/checkout@v4
277290
with:
@@ -303,6 +316,11 @@ jobs:
303316
else
304317
echo labels= >> "$GITHUB_OUTPUT"
305318
fi
319+
if [[ "$RUNNER_ARCH" = "ARM64" ]]; then
320+
echo arch=arm64 >> "$GITHUB_OUTPUT"
321+
else
322+
echo arch=amd64 >> "$GITHUB_OUTPUT"
323+
fi
306324
- id: push-image
307325
uses: docker/build-push-action@v6
308326
with:
@@ -313,10 +331,23 @@ jobs:
313331
org.opencontainers.image.url=${{ github.event.repository.html_url }}
314332
${{ steps.values.outputs.labels }}
315333
tags: |
316-
ghcr.io/${{ github.repository }}/bin:${{ steps.values.outputs.tag }}
317-
${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ steps.values.outputs.tag }}
334+
ghcr.io/${{ github.repository }}/bin:${{ steps.values.outputs.tag }}-${{ steps.values.outputs.arch }}
335+
${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ steps.values.outputs.tag }}-${{ steps.values.outputs.arch }}
318336
provenance: false # https://community.fly.io/t/deploying-to-fly-via-github-action-failing/10171/33
319337

338+
image-manifest:
339+
name: Create and push manifest images
340+
if: github.event_name != 'pull_request'
341+
needs:
342+
- image
343+
runs-on: ubuntu-24.04
344+
steps:
345+
- uses: Noelware/[email protected]
346+
with:
347+
inputs: ${{ needs.image.outputs.tag }}
348+
images: ${{ needs.image.outputs.tag }}-amd64,${{ needs.image.outputs.tag }}-arm64
349+
push: true
350+
320351
fly:
321352
name: Deploy seonbi-api to Fly.io
322353
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
@@ -325,7 +356,7 @@ jobs:
325356
env:
326357
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
327358
IMAGE: ${{ needs.image.outputs.image-ghcr }}
328-
runs-on: ubuntu-22.04
359+
runs-on: ubuntu-24.04
329360
steps:
330361
- uses: actions/checkout@v4
331362
- uses: superfly/flyctl-actions/setup-flyctl@master
@@ -345,16 +376,16 @@ jobs:
345376
needs:
346377
- build
347378
- image
348-
runs-on: ubuntu-22.04
379+
runs-on: ubuntu-24.04
349380
steps:
350381
- uses: actions/checkout@v4
351382
- uses: actions/download-artifact@v4
352383
with:
353-
name: binaries-macos-13-xlarge-ghc-9.4
384+
name: binaries-macos-14-ghc-9.4
354385
path: /tmp/binaries-macos-arm64
355386
- uses: actions/download-artifact@v4
356387
with:
357-
name: binaries-macos-12-ghc-9.4
388+
name: binaries-macos-13-ghc-9.4
358389
path: /tmp/binaries-macos-x86_64
359390
- uses: actions/download-artifact@v4
360391
with:
@@ -363,18 +394,30 @@ jobs:
363394
- run: |
364395
set -e
365396
mkdir -p /tmp/dists
366-
# Linux
367-
docker pull "$IMAGE"
368-
mkdir -p /tmp/binaries-linux
369-
docker run -i "$IMAGE" cat /usr/local/bin/seonbi \
370-
> /tmp/binaries-linux/seonbi
371-
docker run -i "$IMAGE" cat /usr/local/bin/seonbi-api \
372-
> /tmp/binaries-linux/seonbi-api
373-
pushd /tmp/binaries-linux
397+
# Linux (amd64)
398+
docker pull "$IMAGE-amd64"
399+
mkdir -p /tmp/binaries-linux-amd64
400+
docker run -i "$IMAGE-amd64" cat /usr/local/bin/seonbi \
401+
> /tmp/binaries-linux-amd64/seonbi
402+
docker run -i "$IMAGE-amd64" cat /usr/local/bin/seonbi-api \
403+
> /tmp/binaries-linux-amd64/seonbi-api
404+
pushd /tmp/binaries-linux-amd64
374405
chmod +x *
375406
cp "$GITHUB_WORKSPACE/"{LICENSE,README.md,CHANGES.md} ./
376407
tar cvfj /tmp/dists/seonbi.linux-x86_64.tar.bz2 *
377408
popd
409+
# Linux (arm64)
410+
docker pull "$IMAGE-arm64"
411+
mkdir -p /tmp/binaries-linux-arm64
412+
docker run -i "$IMAGE-arm64" cat /usr/local/bin/seonbi \
413+
> /tmp/binaries-linux-arm64/seonbi
414+
docker run -i "$IMAGE-arm64" cat /usr/local/bin/seonbi-api \
415+
> /tmp/binaries-linux-arm64/seonbi-api
416+
pushd /tmp/binaries-linux-arm64
417+
chmod +x *
418+
cp "$GITHUB_WORKSPACE/"{LICENSE,README.md,CHANGES.md} ./
419+
tar cvfj /tmp/dists/seonbi.linux-arm64.tar.bz2 *
420+
popd
378421
# macOS (Apple silicon)
379422
pushd /tmp/binaries-macos-arm64
380423
chmod +x *
@@ -404,12 +447,12 @@ jobs:
404447
needs:
405448
- build
406449
- binaries
407-
runs-on: ubuntu-22.04
450+
runs-on: ubuntu-24.04
408451
steps:
409452
- uses: actions/checkout@v4
410453
- uses: actions/download-artifact@v4
411454
with:
412-
name: sdist-ubuntu-22.04-ghc-9.4
455+
name: sdist-ubuntu-24.04-ghc-9.4
413456
path: /tmp/sdist
414457
- uses: actions/download-artifact@v4
415458
with:
@@ -458,7 +501,7 @@ jobs:
458501
if: >-
459502
github.event_name != 'pull_request' &&
460503
github.ref == 'refs/heads/main'
461-
runs-on: ubuntu-22.04
504+
runs-on: ubuntu-24.04
462505
steps:
463506
- uses: actions/checkout@v4
464507
- uses: actions/download-artifact@v4

Dockerfile

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# To correctly make a statically-linked binary, we use Alpine Linux.
22
# The distro entirely uses musl instead of glibc which is unfriendly to be
33
# statically linked.
4-
FROM docker.io/amd64/alpine:3.19 AS build
4+
FROM docker.io/alpine:3.19 AS build
55

66
LABEL "org.opencontainers.image.title"="Seonbi"
77
LABEL "org.opencontainers.image.licenses"="LGPL-2.1"
@@ -11,9 +11,13 @@ RUN apk add --no-cache \
1111
bzip2-dev=1.0.8-r6 \
1212
ghc=9.4.7-r1 \
1313
libbz2=1.0.8-r6 \
14+
xz=5.4.5-r0 \
1415
zlib-dev=1.3.1-r0 \
1516
zlib-static=1.3.1-r0
16-
RUN wget -qO- https://get.haskellstack.org/ | sh
17+
18+
RUN wget -q "https://github.com/commercialhaskell/stack/releases/download/v3.3.1/stack-3.3.1-linux-$(uname -m)-bin" \
19+
&& mv "stack-3.3.1-linux-$(uname -m)-bin" /usr/bin/stack \
20+
&& chmod +x /usr/bin/stack
1721

1822
RUN stack config set system-ghc --global true
1923

@@ -26,8 +30,9 @@ WORKDIR /src/seonbi
2630
# Docker will cache this command as a layer, freeing us up to
2731
# modify source code without re-installing dependencies
2832
# (unless the .cabal file changes!)
29-
RUN stack setup
33+
RUN stack setup --system-ghc
3034
RUN stack build \
35+
--system-ghc \
3136
--only-snapshot \
3237
--flag seonbi:iconv \
3338
--flag seonbi:static
@@ -36,11 +41,12 @@ COPY . /src/seonbi
3641
RUN cp /src/seonbi/stack-ghc-9.4.yaml /src/seonbi/stack.yaml
3742

3843
RUN stack build \
44+
--system-ghc \
3945
--flag seonbi:iconv \
4046
--flag seonbi:static \
4147
--copy-bins
4248

43-
FROM docker.io/amd64/alpine:3.14
49+
FROM docker.io/alpine:3.19
4450

4551
COPY --from=build /root/.local/bin/seonbi* /usr/local/bin/
4652
ENV LANG=en_US.UTF-8

scripts/deno/mod.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ const STABLE_DOWNLOAD_URLS: DownloadUrls = {
143143
linux: {
144144
x86_64:
145145
"https://github.com/dahlia/seonbi/releases/download/0.5.0/seonbi-0.5.0.linux-x86_64.tar.bz2",
146-
aarch64: undefined,
146+
aarch64:
147+
"https://github.com/dahlia/seonbi/releases/download/0.5.0/seonbi-0.5.0.linux-arm64.tar.bz2",
147148
},
148149
darwin: {
149150
x86_64:
@@ -162,7 +163,8 @@ const NIGHTLY_DOWNLOAD_URLS: DownloadUrls = {
162163
linux: {
163164
x86_64:
164165
"https://dahlia.github.io/seonbi/dists/latest/seonbi.linux-x86_64.tar.bz2",
165-
aarch64: undefined,
166+
aarch64:
167+
"https://dahlia.github.io/seonbi/dists/latest/seonbi.linux-arm64.tar.bz2",
166168
},
167169
darwin: {
168170
x86_64:

stack-ghc-9.4.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-21.25
1+
resolver: lts-21.21
22
packages:
33
- .
44
extra-deps:

0 commit comments

Comments
 (0)