Skip to content

Commit 4077d41

Browse files
committed
Build linux-arm64 on an arm runner
1 parent be0c986 commit 4077d41

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,55 +20,61 @@ jobs:
2020
echo "Tag format is invalid. Expected semantic versioning (e.g., 1.2.3)."
2121
exit 1
2222
fi
23-
macos:
24-
runs-on: macos-latest
23+
build:
24+
runs-on: ${{ matrix.runs-on }}
2525
needs:
2626
- validate
2727
strategy:
2828
matrix:
29-
arch:
30-
- arm64
29+
runs-on:
30+
- macos-15
31+
- ubuntu-24.04
32+
- ubuntu-24.04-arm
3133
steps:
3234
- uses: actions/checkout@v4
3335
with:
3436
repository: apple/swift-protobuf
3537
ref: ${{ github.ref_name }}
36-
- run: |
37-
swift build -c release
38-
mv .build/release/protoc-gen-swift protoc-gen-swift-macos-${{ matrix.arch }}
39-
- uses: actions/upload-artifact@v4
40-
with:
41-
name: protoc-gen-swift-macos-${{ matrix.arch }}
42-
path: protoc-gen-swift-macos-${{ matrix.arch }}
43-
linux:
44-
runs-on: ubuntu-latest
45-
needs:
46-
- validate
47-
strategy:
48-
matrix:
49-
arch:
50-
- amd64
51-
- arm64
52-
steps:
53-
- uses: actions/checkout@v4
54-
with:
55-
repository: apple/swift-protobuf
56-
ref: ${{ github.ref_name }}
57-
- run: |
58-
swift build -c release --static-swift-stdlib
59-
mv .build/release/protoc-gen-swift protoc-gen-swift-linux-${{ matrix.arch }}
38+
- id: build
39+
run: |
40+
echo "OS: $(uname)"
41+
echo "arch: $(uname -m)"
42+
if [[ $(uname) == "Darwin" ]]; then
43+
os=macos
44+
elif [[ $(uname) == "Linux" ]]; then
45+
os=linux
46+
flags="--static-swift-stdlib"
47+
else
48+
echo "Unsupported OS: $(uname)"
49+
exit 1
50+
fi
51+
if [[ "$(uname -m)" == "aarch64" ]]; then
52+
arch=arm64
53+
elif [[ "$(uname -m)" == "arm64" ]]; then
54+
arch=arm64
55+
elif [[ "$(uname -m)" == "x86_64" ]]; then
56+
arch=amd64
57+
elif [[ "$(uname -m)" == "amd64" ]]; then
58+
arch=amd64
59+
else
60+
echo "Unsupported architecture: $(uname -m)"
61+
exit 1
62+
fi
63+
swift build -c release $flags
64+
executable="protoc-gen-swift-$os-$arch"
65+
echo "executable=$executable" >> $GITHUB_OUTPUT
66+
mv .build/release/protoc-gen-swift $executable
6067
- uses: actions/upload-artifact@v4
6168
with:
62-
name: protoc-gen-swift-linux-${{ matrix.arch }}
63-
path: protoc-gen-swift-linux-${{ matrix.arch }}
69+
name: ${{ steps.build.outputs.executable }}
70+
path: ${{ steps.build.outputs.executable }}
6471
release:
6572
runs-on: ubuntu-latest
6673
needs:
67-
- macos
68-
- linux
74+
- build
6975
steps:
7076
- uses: actions/download-artifact@v4
71-
- run: ls -l; ls -l protoc-gen-swift-*
77+
- run: ls -l
7278
- uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda
7379
with:
7480
files: '**/protoc-gen-swift-*'

0 commit comments

Comments
 (0)