Skip to content

Commit 380d2d9

Browse files
author
share121
committed
feat: 初始化项目
1 parent 6a2fcf4 commit 380d2d9

File tree

9 files changed

+2703
-4
lines changed

9 files changed

+2703
-4
lines changed

.github/workflows/build.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build:
14+
name: build
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
build:
19+
- linux-arm64
20+
- linux-64bit
21+
- macos-arm64
22+
- macos-64bit
23+
- windows-64bit
24+
- windows-32bit
25+
- windows-arm64
26+
include:
27+
- build: linux-arm64
28+
os: ubuntu-22.04-arm
29+
target: aarch64-unknown-linux-musl
30+
archive-name: fast-down-linux-arm64
31+
- build: linux-64bit
32+
os: ubuntu-22.04
33+
target: x86_64-unknown-linux-musl
34+
archive-name: fast-down-linux-64bit
35+
- build: macos-arm64
36+
os: macos-13
37+
target: aarch64-apple-darwin
38+
archive-name: fast-down-macos-arm64
39+
- build: macos-64bit
40+
os: macos-13
41+
target: x86_64-apple-darwin
42+
archive-name: fast-down-macos-64bit
43+
- build: windows-64bit
44+
os: windows-2022
45+
target: x86_64-pc-windows-msvc
46+
archive-name: fast-down-windows-64bit
47+
- build: windows-32bit
48+
os: windows-2022
49+
target: i686-pc-windows-msvc
50+
archive-name: fast-down-windows-32bit
51+
- build: windows-arm64
52+
os: windows-11-arm
53+
target: aarch64-pc-windows-msvc
54+
archive-name: fast-down-windows-arm64
55+
fail-fast: false
56+
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
60+
61+
- name: Install Rust stable
62+
uses: dtolnay/rust-toolchain@stable
63+
with:
64+
targets: ${{ matrix.target }}
65+
66+
- name: Install dependencies (linux only)
67+
if: contains(matrix.build, 'linux')
68+
run: sudo apt-get install musl-tools
69+
70+
- name: Configure sccache-cache
71+
uses: mozilla-actions/[email protected]
72+
if: matrix.build != 'windows-arm64'
73+
- name: Set Rust Caching Env
74+
if: matrix.build != 'windows-arm64'
75+
run: |
76+
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
77+
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
78+
79+
- name: Build binary
80+
run: cargo build --verbose --release --target ${{ matrix.target }}
81+
env:
82+
RUST_BACKTRACE: 1
83+
84+
- name: Make output folder
85+
run: |
86+
mkdir fast-down
87+
cp config.toml fast-down
88+
89+
- name: Copy target to folder (Windows)
90+
if: contains(matrix.build, 'windows')
91+
run: cp target/${{ matrix.target }}/release/fast.exe fast-down
92+
93+
- name: Copy target to folder (Non-Windows)
94+
if: ${{ !contains(matrix.build, 'windows') }}
95+
run: cp target/${{ matrix.target }}/release/fast fast-down
96+
97+
- name: Upload archive
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: ${{ matrix.archive-name }}
101+
path: fast-down
102+
103+
- name: Create ZIP (Windows)
104+
if: contains(matrix.build, 'windows')
105+
run: Compress-Archive -Path fast-down -DestinationPath ${{ matrix.archive-name }}.zip
106+
107+
- name: Create ZIP (Non-Windows)
108+
if: ${{ !contains(matrix.build, 'windows') }}
109+
run: zip -r -9 ${{ matrix.archive-name }}.zip fast-down
110+
111+
- name: Release
112+
uses: softprops/action-gh-release@v2
113+
with:
114+
files: ${{ matrix.archive-name }}.zip

.github/workflows/test.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
check:
10+
name: Tests
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
channel:
15+
- stable
16+
- beta
17+
- nightly
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Install Rust Toolchain
24+
uses: dtolnay/rust-toolchain@stable
25+
with:
26+
toolchain: ${{ matrix.channel }}
27+
components: clippy
28+
29+
- name: Configure sccache-cache
30+
uses: mozilla-actions/[email protected]
31+
- name: Set Rust Caching Env
32+
run: |
33+
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
34+
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
35+
36+
- name: Test
37+
run: cargo test --all --verbose
38+
39+
- name: Build
40+
run: cargo build --all --verbose
41+
42+
- name: Clippy
43+
run: cargo clippy --all --verbose -- -Dwarnings
44+
45+
check-minimal:
46+
name: Check minimal versions
47+
runs-on: ubuntu-latest
48+
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v4
52+
53+
- name: Install Rust Toolchain
54+
uses: dtolnay/rust-toolchain@stable
55+
with:
56+
toolchain: nightly
57+
58+
- name: Configure sccache-cache
59+
uses: mozilla-actions/[email protected]
60+
- name: Set Rust Caching Env
61+
run: |
62+
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
63+
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
64+
65+
- name: Check minimal versions
66+
run: cargo check --all --all-targets -Z minimal-versions
67+
68+
format:
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout repository
72+
uses: actions/checkout@v4
73+
74+
- name: Install latest stable
75+
uses: dtolnay/rust-toolchain@stable
76+
with:
77+
toolchain: stable
78+
components: rustfmt
79+
80+
- name: Run rustfmt
81+
run: cargo fmt --all -- --check

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/target
2+
3+
.idea

0 commit comments

Comments
 (0)