Skip to content

Commit 4855120

Browse files
committed
build and deploy full Ubuntu matrix, with static linking and jemalloc
1 parent b2fc08f commit 4855120

16 files changed

+234
-102
lines changed

.github/workflows/Deploy.yml

Lines changed: 26 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -29,77 +29,35 @@ jobs:
2929
run: |
3030
swift --version
3131
swift build -c release --product unidoc
32-
Scripts/Package
32+
Scripts/Package .build/release unidoc
3333
3434
- name: Upload products
3535
env:
3636
UNIDOC_PLATFORM: "${{ runner.os }}-${{ runner.arch }}"
3737
UNIDOC_VERSION: ${{ github.head_ref || github.ref_name }}
3838

39-
run: |
40-
aws s3 cp unidoc.tar.gz \
41-
s3://swiftinit/unidoc/$UNIDOC_VERSION/$UNIDOC_PLATFORM/unidoc.tar.gz \
42-
--content-encoding gzip \
43-
--content-type application/gzip
39+
run: Scripts/Deploy unidoc.tar.gz
4440

4541
linux:
46-
runs-on: ubuntu-24.04
47-
name: Ubuntu 24.04
48-
steps:
49-
- name: Setup AWS CLI
50-
uses: aws-actions/configure-aws-credentials@v1
51-
with:
52-
aws-secret-access-key: ${{ secrets.AWS_S3_ACCESS_SECRET }}
53-
aws-access-key-id: ${{ vars.AWS_S3_ACCESS_KEY }}
54-
aws-region: us-east-1
55-
56-
- name: Install Swift
57-
uses: tayloraswift/swift-install-action@master
58-
with:
59-
swift-prefix: "swift-6.0.2-release/ubuntu2404/swift-6.0.2-RELEASE"
60-
swift-id: "swift-6.0.2-RELEASE-ubuntu24.04"
42+
strategy:
43+
matrix:
44+
os:
45+
- codename: jammy
46+
version: Ubuntu-22.04
47+
display: Ubuntu 22.04
48+
49+
- codename: noble
50+
version: Ubuntu-24.04
51+
display: Ubuntu 24.04
52+
arch:
53+
- id: aarch64
54+
name: ARM64
55+
56+
- id: x86_64
57+
name: X64
6158

62-
- name: Checkout repository
63-
uses: actions/checkout@v3
64-
65-
# For some reason, Swift cannot build both the products in one invocation.
66-
# We pass the same flags to both invocations to speed up the build.
67-
- name: Build products
68-
env:
69-
UNIDOC_ENABLE_INDEXSTORE: "1"
70-
run: |
71-
swift --version
72-
swift build -c release \
73-
--static-swift-stdlib \
74-
--product unidoc \
75-
-Xcxx -I$SWIFT_INSTALLATION/lib/swift \
76-
-Xcxx -I$SWIFT_INSTALLATION/lib/swift/Block
77-
swift build -c release \
78-
--static-swift-stdlib \
79-
--product unidoc-linkerd \
80-
-Xcxx -I$SWIFT_INSTALLATION/lib/swift \
81-
-Xcxx -I$SWIFT_INSTALLATION/lib/swift/Block
82-
Scripts/Package
83-
Scripts/PackageLinker
84-
85-
- name: Upload products
86-
env:
87-
UNIDOC_PLATFORM: "${{ runner.os }}-${{ runner.arch }}"
88-
UNIDOC_VERSION: ${{ github.head_ref || github.ref_name }}
89-
90-
run: |
91-
aws s3 cp unidoc.tar.gz \
92-
s3://swiftinit/unidoc/$UNIDOC_VERSION/$UNIDOC_PLATFORM/unidoc.tar.gz \
93-
--content-encoding gzip \
94-
--content-type application/gzip
95-
aws s3 cp unidoc-linkerd.tar.gz \
96-
s3://swiftinit/unidoc/$UNIDOC_VERSION/$UNIDOC_PLATFORM/unidoc-linkerd.tar.gz \
97-
--content-encoding gzip \
98-
--content-type application/gzip
99-
100-
linux-aarch64:
10159
runs-on: ubuntu-24.04
102-
name: Ubuntu 24.04 (AArch64)
60+
name: "${{ matrix.os.display }} (${{ matrix.arch.id }})"
10361
steps:
10462
- name: Setup AWS CLI
10563
uses: aws-actions/configure-aws-credentials@v1
@@ -113,30 +71,15 @@ jobs:
11371

11472
- name: Build products
11573
run: |
116-
docker run -t --rm \
117-
-v $PWD:/swift-unidoc \
118-
-w /swift-unidoc \
119-
-e UNIDOC_ENABLE_INDEXSTORE=1 \
120-
tayloraswift/swift-cross-aarch64:6.0.2 \
121-
/home/ubuntu/x86_64/swift/usr/bin/swift build \
122-
-c release \
123-
--destination Scripts/aarch64-unknown-linux-gnu.json \
124-
--static-swift-stdlib
125-
126-
Scripts/Package
127-
Scripts/PackageLinker
74+
Scripts/Build ${{ matrix.arch.id }} \
75+
--os ${{ matrix.os.codename }}
76+
Scripts/Package .build.${{ matrix.arch.id }}/release \
77+
unidoc \
78+
unidoc-linkerd
12879
12980
- name: Upload products
13081
env:
131-
UNIDOC_PLATFORM: "${{ runner.os }}-ARM64"
82+
UNIDOC_PLATFORM: "${{ matrix.os.version }}-${{ matrix.arch.name }}"
13283
UNIDOC_VERSION: ${{ github.head_ref || github.ref_name }}
13384

134-
run: |
135-
aws s3 cp unidoc.tar.gz \
136-
s3://swiftinit/unidoc/$UNIDOC_VERSION/$UNIDOC_PLATFORM/unidoc.tar.gz \
137-
--content-encoding gzip \
138-
--content-type application/gzip
139-
aws s3 cp unidoc-linkerd.tar.gz \
140-
s3://swiftinit/unidoc/$UNIDOC_VERSION/$UNIDOC_PLATFORM/unidoc-linkerd.tar.gz \
141-
--content-encoding gzip \
142-
--content-type application/gzip
85+
run: Scripts/Deploy unidoc.tar.gz unidoc-linkerd.tar.gz

Scripts/Deploy

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ -z $UNIDOC_PLATFORM ]; then
5+
echo "UNIDOC_PLATFORM environment variable not set"
6+
exit 1
7+
fi
8+
9+
if [ -z $UNIDOC_VERSION ]; then
10+
echo "UNIDOC_VERSION environment variable not set"
11+
exit 1
12+
fi
13+
14+
while [[ $# -gt 0 ]]; do
15+
aws s3 cp $1 \
16+
s3://swiftinit/unidoc/$UNIDOC_VERSION/$UNIDOC_PLATFORM/$1 \
17+
--content-encoding gzip \
18+
--content-type application/gzip
19+
shift
20+
done

Scripts/Linux/Build

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
set -e
3+
4+
HOST_ARCH=$(uname -m)
5+
DEST_ARCH=aarch64
6+
DEST_OS=noble
7+
LIBC=gnu
8+
9+
while [[ $# -gt 0 ]]; do
10+
case $1 in
11+
--os )
12+
shift
13+
14+
case $1 in
15+
jammy | noble )
16+
DEST_OS=$1
17+
shift
18+
;;
19+
20+
* )
21+
echo "Unsupported OS '$1'"
22+
exit 1
23+
;;
24+
esac
25+
;;
26+
27+
x86_64 | aarch64)
28+
DEST_ARCH=$1
29+
shift
30+
;;
31+
32+
* )
33+
echo "Unknown architecture '$1'"
34+
exit 1
35+
;;
36+
esac
37+
done
38+
39+
DOCKER_IMAGE=unidoc:__${DEST_ARCH}_${DEST_OS}
40+
41+
docker build -f Scripts/Linux/$HOST_ARCH/$DEST_ARCH-$DEST_OS.dockerfile -t $DOCKER_IMAGE .
42+
43+
docker run --rm \
44+
-e UNIDOC_ENABLE_INDEXSTORE=1 \
45+
-v $PWD:/swift-unidoc \
46+
-w /swift-unidoc \
47+
$DOCKER_IMAGE /home/ubuntu/$HOST_ARCH/swift/usr/bin/swift build \
48+
--configuration release \
49+
--scratch-path .build.$DEST_ARCH \
50+
--cache-path /swiftpm \
51+
--destination Scripts/Linux/$HOST_ARCH/$DEST_ARCH-$DEST_OS.json \
52+
--static-swift-stdlib \
53+
-Xlinker -ljemalloc

Scripts/Linux/x86_64/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This directory contains configuration files for building Unidoc from an x86_64 host system.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM tayloraswift/swift-cross-aarch64:6.0.2-jammy
2+
3+
# Only bash supports multiline strings
4+
SHELL ["/bin/bash", "-c"]
5+
6+
RUN dpkg --add-architecture arm64
7+
8+
## Arch-qualify the current sources
9+
RUN sed -i "s/deb h/deb [arch=amd64] h/g" /etc/apt/sources.list
10+
11+
## Add AArch64 sources — the `jemalloc` package is part of the `universe` component.
12+
RUN echo $'deb [arch=arm64] http://ports.ubuntu.com jammy main universe\n\
13+
deb [arch=arm64] http://ports.ubuntu.com jammy-security main universe\n\
14+
deb [arch=arm64] http://ports.ubuntu.com jammy-backports main universe\n\
15+
deb [arch=arm64] http://ports.ubuntu.com jammy-updates main universe\n' \
16+
> /etc/apt/sources.list.d/arm64.list
17+
18+
RUN apt update
19+
RUN apt -y install libjemalloc-dev:arm64 libjemalloc2:arm64

Scripts/aarch64-unknown-linux-gnu.json renamed to Scripts/Linux/x86_64/aarch64-jammy.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
"-fPIC"
88
],
99
"extra-cpp-flags": [
10-
"-lstdc++",
1110
"-I", "/usr/aarch64-linux-gnu/include/c++/12",
1211
"-I", "/usr/aarch64-linux-gnu/include/c++/12/aarch64-linux-gnu/",
1312

1413
"-I", "/home/ubuntu/aarch64/swift/usr/lib/swift",
1514
"-I", "/home/ubuntu/aarch64/swift/usr/lib/swift/Block"
1615
],
1716
"extra-swiftc-flags": [
18-
"-resource-dir", "/home/ubuntu/aarch64/swift/usr/lib/swift"
17+
"-resource-dir", "/home/ubuntu/aarch64/swift/usr/lib/swift_static"
1918
]
2019
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM tayloraswift/swift-cross-aarch64:6.0.2-noble
2+
3+
# Only bash supports multiline strings
4+
SHELL ["/bin/bash", "-c"]
5+
6+
RUN dpkg --add-architecture arm64
7+
8+
## Arch-qualify the current sources (noble uses the deb822 format)
9+
RUN sed -i "s/Types: deb/Types: deb\nArchitectures: amd64/" \
10+
/etc/apt/sources.list.d/ubuntu.sources
11+
12+
## Add AArch64 sources — the `jemalloc` package is part of the `universe` component.
13+
RUN echo $'Types: deb\n\
14+
Architectures: arm64\n\
15+
URIs: http://ports.ubuntu.com\n\
16+
Suites: noble noble-updates noble-backports\n\
17+
Components: main universe\n\
18+
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n\
19+
\n\
20+
Types: deb\n\
21+
Architectures: arm64\n\
22+
URIs: http://ports.ubuntu.com\n\
23+
Suites: noble-security\n\
24+
Components: main universe\n\
25+
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n' \
26+
> /etc/apt/sources.list.d/arm64.sources
27+
28+
RUN apt update
29+
RUN apt -y install libjemalloc-dev:arm64 libjemalloc2:arm64
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": 1,
3+
"target": "aarch64-unknown-linux-gnu",
4+
"toolchain-bin-dir": "/home/ubuntu/x86_64/swift/usr/bin",
5+
"sdk": "/usr/aarch64-linux-gnu",
6+
"extra-cc-flags": [
7+
"-fPIC"
8+
],
9+
"extra-cpp-flags": [
10+
"-I", "/usr/aarch64-linux-gnu/include/c++/13",
11+
"-I", "/usr/aarch64-linux-gnu/include/c++/13/aarch64-linux-gnu/",
12+
13+
"-I", "/home/ubuntu/aarch64/swift/usr/lib/swift",
14+
"-I", "/home/ubuntu/aarch64/swift/usr/lib/swift/Block"
15+
],
16+
"extra-swiftc-flags": [
17+
"-resource-dir", "/home/ubuntu/aarch64/swift/usr/lib/swift_static"
18+
]
19+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM tayloraswift/swift-cross-aarch64:6.0.2-jammy
2+
3+
RUN apt update
4+
RUN apt -y install libjemalloc-dev:amd64 libjemalloc2:amd64
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
x86_64.json

0 commit comments

Comments
 (0)