-
Notifications
You must be signed in to change notification settings - Fork 8
202 lines (172 loc) · 7 KB
/
release.yaml
File metadata and controls
202 lines (172 loc) · 7 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
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
# Release Process for the autonomy command:
#
# 1. Run this workflow (optionally provide a commit SHA, otherwise uses default branch HEAD)
# 2. Mark the draft release as a pre-release
# 3. Test with:
# curl -sSfL autonomy.computer/install | bash -s -- --version v0.159.0 && . "$HOME/.autonomy/env"
# 4. Mark the release as latest
name: Release
permissions:
contents: write
on:
workflow_dispatch:
inputs:
commit_sha:
description: Git commit sha, on which, to run this workflow
defaults:
run:
shell: bash
jobs:
build_and_test:
name: Build and Test Binaries
strategy:
matrix:
include:
- target: aarch64-apple-darwin
host_operating_system: macos-14
use_cross: false
test_method: native
- target: x86_64-apple-darwin
host_operating_system: macos-14
use_cross: false
test_method: native
- target: x86_64-unknown-linux-gnu
host_operating_system: ubuntu-22.04
use_cross: false
test_method: native
- target: x86_64-unknown-linux-musl
host_operating_system: ubuntu-22.04
use_cross: true
test_method: native
- target: aarch64-unknown-linux-gnu
host_operating_system: ubuntu-22.04
use_cross: true
test_method: qemu
qemu_architecture: aarch64
- target: aarch64-unknown-linux-musl
host_operating_system: ubuntu-22.04
use_cross: true
test_method: qemu
qemu_architecture: aarch64
- target: armv7-unknown-linux-musleabihf
host_operating_system: ubuntu-22.04
use_cross: true
test_method: qemu
qemu_architecture: arm
runs-on: ${{ matrix.host_operating_system }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ github.event.inputs.commit_sha }}
- name: Setup rust toolchain
run: |
rustup show
rustup target add ${{ matrix.target }}
- name: Install build dependencies
if: matrix.host_operating_system == 'ubuntu-22.04'
run: |
set -x
if [ "${{ matrix.use_cross }}" == "true" ]; then
cargo install cross --git https://github.com/cross-rs/cross
else
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
gcc g++ libclang-dev xz-utils liblz4-tool musl-tools
fi
if [ "${{ matrix.test_method }}" == "qemu" ]; then
sudo apt-get update
sudo apt-get install -y qemu-user-static
# Install libraries needed for QEMU to properly execute dynamically
# linked binaries for the target architectures.
if [ "${{ matrix.qemu_architecture }}" == "aarch64" ]; then
sudo apt-get install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross
elif [ "${{ matrix.qemu_architecture }}" == "arm" ]; then
sudo apt-get install -y gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
fi
fi
- name: Build binaryc
run: |
set -ex
cd source/rust/autonomy_command
# Build the compile tool first (natively for the host)
# This must be done before setting RUSTFLAGS=+crt-static to avoid
# the Rust compiler bug where proc-macros cannot be built with static
# linking https://github.com/rust-lang/rust/issues/78210
cargo build --bin compile
# Set RUSTFLAGS for musl targets only when building the target binary
# The compile tool will use these flags when building the final autonomy binary
if [[ "${{ matrix.target }}" =~ .+-musl(.+)? ]]; then
export RUSTFLAGS='-C target-feature=+crt-static'
fi
# Use the compile tool to build the target binary
if [ "${{ matrix.use_cross }}" == "true" ]; then
./target/debug/compile --configuration compile.yaml \
--target ${{ matrix.target }} --use-cross --release
else
./target/debug/compile --configuration compile.yaml \
--target ${{ matrix.target }} --release
fi
BINARY_PATH="./target/${{ matrix.target }}/release/autonomy"
chmod +x "$BINARY_PATH"
if [ "${{ matrix.test_method }}" == "qemu" ]; then
if [ "${{ matrix.qemu_architecture }}" == "aarch64" ]; then
QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-${{ matrix.qemu_architecture }}-static "$BINARY_PATH" --version
elif [ "${{ matrix.qemu_architecture }}" == "arm" ]; then
QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf qemu-${{ matrix.qemu_architecture }}-static "$BINARY_PATH" --version
else
qemu-${{ matrix.qemu_architecture }}-static "$BINARY_PATH" --version
fi
else
"$BINARY_PATH" --version
fi
- name: Upload binary artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: autonomy.${{ matrix.target }}
path: source/rust/autonomy_command/target/${{ matrix.target }}/release/autonomy
if-no-files-found: error
compression-level: 0
create_release:
name: Create Release
needs: build_and_test
runs-on: ubuntu-22.04
if: github.event_name == 'workflow_dispatch'
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ github.event.inputs.commit_sha }}
- name: Download all artifacts
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
with:
path: artifacts
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -ex
VERSION=$(grep '^version = ' source/rust/autonomy_command/Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
RELEASE_TAG="v$VERSION"
RELEASE_NAME="Release v$VERSION"
COMMIT_SHA="${{ github.event.inputs.commit_sha || github.sha }}"
RELEASE_BODY="Release v$VERSION"
gh release create "$RELEASE_TAG" \
--title "$RELEASE_NAME" \
--notes "$RELEASE_BODY" \
--target "$COMMIT_SHA" \
--draft
for artifact_dir in artifacts/autonomy.*; do
if [ -d "$artifact_dir" ]; then
target=$(basename "$artifact_dir" | sed 's/autonomy\.//')
for binary_file in "$artifact_dir"/*; do
if [ -f "$binary_file" ]; then
asset_name="autonomy-${target}"
# Copy binary with the target-specific name
cp "$binary_file" "$asset_name"
echo "Uploading $asset_name"
gh release upload "$RELEASE_TAG" "$asset_name"
fi
done
fi
done