Skip to content

Commit 1e8ee80

Browse files
authored
Only upload one copy of linux binaries to releases (#1721)
We upload the statically-linked Alpine edge binaries, as these are probably the most portable. Note that the statically-linked Alpine binaries are actually smaller than the Debian executables (~35 MB archive vs ~41 MB archive), though the Debian ones are pie (position-independent executables, supporting Address Space Layout Randomization).
1 parent 4e7dde9 commit 1e8ee80

File tree

6 files changed

+143
-46
lines changed

6 files changed

+143
-46
lines changed

.github/workflows/coq-alpine.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ jobs:
161161
contents: write # IMPORTANT: mandatory for making GitHub Releases
162162
steps:
163163
- uses: actions/checkout@v4
164+
with:
165+
fetch-depth: 0 # Fetch all history for all tags and branches
166+
tags: true # Fetch all tags as well, `fetch-depth: 0` might be sufficient depending on Git version
164167
- name: Download standalone edge
165168
uses: actions/download-artifact@v3
166169
with:
@@ -171,9 +174,15 @@ jobs:
171174
- name: Unpack files
172175
run: |
173176
mkdir dist
174-
mv dist-edge/standalone.tar.gz dist/fiat-crypto-alpine-edge.tar.gz
177+
echo "::group::find arch"
178+
( cd dist-edge && tar -xzvf standalone.tar.gz )
179+
arch="$(etc/ci/find-arch.sh dist-edge/word_by_word_montgomery "unknown")"
180+
tag="$(git describe --tags HEAD)"
181+
fname="Fiat-Cryptography_${tag}_Linux_${arch}.tar.gz"
182+
echo "$fname"
183+
mv dist-edge/standalone.tar.gz "dist/$fname"
175184
find dist
176-
tar -tvf dist/fiat-crypto-alpine-edge.tar.gz
185+
tar -tvf "dist/$fname"
177186
- name: Upload artifacts to GitHub Release
178187
env:
179188
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/coq-debian.yml

+29-20
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,16 @@ jobs:
149149
echo "::endgroup::"
150150
done
151151
152-
publish-standalone:
152+
publish-standalone-dry-run:
153153
runs-on: ubuntu-latest
154154
needs: build
155-
permissions:
156-
contents: write # IMPORTANT: mandatory for making GitHub Releases
155+
# permissions:
156+
# contents: write # IMPORTANT: mandatory for making GitHub Releases
157157
steps:
158158
- uses: actions/checkout@v4
159+
with:
160+
fetch-depth: 0 # Fetch all history for all tags and branches
161+
tags: true # Fetch all tags as well, `fetch-depth: 0` might be sufficient depending on Git version
159162
- name: Download standalone sid
160163
uses: actions/download-artifact@v3
161164
with:
@@ -166,34 +169,40 @@ jobs:
166169
- name: Unpack files
167170
run: |
168171
mkdir dist
169-
mv dist-sid/standalone.tar.gz dist/fiat-crypto-sid.tar.gz
172+
echo "::group::find arch"
173+
( cd dist-sid && tar -xzvf standalone.tar.gz )
174+
arch="$(etc/ci/find-arch.sh dist-sid/word_by_word_montgomery "unknown")"
175+
tag="$(git describe --tags HEAD)"
176+
fname="Fiat-Cryptography_${tag}_Linux_debian_sid_${arch}.tar.gz"
177+
echo "$fname"
178+
mv dist-sid/standalone.tar.gz "dist/$fname"
170179
find dist
171-
tar -tvf dist/fiat-crypto-sid.tar.gz
172-
- name: Upload artifacts to GitHub Release
173-
env:
174-
GITHUB_TOKEN: ${{ github.token }}
175-
# Upload to GitHub Release using the `gh` CLI.
176-
# `dist/` contains the built packages
177-
run: >-
178-
gh release upload
179-
'${{ github.ref_name }}' dist/**
180-
--repo '${{ github.repository }}'
181-
if: ${{ startsWith(github.ref, 'refs/tags/') && github.event_name == 'release' }}
180+
tar -tvf "dist/$fname"
181+
# - name: Upload artifacts to GitHub Release
182+
# env:
183+
# GITHUB_TOKEN: ${{ github.token }}
184+
# # Upload to GitHub Release using the `gh` CLI.
185+
# # `dist/` contains the built packages
186+
# run: >-
187+
# gh release upload
188+
# '${{ github.ref_name }}' dist/**
189+
# --repo '${{ github.repository }}'
190+
# if: ${{ startsWith(github.ref, 'refs/tags/') && github.event_name == 'release' }}
182191

183192
debian-check-all:
184193
runs-on: ubuntu-latest
185-
needs: [build, test-standalone, publish-standalone]
194+
needs: [build, test-standalone, publish-standalone-dry-run]
186195
if: always()
187196
steps:
188197
- run: echo 'build passed'
189198
if: ${{ needs.build.result == 'success' }}
190199
- run: echo 'test-standalone passed'
191200
if: ${{ needs.test-standalone.result == 'success' }}
192-
- run: echo 'publish-standalone passed'
193-
if: ${{ needs.publish-standalone.result == 'success' }}
201+
- run: echo 'publish-standalone-dry-run passed'
202+
if: ${{ needs.publish-standalone-dry-run.result == 'success' }}
194203
- run: echo 'build failed' && false
195204
if: ${{ needs.build.result != 'success' }}
196205
- run: echo 'test-standalone failed' && false
197206
if: ${{ needs.test-standalone.result != 'success' }}
198-
- run: echo 'publish-standalone failed' && false
199-
if: ${{ needs.publish-standalone.result != 'success' }}
207+
- run: echo 'publish-standalone-dry-run failed' && false
208+
if: ${{ needs.publish-standalone-dry-run.result != 'success' }}

.github/workflows/coq-docker.yml

+29-20
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,16 @@ jobs:
202202
echo "::endgroup::"
203203
done
204204
205-
publish-standalone:
205+
publish-standalone-dry-run:
206206
runs-on: ubuntu-latest
207207
needs: build
208-
permissions:
209-
contents: write # IMPORTANT: mandatory for making GitHub Releases
208+
# permissions:
209+
# contents: write # IMPORTANT: mandatory for making GitHub Releases
210210
steps:
211211
- uses: actions/checkout@v4
212+
with:
213+
fetch-depth: 0 # Fetch all history for all tags and branches
214+
tags: true # Fetch all tags as well, `fetch-depth: 0` might be sufficient depending on Git version
212215
- name: Download standalone Docker
213216
uses: actions/download-artifact@v3
214217
with:
@@ -219,23 +222,29 @@ jobs:
219222
- name: Unpack files
220223
run: |
221224
mkdir dist
222-
mv dist-docker-coq-dev/standalone.tar.gz dist/fiat-crypto-docker-coq-dev.tar.gz
225+
echo "::group::find arch"
226+
( cd dist-docker-coq-dev && tar -xzvf standalone.tar.gz )
227+
arch="$(etc/ci/find-arch.sh dist-docker-coq-dev/word_by_word_montgomery "unknown")"
228+
tag="$(git describe --tags HEAD)"
229+
fname="Fiat-Cryptography_${tag}_Linux_docker_dev_${arch}.tar.gz"
230+
echo "$fname"
231+
mv dist-docker-coq-dev/standalone.tar.gz "dist/$fname"
223232
find dist
224-
tar -tvf dist/fiat-crypto-docker-coq-dev.tar.gz
225-
- name: Upload artifacts to GitHub Release
226-
env:
227-
GITHUB_TOKEN: ${{ github.token }}
228-
# Upload to GitHub Release using the `gh` CLI.
229-
# `dist/` contains the built packages
230-
run: >-
231-
gh release upload
232-
'${{ github.ref_name }}' dist/**
233-
--repo '${{ github.repository }}'
234-
if: ${{ startsWith(github.ref, 'refs/tags/') && github.event_name == 'release' }}
233+
tar -tvf "dist/$fname"
234+
# - name: Upload artifacts to GitHub Release
235+
# env:
236+
# GITHUB_TOKEN: ${{ github.token }}
237+
# # Upload to GitHub Release using the `gh` CLI.
238+
# # `dist/` contains the built packages
239+
# run: >-
240+
# gh release upload
241+
# '${{ github.ref_name }}' dist/**
242+
# --repo '${{ github.repository }}'
243+
# if: ${{ startsWith(github.ref, 'refs/tags/') && github.event_name == 'release' }}
235244

236245
docker-check-all:
237246
runs-on: ubuntu-latest
238-
needs: [build, test-amd64, test-standalone, publish-standalone]
247+
needs: [build, test-amd64, test-standalone, publish-standalone-dry-run]
239248
if: always()
240249
steps:
241250
- run: echo 'build passed'
@@ -244,13 +253,13 @@ jobs:
244253
if: ${{ needs.test-amd64.result == 'success' }}
245254
- run: echo 'test-standalone passed'
246255
if: ${{ needs.test-standalone.result == 'success' }}
247-
- run: echo 'publish-standalone passed'
248-
if: ${{ needs.publish-standalone.result == 'success' }}
256+
- run: echo 'publish-standalone-dry-run passed'
257+
if: ${{ needs.publish-standalone-dry-run.result == 'success' }}
249258
- run: echo 'build failed' && false
250259
if: ${{ needs.build.result != 'success' }}
251260
- run: echo 'test-amd64 failed' && false
252261
if: ${{ needs.test-amd64.result != 'success' }}
253262
- run: echo 'test-standalone failed' && false
254263
if: ${{ needs.test-standalone.result != 'success' }}
255-
- run: echo 'publish-standalone failed' && false
256-
if: ${{ needs.publish-standalone.result != 'success' }}
264+
- run: echo 'publish-standalone-dry-run failed' && false
265+
if: ${{ needs.publish-standalone-dry-run.result != 'success' }}

.github/workflows/coq-macos.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ jobs:
149149
contents: write # IMPORTANT: mandatory for making GitHub Releases
150150
steps:
151151
- uses: actions/checkout@v4
152+
with:
153+
fetch-depth: 0 # Fetch all history for all tags and branches
154+
tags: true # Fetch all tags as well, `fetch-depth: 0` might be sufficient depending on Git version
152155
- name: Download standalone MacOS
153156
uses: actions/download-artifact@v3
154157
with:
@@ -159,9 +162,14 @@ jobs:
159162
- name: Unpack files
160163
run: |
161164
mkdir dist
162-
mv dist-macos/standalone.tar.gz dist/fiat-crypto-macos.tar.gz
165+
( cd dist-macos && tar -xzvf standalone.tar.gz )
166+
arch="$(etc/ci/find-arch.sh dist-macos/word_by_word_montgomery)"
167+
tag="$(git describe --tags HEAD)"
168+
fname="Fiat-Cryptography_${tag}_macOS_${arch}.tar.gz"
169+
echo "$fname"
170+
mv dist-macos/standalone.tar.gz "dist/$fname"
163171
find dist
164-
tar -tvf dist/fiat-crypto-macos.tar.gz
172+
tar -tvf "dist/$fname"
165173
- name: Upload artifacts to GitHub Release
166174
env:
167175
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/coq-windows.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ jobs:
175175
contents: write # IMPORTANT: mandatory for making GitHub Releases
176176
steps:
177177
- uses: actions/checkout@v4
178+
with:
179+
fetch-depth: 0 # Fetch all history for all tags and branches
180+
tags: true # Fetch all tags as well, `fetch-depth: 0` might be sufficient depending on Git version
178181
- name: Download standalone Windows
179182
uses: actions/download-artifact@v3
180183
with:
@@ -185,9 +188,14 @@ jobs:
185188
- name: Unpack files
186189
run: |
187190
mkdir dist
188-
mv dist-windows/standalone.zip dist/fiat-crypto-windows.zip
191+
( cd dist-windows && unzip standalone.zip )
192+
arch="$(etc/ci/find-arch.sh dist-windows/word_by_word_montgomery "x86_64")"
193+
tag="$(git describe --tags HEAD)"
194+
fname="Fiat-Cryptography_${tag}_Windows_${arch}.zip"
195+
echo "$fname"
196+
mv dist-windows/standalone.zip "dist/$fname"
189197
find dist
190-
unzip -l dist/fiat-crypto-windows.zip
198+
unzip -l "dist/$fname"
191199
- name: Upload artifacts to GitHub Release
192200
env:
193201
GITHUB_TOKEN: ${{ github.token }}

etc/ci/find-arch.sh

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
usage() {
4+
>&2 printf "%s FILENAME [DEFAULT_ARCH]\n" "$0"
5+
}
6+
7+
fname="$1"
8+
default="$2"
9+
if [ -z "$fname" ] || [ "$fname" = "-h" ] || [ "$fname" = "--help" ]; then
10+
usage
11+
fi
12+
if [ -z "$fname" ]; then
13+
exit 1
14+
fi
15+
16+
if [ ! -z "${SHELL}" ]; then
17+
run() {
18+
"${SHELL}" -c "$*" || true
19+
}
20+
else
21+
run() {
22+
/bin/sh -c "$*" || true
23+
}
24+
fi
25+
26+
if [ ! -z "$CI" ]; then
27+
group() {
28+
echo "::group::$*"
29+
run "$@"
30+
echo "::endgroup::"
31+
}
32+
else
33+
group() { run "$@"; }
34+
fi
35+
36+
>&2 group file "$fname"
37+
>&2 group otool -L "$fname" || true
38+
>&2 group lipo -info "$fname" || true
39+
file_info="$(file "$fname" 2>&1)"
40+
case "${file_info}" in
41+
*x86_64*|*x86-64*)
42+
arch=x86_64
43+
;;
44+
*)
45+
if [ -z "$default" ]; then
46+
arch="$(printf "%s\n" "${file_info}" | awk '{print $NF}')"
47+
else
48+
arch="$default"
49+
fi
50+
>&2 echo "::warning::Unknown architecture ${file_info} (using ${arch})"
51+
;;
52+
esac
53+
54+
printf "%s\n" "$arch"

0 commit comments

Comments
 (0)