-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (131 loc) · 4.67 KB
/
build-ark-linux.yml
File metadata and controls
144 lines (131 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: "Ark Prebuild: Linux"
# Builds Ark for Linux (x64 + arm64). Linked against an old glibc via
# cargo-zigbuild for broad distro compatibility, matching ark's own release
# workflow. Called from build-ark.yml.
on:
workflow_call:
inputs:
ark_ref:
required: true
type: string
description: "Ark git ref/SHA to build"
version:
required: false
default: ""
type: string
description: "Public ark version, e.g. 0.1.251 (derived from ark_ref if omitted)"
distance:
required: false
default: ""
type: string
description: "Commits since the public version tag (derived from ark_ref if omitted)"
short_sha:
required: false
default: ""
type: string
description: "Short (7-char) SHA of the ark commit (derived from ark_ref if omitted)"
workflow_dispatch:
inputs:
ark_ref:
required: false
default: "main"
type: string
version:
required: false
default: ""
type: string
distance:
required: false
default: ""
type: string
short_sha:
required: false
default: ""
type: string
jobs:
resolve:
name: Resolve version inputs
runs-on: ubuntu-latest
outputs:
version: ${{ steps.out.outputs.version }}
distance: ${{ steps.out.outputs.distance }}
short_sha: ${{ steps.out.outputs.short_sha }}
steps:
# Skip checkout when the caller already passed all three values; the
# parent build-ark.yml does, so the common path is a pure passthrough.
- name: Checkout ark
if: ${{ inputs.version == '' || inputs.distance == '' || inputs.short_sha == '' }}
uses: actions/checkout@v4
with:
repository: posit-dev/ark
ref: ${{ inputs.ark_ref }}
fetch-depth: 0
- name: Compute outputs
id: out
run: |
set -euo pipefail
VERSION='${{ inputs.version }}'
DISTANCE='${{ inputs.distance }}'
SHORT_SHA='${{ inputs.short_sha }}'
if [ -z "$VERSION" ]; then
VERSION=$(grep '^version' crates/ark/Cargo.toml | sed -e 's/[^.0-9]//g')
fi
if [ -z "$DISTANCE" ]; then
LAST_TAG=$(git describe --tags --abbrev=0)
DISTANCE=$(git rev-list --count "${LAST_TAG}..HEAD")
fi
if [ -z "$SHORT_SHA" ]; then
SHORT_SHA=$(git rev-parse --short=7 HEAD)
fi
echo "version=${VERSION}" | tee -a $GITHUB_OUTPUT
echo "distance=${DISTANCE}" | tee -a $GITHUB_OUTPUT
echo "short_sha=${SHORT_SHA}" | tee -a $GITHUB_OUTPUT
build_linux:
name: Build Linux ${{ matrix.arch }}
needs: resolve
runs-on: ubuntu-latest
timeout-minutes: 60
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ARCH_FLAG: ${{ matrix.arch == 'x64' && 'x86_64' || 'aarch64' }}
GLIBC_MAX_VERSION: '2.26'
strategy:
matrix:
arch: [x64, arm64]
steps:
- name: Checkout ark
uses: actions/checkout@v4
with:
repository: posit-dev/ark
ref: ${{ inputs.ark_ref }}
- name: Setup build environment
run: |
sudo apt-get update
sudo apt-get install -y cargo
# Use the zig linker to pin glibc version
cargo install --locked cargo-zigbuild
sudo apt install python3-pip
pip3 install ziglang
- name: Setup arm64 cross target
if: matrix.arch == 'arm64'
run: rustup target add aarch64-unknown-linux-gnu
- name: Compile ark
env:
ARK_BUILD_VERSION: ${{ needs.resolve.outputs.version }}+${{ needs.resolve.outputs.distance }}.${{ needs.resolve.outputs.short_sha }}
run: |
cargo clean
cargo zigbuild --release \
--target ${ARCH_FLAG}-unknown-linux-gnu.${GLIBC_MAX_VERSION}
- name: Create archive
run: |
pushd target/${ARCH_FLAG}-unknown-linux-gnu/release
ARCHIVE="$GITHUB_WORKSPACE/ark-${{ needs.resolve.outputs.version }}-${{ needs.resolve.outputs.distance }}-${{ needs.resolve.outputs.short_sha }}-linux-${{ matrix.arch }}.zip"
[ -e LICENSE ] || cp "$GITHUB_WORKSPACE/LICENSE" LICENSE
[ -e NOTICE ] || cp "$GITHUB_WORKSPACE/crates/ark/NOTICE" NOTICE
zip -Xry $ARCHIVE ark LICENSE NOTICE
popd
- name: Upload archive
uses: actions/upload-artifact@v4
with:
name: ark-linux-${{ matrix.arch }}-archive
path: ark-${{ needs.resolve.outputs.version }}-${{ needs.resolve.outputs.distance }}-${{ needs.resolve.outputs.short_sha }}-linux-${{ matrix.arch }}.zip