-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (129 loc) · 4.1 KB
/
Copy pathcli.yml
File metadata and controls
152 lines (129 loc) · 4.1 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Release CLI
on:
push:
tags:
- "v*.*.*"
env:
CARGO_TERM_COLOR: always
BINARY_NAME: cdn
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2.7.7
with:
env-vars: "CARGO RUST"
cache-on-failure: true
- name: lint
run: cargo clippy
build-and-release:
name: Build and Release
runs-on: ${{ matrix.os }}
needs: [lint]
strategy:
matrix:
include:
# linux x64
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: cdn
asset_name: cdn-linux-amd64
# linux arm
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact_name: cdn
asset_name: cdn-linux-arm
# windows x64
- os: windows-latest
target: x86_64-pc-windows-gnu
artifact_name: cdn.exe
asset_name: cdn-windows-amd64.exe
# windows arm
- os: windows-latest
target: aarch64-pc-windows-msvc
artifact_name: cdn.exe
asset_name: cdn-windows-arm.exe
# macos x64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: cdn
asset_name: cdn-macos-amd64
# macos arm
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: cdn
asset_name: cdn-macos-arm
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: rustup toolchain install stable --profile minimal
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: Install Linux ARM dependencies
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Set linker for Linux ARM
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
- uses: Swatinem/rust-cache@v2
with:
prefix-key: "v0-rust"
shared-key: "${{ matrix.target }}"
cache-on-failure: "true"
cache-all-crates: "true"
workspaces: |
. -> target
cache-targets: "true"
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}
- name: Prepare artifact
shell: bash
run: |
mkdir -p artifacts
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "artifacts/${{ matrix.asset_name }}"
else
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "artifacts/${{ matrix.asset_name }}"
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: artifacts/${{ matrix.asset_name }}
create-release:
needs: build-and-release
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
files: |
cdn-linux-amd64/cdn-linux-amd64
cdn-windows-amd64.exe/cdn-windows-amd64.exe
cdn-macos-amd64/cdn-macos-amd64
cdn-linux-arm/cdn-linux-arm
cdn-windows-arm.exe/cdn-windows-arm.exe
cdn-macos-arm/cdn-macos-arm
draft: false
prerelease: false
generate_release_notes: true
append_bode: true
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}