-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (76 loc) · 2.2 KB
/
build.yml
File metadata and controls
88 lines (76 loc) · 2.2 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
name: Build and Test
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable, 1.80.0]
fail-fast: false
max-parallel: 2
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- name: Rust Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-rust-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rust-${{ matrix.rust }}-
${{ runner.os }}-rust-
- name: Check formatting
run: cargo fmt --all -- --check
continue-on-error: true
- name: Run clippy
run: cargo clippy -- -D warnings
continue-on-error: true
- name: Build project
run: cargo build --release
timeout-minutes: 20
if: always()
- name: Run tests
run: cargo test --release
timeout-minutes: 30
if: success()
- name: Create dist directory
run: mkdir -p dist
shell: bash
- name: Package binary
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
cp target/release/treegen.exe LICENSE README.md dist/
7z a "treegen-${RUNNER_OS}-${GITHUB_SHA}.zip" ./dist/*
else
cp target/release/treegen LICENSE README.md dist/
tar -czvf "treegen-${RUNNER_OS}-${GITHUB_SHA}.tar.gz" dist/
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
if: success()
with:
name: treegen-${{ runner.os }}-${{ matrix.rust }}-${{ github.sha }}
path: |
treegen-*.tar.gz
treegen-*.zip
retention-days: 5