-
Notifications
You must be signed in to change notification settings - Fork 20
131 lines (114 loc) · 4.29 KB
/
bolt_cli_release_bins.yml
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
name: Build and push Bolt CLI release binaries
on:
push:
tags:
- "v*" # Trigger when version tags are pushed (e.g. v0.3.1)
release:
types:
- created # Trigger when a release is created and immediately published
- published # Trigger when a release is published
workflow_dispatch: # allows manual triggering of the workflow
env:
CARGO_TERM_COLOR: always
PROFILE: release
jobs:
build-and-push:
name: ${{ matrix.target }} (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 240
strategy:
fail-fast: false
matrix:
include:
# `runner`: GHA runner label
# `target`: Rust build target triple
# `platform` and `arch`: Used in tarball names
- runner: Linux-20.04
target: x86_64-unknown-linux-gnu
platform: linux
arch: amd64
- runner: Linux-20.04
target: aarch64-unknown-linux-gnu
platform: linux
arch: arm64
- runner: macos-12-large
target: x86_64-apple-darwin
platform: darwin
arch: amd64
- runner: macos-latest-large
target: aarch64-apple-darwin
platform: darwin
arch: arm64
- runner: Windows
target: x86_64-pc-windows-msvc
platform: win32
arch: amd64
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Cross
run: |
cargo install cross --force
- name: Install Protoc
uses: arduino/setup-protoc@v3
- name: Apple M1 setup
if: matrix.target == 'aarch64-apple-darwin'
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Build binaries
env:
PLATFORM_NAME: ${{ matrix.platform }}
TARGET: ${{ matrix.target }}
OUT_DIR: bolt-cli/target/${{ matrix.target }}/${{ env.PROFILE }}
shell: bash
run: |
set -eo pipefail
# Install the toolchain if it's not already installed
rustup target add $TARGET || true
flags=(--target $TARGET --profile $PROFILE)
[[ "$TARGET" == *windows* ]] && ext=".exe"
(cd bolt-cli && cross build "${flags[@]}")
bin=$OUT_DIR/bolt$ext
echo ""
file "$bin" || true
du -h "$bin" || true
ldd "$bin" || true
$bin --version || true
- name: Archive binaries
id: artifacts
env:
PLATFORM_NAME: ${{ matrix.platform }}
OUT_DIR: bolt-cli/target/${{ matrix.target }}/${{ env.PROFILE }}
ARCH: ${{ matrix.arch }}
shell: bash
run: |
if [ "$PLATFORM_NAME" == "linux" ]; then
# Examples: "bolt-cli-amd64-darwin.tar.gz" or "bolt-cli-arm64-linux.tar.gz"
tar -czvf "bolt-cli-${ARCH}-${PLATFORM}.tar.gz" -C $OUT_DIR bolt
echo "file_name=bolt-cli-${ARCH}-${PLATFORM}.tar.gz" >> $GITHUB_OUTPUT
elif [ "$PLATFORM_NAME" == "darwin" ]; then
# We need to use gtar here otherwise the archive is corrupt.
# See: https://github.com/actions/virtual-environments/issues/2619
gtar -czvf "bolt-cli-${ARCH}-${PLATFORM}.tar.gz" -C $OUT_DIR bolt
echo "file_name=bolt-cli-${ARCH}-${PLATFORM}.tar.gz" >> $GITHUB_OUTPUT
else
cd $OUT_DIR
7z a -tzip "bolt-cli-${ARCH}-${PLATFORM}.zip" bolt.exe
mv "bolt-cli-${ARCH}-${PLATFORM}.zip" ../../../../
echo "file_name=bolt-cli-${ARCH}-${PLATFORM}.zip" >> $GITHUB_OUTPUT
fi
- name: Push updated binaries to the release
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.artifacts.outputs.file_name}}
asset_name: ${{ steps.artifacts.outputs.file_name}}
asset_content_type: application/zip