Skip to content

Commit 1fc740d

Browse files
ntkmenex3
andauthored
Upload releases for musl-libc and android (#2149)
Co-authored-by: Natalie Weizenbaum <[email protected]>
1 parent 6f665c1 commit 1fc740d

File tree

11 files changed

+921
-638
lines changed

11 files changed

+921
-638
lines changed

.github/util/initialize/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Initialize
22
description: Check out Dart Sass and build the embedded protocol buffer.
33
inputs:
44
github-token: {required: true}
5-
node-version: {required: false, default: 18}
5+
node-version: {required: false, default: 'lts/*'}
66
dart-sdk: {required: false, default: stable}
77
architecture: {required: false}
88
runs:
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build for android
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build:
9+
name: Build
10+
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- arch: x64
18+
lib: lib64
19+
platform: linux/amd64
20+
- arch: ia32
21+
lib: lib
22+
platform: linux/amd64
23+
- arch: arm64
24+
lib: lib64
25+
platform: linux/arm64
26+
- arch: arm
27+
lib: lib
28+
platform: linux/arm64
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Set up QEMU
34+
uses: docker/setup-qemu-action@v3
35+
with:
36+
image: tonistiigi/binfmt:master # need qemu >= 7.0.0
37+
38+
- name: Compile Protobuf
39+
run: |
40+
docker run --rm -i \
41+
--volume "$PWD:$PWD" \
42+
--workdir "$PWD" \
43+
docker.io/library/dart <<'EOF'
44+
set -e
45+
curl -fsSL -H "Authorization: Bearer ${{ github.token }}" "https://github.com/bufbuild/buf/releases/latest/download/buf-$(uname -s)-$(uname -m).tar.gz" | tar -xzC /usr/local --strip-components 1
46+
dart pub get
47+
dart run grinder protobuf
48+
EOF
49+
50+
- name: Build
51+
run: |
52+
docker run --rm -i \
53+
--platform ${{ matrix.platform }} \
54+
--privileged \
55+
--volume "$PWD:$PWD" \
56+
--workdir "$PWD" \
57+
ghcr.io/dart-android/dart <<'EOF'
58+
set -e
59+
export DART_SDK=/system/${{ matrix.lib }}/dart
60+
export PATH=$DART_SDK/bin:$PATH
61+
dart pub get
62+
dart run grinder pkg-standalone-android-${{ matrix.arch }}
63+
EOF
64+
65+
- name: Upload Artifact
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: build-android-${{ matrix.arch }}
69+
path: build/*.tar.gz
70+
if-no-files-found: error
71+
compression-level: 0
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build for linux-musl
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build:
9+
name: Build
10+
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- arch: x64
18+
platform: linux/amd64
19+
- arch: ia32
20+
platform: linux/386
21+
- arch: arm64
22+
platform: linux/arm64
23+
- arch: arm
24+
platform: linux/arm/v7
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v3
31+
32+
- name: Compile Protobuf
33+
run: |
34+
docker run --rm -i \
35+
--volume "$PWD:$PWD" \
36+
--workdir "$PWD" \
37+
docker.io/library/dart <<'EOF'
38+
set -e
39+
curl -fsSL -H "Authorization: Bearer ${{ github.token }}" "https://github.com/bufbuild/buf/releases/latest/download/buf-$(uname -s)-$(uname -m).tar.gz" | tar -xzC /usr/local --strip-components 1
40+
dart pub get
41+
dart run grinder protobuf
42+
EOF
43+
44+
# https://gitlab.com/qemu-project/qemu/-/issues/1729
45+
#
46+
# There is a bug in qemu's mremap causing pthread_getattr_np in musl to stuck in a loop on arm.
47+
# Unless qemu fixes the bug or we get a real linux-arm runner, we cannot build aot-snapshot
48+
# for arm on CI. So, we create a kernel snapshot for arm build in amd64 container instead.
49+
- name: Build
50+
run: |
51+
docker run --rm -i \
52+
--platform ${{ matrix.arch == 'arm' && 'linux/amd64' || matrix.platform }} \
53+
--volume "$PWD:$PWD" \
54+
--workdir "$PWD" \
55+
ghcr.io/dart-musl/dart <<'EOF'
56+
set -e
57+
dart pub get
58+
dart run grinder pkg-standalone-linux-${{ matrix.arch }}
59+
# Rename the artifact from -linux- to -linux-musl- to avoid conflict with glibc builds.
60+
find build -name '*.tar.gz' -print0 | xargs -0 -n 1 -- sh -xc 'mv "$1" "$(echo "$1" | sed -e "s/linux/linux-musl/")"' --
61+
EOF
62+
63+
# The kernel snapshot created for arm in the previous step is bundling a glibc based dart runtime
64+
# due to how cli_pkg downloads the sdk for building non-native platforms. Therefore we need to
65+
# replace it with musl-libc based dart runtime to create a working linux-musl-arm package.
66+
- name: Fix Dart Runtime
67+
if: matrix.arch == 'arm'
68+
run: |
69+
docker run --rm -i \
70+
--platform ${{ matrix.platform }} \
71+
--volume $PWD:$PWD \
72+
--workdir $PWD \
73+
ghcr.io/dart-musl/dart <<'EOF'
74+
set -e
75+
apk add --no-cache tar
76+
cd build
77+
DART_RUNTIME=$(tar -tzf *.tar.gz --wildcards "*/src/dart")
78+
tar -xzf *.tar.gz
79+
cp $DART_SDK/bin/dart $DART_RUNTIME
80+
tar -czf *.tar.gz "$(dirname "$(dirname "$DART_RUNTIME")")"
81+
EOF
82+
83+
- name: Upload Artifact
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: build-linux-musl-${{ matrix.arch }}
87+
path: build/*.tar.gz
88+
if-no-files-found: error
89+
compression-level: 0

.github/workflows/build-linux.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build for linux
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build:
9+
name: Build
10+
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- arch: x64
18+
platform: linux/amd64
19+
- arch: ia32
20+
platform: linux/amd64
21+
- arch: arm
22+
platform: linux/arm/v7
23+
- arch: arm64
24+
platform: linux/arm64
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v3
31+
32+
- name: Compile Protobuf
33+
run: |
34+
docker run --rm -i \
35+
--volume "$PWD:$PWD" \
36+
--workdir "$PWD" \
37+
docker.io/library/dart <<'EOF'
38+
set -e
39+
curl -fsSL -H "Authorization: Bearer ${{ github.token }}" "https://github.com/bufbuild/buf/releases/latest/download/buf-$(uname -s)-$(uname -m).tar.gz" | tar -xzC /usr/local --strip-components 1
40+
dart pub get
41+
dart run grinder protobuf
42+
EOF
43+
44+
- name: Build
45+
run: |
46+
docker run --rm -i \
47+
--platform ${{ matrix.platform }} \
48+
--volume "$PWD:$PWD" \
49+
--workdir "$PWD" \
50+
docker.io/library/dart:latest <<'EOF'
51+
set -e
52+
dart pub get
53+
dart run grinder pkg-standalone-linux-${{ matrix.arch }}
54+
EOF
55+
56+
- name: Upload Artifact
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: build-linux-${{ matrix.arch }}
60+
path: build/*.tar.gz
61+
if-no-files-found: error
62+
compression-level: 0

.github/workflows/build-macos.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build for macos
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build:
9+
name: Build
10+
11+
runs-on: ${{ matrix.runner }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- arch: x64
18+
runner: macos-latest
19+
# https://github.blog/2023-10-02-introducing-the-new-apple-silicon-powered-m1-macos-larger-runner-for-github-actions/
20+
- arch: arm64
21+
runner: macos-latest-xlarge
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: ./.github/util/initialize
27+
with: {github-token: "${{ github.token }}"}
28+
29+
- name: Build
30+
run: dart run grinder pkg-standalone-macos-${{ matrix.arch }}
31+
32+
- name: Upload Artifact
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: build-macos-${{ matrix.arch }}
36+
path: build/*.tar.gz
37+
if-no-files-found: error
38+
compression-level: 0
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build for windows
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build:
9+
name: Build
10+
11+
runs-on: ${{ matrix.runner }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- arch: x64
18+
runner: windows-latest
19+
- arch: ia32
20+
runner: windows-latest
21+
# The support of windows-arm64 dart-sdk is in beta.
22+
# TODO: Enable this once windows-arm64 support is stable.
23+
# - arch: arm64
24+
# runner: windows-latest
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- uses: ./.github/util/initialize
30+
with: {github-token: "${{ github.token }}"}
31+
32+
- name: Build
33+
run: dart run grinder pkg-standalone-windows-${{ matrix.arch }}
34+
35+
- name: Upload Artifact
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: build-windows-${{ matrix.arch }}
39+
path: build/*.zip
40+
if-no-files-found: error
41+
compression-level: 0

0 commit comments

Comments
 (0)