Skip to content

Commit df03a9e

Browse files
committed
attempt to DRY up QEMU setup
1 parent 775f5d2 commit df03a9e

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

.github/actions/setup-qemu/action.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: 'Setup QEMU'
2+
description: 'Setup QEMU for arm64 architecture'
3+
inputs:
4+
arch:
5+
description: 'Architecture to set up QEMU for'
6+
required: true
7+
default: 'x64'
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
- name: Setup QEMU
13+
if: ${{ inputs.arch == 'arm64' }}
14+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392
15+
with:
16+
platforms: linux/arm64

.github/workflows/build.yml

+11-19
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ jobs:
4444
arch: [x64, arm64]
4545
runs-on: ubuntu-22.04 # < compile with oldest supported Ubuntu
4646
steps:
47-
- name: Setup QEMU
48-
if: ${{ matrix.arch == 'arm64' }}
49-
uses: docker/setup-qemu-action@f30d974279f970cd3ed4ee3bcf1ff7795e271f00
47+
- uses: actions/checkout@v4
48+
- uses: ./.github/actions/setup-qemu
5049
with:
51-
platforms: linux/arm64
50+
arch: ${{ matrix.arch }}
5251
- run: sudo apt-get update
5352
- run: sudo apt-get install -y build-essential libglib2.0-dev libblkid-dev uuid-dev
54-
- uses: actions/checkout@v4
5553
- uses: actions/setup-node@v4
5654
with:
5755
node-version: 18
@@ -71,17 +69,15 @@ jobs:
7169
runs-on: ubuntu-24.04
7270
steps:
7371
- uses: actions/checkout@v4
74-
- uses: docker/setup-qemu-action@f30d974279f970cd3ed4ee3bcf1ff7795e271f00
75-
if: ${{ matrix.arch == 'arm64' }}
72+
- uses: ./.github/actions/setup-qemu
7673
with:
77-
platforms: linux/arm64
74+
arch: ${{ matrix.arch }}
7875
- run: |
7976
docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform linux/${{ matrix.arch == 'x64' && 'amd64' || 'arm64' }} node:18-alpine -c "\
8077
apk add build-base git python3 py3-setuptools util-linux-dev --update-cache && \
8178
cd /tmp/project && \
8279
npm ci && \
8380
npm run prebuild"
84-
8581
- uses: actions/upload-artifact@v4
8682
with:
8783
name: prebuilds-linux-${{ matrix.arch }}-musl
@@ -118,17 +114,15 @@ jobs:
118114
node-version: [18, 20, 22, 23]
119115
runs-on: ${{ matrix.os }}
120116
steps:
121-
- name: Setup QEMU
122-
if: ${{ matrix.arch == 'arm64' }}
123-
uses: docker/setup-qemu-action@f30d974279f970cd3ed4ee3bcf1ff7795e271f00
117+
- uses: actions/checkout@v4
118+
- uses: ./.github/actions/setup-qemu
124119
with:
125-
platforms: linux/arm64
120+
arch: ${{ matrix.arch }}
126121
- run: sudo apt-get update
127122
- run: sudo apt-get install -y libglib2.0-dev libblkid-dev uuid-dev
128123
- uses: actions/setup-node@v4
129124
with:
130125
node-version: ${{ matrix.node-version }}
131-
- uses: actions/checkout@v4
132126
- uses: actions/download-artifact@v4
133127
with:
134128
path: ./prebuilds
@@ -141,20 +135,18 @@ jobs:
141135
strategy:
142136
fail-fast: false
143137
matrix:
144-
# my eyes can't discern arm64 from amd64
145138
arch: [x64, arm64]
146139
node-version: [18, 20, 22, 23]
147140
runs-on: ubuntu-24.04
148141
steps:
149142
- uses: actions/checkout@v4
143+
- uses: ./.github/actions/setup-qemu
144+
with:
145+
arch: ${{ matrix.arch }}
150146
- uses: actions/download-artifact@v4
151147
with:
152148
path: ./prebuilds
153149
merge-multiple: true
154-
- uses: docker/setup-qemu-action@f30d974279f970cd3ed4ee3bcf1ff7795e271f00
155-
if: ${{ matrix.arch == 'arm64' }}
156-
with:
157-
platforms: linux/arm64
158150
- run: |
159151
docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform linux/${{ matrix.arch == 'x64' && 'amd64' || 'arm64' }} node:${{ matrix.node-version }}-alpine -c "\
160152
apk add util-linux-dev --update-cache && \

0 commit comments

Comments
 (0)