-
Notifications
You must be signed in to change notification settings - Fork 9
240 lines (189 loc) · 7.42 KB
/
libclient-build.yaml
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: libsignal-build
on:
workflow_dispatch:
inputs:
libsignal-ref:
description: The branch, tag or SHA to checkout for libsignal
default: '' # Use the latest commit from the default branch
schedule:
- cron: '33 3 * * *'
defaults:
run:
shell: bash # Explicit for windows
jobs:
compare_releases:
outputs:
upstream_ver: ${{ steps.check_releases.outputs.upstream_ver }}
release_name: ${{ steps.check_releases.outputs.release_name }}
runs-on: ubuntu-latest
steps:
- name: Checkout this repo sources
uses: actions/checkout@v3
- name: Get libs data in json
id: dummy_matrix
run: python3 generate_matrix.py '0.0.0'
- name: Check the latest official version
id: check_releases
env:
MATRIX_JSON: ${{ steps.dummy_matrix.outputs.matrix }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
upstream_ver: ${{ github.event.inputs.libsignal-ref }}
run: |
LIB_REPO=$(echo "$MATRIX_JSON" | jq -j '.lib[].repo' )
echo "LIB_REPO = $LIB_REPO"
[ -n "$upstream_ver" ] || upstream_ver=$(bash util.sh get_latest_release_name "$LIB_REPO")
echo "upstream_ver=$upstream_ver" | tee -a $GITHUB_OUTPUT
release_name=$(bash util.sh release_name "$LIB_REPO" "$upstream_ver")
this_repo_release=$(bash util.sh get_release_data "$release_name")
[ -z "$this_repo_release" ] || release_name=''
echo "release_name=$release_name" | tee -a $GITHUB_OUTPUT
new_release:
needs:
- compare_releases
if: ${{ needs.compare_releases.outputs.release_name }}
runs-on: ubuntu-latest
steps:
- name: Checkout this repo sources
uses: actions/checkout@v3
- name: Create a new release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REF_NAME: ${{ github.ref_name }}
TAG_NAME: ${{ needs.compare_releases.outputs.release_name }}
run: |
gh release create \
--target "$GITHUB_REF_NAME" \
-n "Produced by GitHub actions run: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" \
"$TAG_NAME"
matrix_setup:
needs:
- new_release
- compare_releases
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
runs-on: ubuntu-latest
steps:
- name: Checkout this repo sources
uses: actions/checkout@v3
- name: Generate matrix
id: matrix
env:
LIBSIGNAL_VERSION: ${{ needs.compare_releases.outputs.upstream_ver }}
run: python3 generate_matrix.py "$LIBSIGNAL_VERSION"
build:
needs:
- matrix_setup
- compare_releases
strategy:
matrix: ${{ fromJSON(needs.matrix_setup.outputs.matrix) }}
fail-fast: false # do not abort all if some of the builds fail
name: build_${{ matrix.build-env.target || matrix.build-env.triple }}
runs-on: ${{ matrix.build-env.runner }}
container: ${{ matrix.build-env.container }}
env:
TARGET: ${{ matrix.build-env.target }}
THIS_REPO_DIR: _this_repo_checkout
# Ref:
# Upstream workflow:
# https://github.com/signalapp/libsignal-client/blob/master/.github/workflows/build_and_test.yml
# Signal-cli wiki:
# https://github.com/AsamK/signal-cli/wiki/Provide-native-lib-for-libsignal
steps:
- name: Dump strategy and matrix contexts
run: |
echo '${{ toJSON(strategy) }}'
echo '${{ toJSON(matrix) }}'
- name: Checkout this repo sources
uses: actions/checkout@v3
- name: Install required packages
if: ${{ matrix.build-env.req-pkg }}
env:
INSTALL_CMD: ${{ matrix.build-env.install-cmd }}
PKGS: ${{ matrix.build-env.req-pkg }}
run: |
bash -c "$INSTALL_CMD $PKGS"
- name: Generate file names for the current matrix item
id: filenames
env:
MATRIX_RUN: ${{ toJSON(matrix) }}
run: python3 filename_for_matrix_item.py "$MATRIX_RUN"
- name: Clone upstream source
uses: actions/checkout@v3
with:
repository: ${{ matrix.lib.repo }}
ref: ${{ matrix.lib.ref }}
- name: Install Rust toolchain
run: rustup toolchain install nightly --profile minimal
# Why nightly: https://github.com/signalapp/libsignal/issues/141#issuecomment-1211192153
- name: Add target to rust toolchain
if: ${{ matrix.build-env.target }}
run: rustup target add $TARGET
- name: Add linker to cargo config
# Alternatively can add to rust flags
#RUSTFLAGS: -C linker=${{ matrix.build-env.linker }}
if: ${{ matrix.build-env.linker }}
env:
LINKER: ${{ matrix.build-env.linker }}
run: |
cat >> ~/.cargo/config <<EOF
[target.$TARGET]
linker = "$LINKER"
EOF
- name: Setup rust cache
if: false # Not using cache
# On macos-latest cache does not work properly:
# https://github.com/actions/cache/issues/403
# https://github.com/rust-lang/cargo/issues/8603
# https://github.com/Swatinem/rust-cache
uses: actions/cache@v3
env:
cache-name: cache-rust
with:
path: |
~/.cargo
./target
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.build-env.target }}-${{ matrix.lib.name }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.build-env.target }}-${{ matrix.lib.name }}-
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.build-env.target }}-
- name: Cargo build
env:
RUSTFLAGS: -C link-arg=-s ${{ matrix.build-env.rust-flags }}
CARGO_FLAGS: ${{ matrix.lib.cargo-flags }}
BUILD_ENV_VARS: ${{ matrix.build-env.build-env-vars }}
run: |
if [[ -n $TARGET ]]; then
export CARGO_BUILD_TARGET=$TARGET
fi
env $BUILD_ENV_VARS cargo build --release --verbose $CARGO_FLAGS
- name: Inspect built file
env:
FILENAME: ${{ steps.filenames.outputs.lib_filename }}
working-directory: target/${{ matrix.build-env.target }}/release
run: |
file $FILENAME
readelf --arch-specific $FILENAME || :
ldd -v $FILENAME || :
objdump -T $FILENAME | grep LIBC || :
objdump -T $FILENAME | grep LIBC | cut -d'_' -f2 | sort -V | tail -n1 | cut -d ' ' -f1 || :
openssl sha256 $FILENAME
- name: Create archive
env:
DIR: target/${{ matrix.build-env.target }}/release
FILENAME: ${{ steps.filenames.outputs.lib_filename }}
ARCHIVE_NAME: ${{ steps.filenames.outputs.archive_name }}
run: tar -czvf ${ARCHIVE_NAME}.tar.gz --directory ${DIR} ${FILENAME}
- name: Checkout this repo
# (for gh cli)
uses: actions/checkout@v3
with:
path: ${{ env.THIS_REPO_DIR }}
clean: false
- name: Upload release asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ needs.compare_releases.outputs.release_name }}
FILENAME: ${{ steps.filenames.outputs.archive_name }}.tar.gz
working-directory: ${{ env.THIS_REPO_DIR }}
run: gh release upload "$TAG_NAME" "${GITHUB_WORKSPACE}/${FILENAME}"