-
Notifications
You must be signed in to change notification settings - Fork 2
97 lines (83 loc) · 3.27 KB
/
Copy pathlinux.yml
File metadata and controls
97 lines (83 loc) · 3.27 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
name: Linux
on:
push:
branches: [main, "v[0-9]+.[0-9]+.[0-9]+"]
pull_request:
branches: [main, "v[0-9]+.[0-9]+.[0-9]+"]
release:
types:
- created
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.7
- name: Install fmt, clippy and nightly for the fmt
run: |
rustup component add rustfmt
rustup component add clippy
rustup toolchain install nightly
rustup component add --toolchain nightly rustfmt
- name: Run fmt
run: cargo +nightly fmt -- --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Build
run: cargo build --tests --verbose
- name: Run tests
run: cargo test --verbose
deploy:
needs: test
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
strategy:
matrix:
target: [i686-unknown-linux-gnu, x86_64-unknown-linux-gnu]
steps:
- uses: actions/checkout@v4.1.7
- id: "auth"
uses: google-github-actions/auth@v2.1.5
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: "Set up Cloud SDK"
uses: google-github-actions/setup-gcloud@v2.1.1
- name: Cache cargo registry and build artifacts
uses: actions/cache@v4
with:
path: |
~/.cargo-container/registry
~/.cargo-container/git
target
key: ${{ runner.os }}-release-cargo-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-release-cargo-${{ matrix.target }}-
# Build inside the official Rust image on Debian bullseye (glibc 2.31, the same floor
# as Ubuntu 20.04) so the binaries run on older systems and the toolchain ships in the
# image instead of being downloaded on every run. gcc-multilib provides the 32-bit
# toolchain for the i686 target; reqwest uses rustls-tls, so no OpenSSL is needed. The
# image tag pins the toolchain to the MSRV. Cargo caches are mounted in and ownership
# normalised afterwards so the cache and gsutil can read the root-owned tree.
- name: Cargo build
run: |
mkdir -p "$HOME/.cargo-container/registry" "$HOME/.cargo-container/git"
docker run --rm \
-v "$PWD":/w -w /w \
-v "$HOME/.cargo-container/registry":/usr/local/cargo/registry \
-v "$HOME/.cargo-container/git":/usr/local/cargo/git \
rust:1.88.0-bullseye bash -euo pipefail -c '
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y gcc-multilib
rustup target add ${{ matrix.target }}
cargo build -p tmc --release --verbose --target ${{ matrix.target }}
'
sudo chown -R "$(id -u):$(id -g)" target "$HOME/.cargo-container"
- name: Get the version
id: get_version
shell: bash
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
- name: Deploy
run: gsutil cp target/${{ matrix.target }}/release/tmc gs://${{ secrets.GCP_BUCKET }}/tmc-cli-rust/tmc-cli-rust-${{ matrix.target }}-${{ steps.get_version.outputs.VERSION }}