-
Notifications
You must be signed in to change notification settings - Fork 37
87 lines (75 loc) · 2.73 KB
/
Copy pathRelease.yml
File metadata and controls
87 lines (75 loc) · 2.73 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Run tests
run: cargo test --release
- name: Build release
run: cargo build --release
- name: Set binary extension
id: set-ext
run: |
if [ "${{ runner.os }}" == "Windows" ]; then
echo "extension=.exe" >> $GITHUB_OUTPUT
echo "binary_path=target/release/binance_l3_est.exe" >> $GITHUB_OUTPUT
else
echo "extension=" >> $GITHUB_OUTPUT
echo "binary_path=target/release/binance_l3_est" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Rename binary (non-Windows)
if: runner.os != 'Windows'
run: |
mv -f ${{ steps.set-ext.outputs.binary_path }} target/release/binance_l3_est-${{ runner.os }}-${{ runner.arch }}${{ steps.set-ext.outputs.extension }}
shell: bash
- name: Rename binary (Windows)
if: runner.os == 'Windows'
run: |
$dest = "target/release/binance_l3_est-${{ runner.os }}-${{ runner.arch }}${{ steps.set-ext.outputs.extension }}"
if (Test-Path $dest) { Remove-Item $dest -Force }
Rename-Item -Path "${{ steps.set-ext.outputs.binary_path }}" -NewName "binance_l3_est-${{ runner.os }}-${{ runner.arch }}${{ steps.set-ext.outputs.extension }}"
shell: pwsh
- name: Upload binaries as artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ runner.os }}
path: target/release/binance_l3_est-${{ runner.os }}-${{ runner.arch }}${{ steps.set-ext.outputs.extension }}
- name: Create and upload release assets
if: github.event_name == 'push'
uses: softprops/action-gh-release@v2
with:
files: target/release/binance_l3_est-${{ runner.os }}-${{ runner.arch }}${{ steps.set-ext.outputs.extension }}
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}