-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (86 loc) · 2.96 KB
/
ci.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
name: CI
on:
push:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Check
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Toolchain
id: toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: "clippy, rustfmt"
- name: Cache
uses: actions/cache@v3
with:
path: |
target/
# https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-rustc-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/ci.yml', '.github/workflows/pr.yml') }}
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
if: success() || failure()
run: cargo clippy -- -D warnings
- name: Test
if: success() || failure()
run: cargo test
rel:
name: Create Release
needs: ["check"]
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Toolchain
id: toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-gnu
- name: Install Windows Cross Tools
run: |
sudo apt update
sudo apt install gcc-mingw-w64-x86-64-win32
- name: Cache
uses: actions/cache@v3
with:
path: |
target/
# https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-rustc-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/ci.yml') }}
- name: Version
id: version
run: |
echo "version=$(cargo metadata --format-version 1 | jq --raw-output '.packages[] | select(.name=="hanzo") | .version')" >> $GITHUB_OUTPUT
echo "sha=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
- name: Build
run: cargo build --release
- name: Build for Windows
run: cargo build --release --bin client --target x86_64-pc-windows-gnu --config target.x86_64-pc-windows-gnu.linker=\"x86_64-w64-mingw32-gcc-win32\" --config target.x86_64-pc-windows-gnu.ar=\"x86_64-w64-mingw32-ar-win32\"
- name: Create Release
id: create_release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: ${{ steps.version.outputs.version }}-${{ steps.version.outputs.sha }}
title: v${{ steps.version.outputs.version }}-${{ steps.version.outputs.sha }}
draft: true
prerelease: false
files: |
target/release/client
target/release/server
target/x86_64-pc-windows-gnu/release/client.exe