-
Notifications
You must be signed in to change notification settings - Fork 66
193 lines (162 loc) · 5.25 KB
/
rust.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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Rust
on:
push:
branches:
- 'main'
- 'dev'
paths-ignore:
- 'README.md'
- 'LICENSE'
pull_request:
branches:
- 'main'
- 'dev'
paths-ignore:
- 'README.md'
- 'LICENSE'
release:
types:
- 'prereleased'
- 'published'
- 'released'
# For test
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
RUST_BACKTRACE: 1
jobs:
build:
timeout-minutes: 30
env:
CARGO_TERM_COLOR: always
PROTOC_NO_VENDOR: true
name: '${{ matrix.config.name }}'
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Windows-x86_64", artifact: "Windows-x86_64",
os: windows-latest,
has_release: true,
rust: stable-x86_64-msvc,
target_triple: x86_64-pc-windows-msvc
}
- {
name: "Linux", artifact: "Linux-x86_64",
os: ubuntu-latest,
has_release: true,
rust: stable,
target_triple: x86_64-unknown-linux-gnu
}
- {
name: "macOS-x64", artifact: "macOS-x64",
os: macos-latest,
rust: stable,
has_release: true,
target_triple: x86_64-apple-darwin
}
steps:
- name: Set up NASM
uses: ilammy/[email protected]
- uses: actions/checkout@v4
- name: macOS - Build preparation - Install Packages
if: matrix.config.os == 'macos-latest'
run: |
brew install coreutils
- name: Install Rust (rustup)
run: rustup update ${{ matrix.config.rust }} --no-self-update && rustup default ${{ matrix.config.rust }}
shell: bash
- run: rustup target add ${{ matrix.config.target_triple }}
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Get rust version
id: rust-version
run: echo "version=$(rustc --version)" >> $GITHUB_OUTPUT
- name: Cache cargo index
uses: actions/[email protected]
with:
path: ~/.cargo/registry/index
key: index-${{ runner.os }}-${{ github.run_number }}
restore-keys: |
index-${{ runner.os }}-
# - name: Create lockfile
# run: cargo generate-lockfile
- name: Cache cargo registry
uses: actions/[email protected]
with:
path: ~/.cargo/registry/cache
key: registry-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
- name: Fetch dependencies
run: cargo fetch
- name: Cache target directory
uses: actions/[email protected]
with:
path: target
key: cache-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
- name: Build
shell: bash
run: |
cargo build --release --target=${{matrix.config.target_triple}}
- name: Run tests
shell: bash
run: |
cargo test --release --target=${{matrix.config.target_triple}}
- uses: robinraju/[email protected]
with:
repository: "v2fly/geoip"
latest: true
fileName: "geoip.dat"
token: ${{ secrets.GITHUB_TOKEN }}
- uses: robinraju/[email protected]
with:
repository: "v2fly/geoip"
latest: true
fileName: "geoip.dat.sha256sum"
token: ${{ secrets.GITHUB_TOKEN }}
- uses: robinraju/[email protected]
with:
repository: "v2fly/domain-list-community"
latest: true
fileName: "dlc.dat.sha256sum"
token: ${{ secrets.GITHUB_TOKEN }}
- uses: robinraju/[email protected]
with:
repository: "v2fly/domain-list-community"
latest: true
fileName: "dlc.dat"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Add geoip,geosite to release
shell: bash
run: |
mkdir release-tmp
cp ${GITHUB_WORKSPACE}/README.md ./release-tmp/README.md
cp ${GITHUB_WORKSPACE}/LICENSE ./release-tmp/LICENSE
cat dlc.dat.sha256sum | sha256sum --check --status
cat geoip.dat.sha256sum | sha256sum --check --status
mv dlc.dat ./release-tmp/geosite.dat
mv geoip.dat ./release-tmp/
cp ./target/${{matrix.config.target_triple}}/release/v2ray-rust ./release-tmp/
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3
with:
name: v2ray-rust-${{ github.sha }}-${{ matrix.config.artifact }}.7z
path: release-tmp
- name: Get the version
if: github.event_name == 'release' && matrix.config.has_release
id: get_version
run: echo VERSION=$(echo $GITHUB_REF | cut -d / -f 3) >> $GITHUB_OUTPUT
- name: Upload to GitHub Release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release' && matrix.config.has_release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: v2ray-rust.7z
asset_name: v2ray-rust-${{ steps.get_version.outputs.VERSION }}-${{ matrix.config.artifact }}.7z
tag: ${{ github.ref }}
overwrite: true