-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (89 loc) · 2.89 KB
/
Copy pathrust.yml
File metadata and controls
104 lines (89 loc) · 2.89 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
name: Rust
on:
push:
tags: [ "v*" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust components
run: rustup component add rustfmt clippy
- name: Check formatting
run: cargo fmt --check
- name: Run Clippy
run: cargo clippy --all-targets --all-features --locked -- -D warnings
- name: Build
run: cargo build --locked --verbose
- name: Run tests
run: cargo test --locked --verbose
create-release:
name: Create GitHub release
needs: test
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Create release if needed
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG_NAME: ${{ github.ref_name }}
run: |
gh release view "$TAG_NAME" >/dev/null 2>&1 || \
gh release create "$TAG_NAME" \
--title "$TAG_NAME" \
--notes "Automated release for $TAG_NAME"
release-binaries:
name: Build release binary (${{ matrix.target }})
needs: create-release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
asset_name: tidaload-linux-amd64
- target: aarch64-unknown-linux-gnu
asset_name: tidaload-linux-arm64
steps:
- uses: actions/checkout@v4
- name: Install Rust target
run: rustup target add ${{ matrix.target }}
- name: Install arm64 linker
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build release binary
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc
AR_aarch64_unknown_linux_gnu: aarch64-linux-gnu-ar
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Package binary
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/tidaload dist/${{ matrix.asset_name }}
chmod +x dist/${{ matrix.asset_name }}
tar -C dist -czf dist/${{ matrix.asset_name }}.tar.gz ${{ matrix.asset_name }}
sha256sum dist/${{ matrix.asset_name }}.tar.gz > dist/${{ matrix.asset_name }}.tar.gz.sha256
- name: Upload release assets
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG_NAME: ${{ github.ref_name }}
run: |
gh release upload "$TAG_NAME" \
dist/${{ matrix.asset_name }}.tar.gz \
dist/${{ matrix.asset_name }}.tar.gz.sha256 \
--clobber