-
Notifications
You must be signed in to change notification settings - Fork 68
103 lines (98 loc) · 2.81 KB
/
ci.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
name: Build/Test/Release
on:
push:
branches: [ "master" ]
tags:
- v*
pull_request:
branches: [ "master" ]
jobs:
test:
name: test on ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-13]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v4
with:
go-version: '1.20'
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
# https://github.com/bazelbuild/rules_rust/issues/1966
# maybe we should not use bazel anymore
# - run: CARGO_BAZEL_ISOLATED=0 CARGO_BAZEL_REPIN=true bazelisk test --test_output=all //clash_lib/... //clash/...
- uses: Swatinem/rust-cache@v2
- run: cargo test --all --all-features
release:
name: Create Github Release
if: contains(github.ref, 'tags/v')
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Output Release URL File
run: echo "${{ steps.create_release.outputs.id }}" > release_id.txt
- name: Save Release URL File for publish
uses: actions/upload-artifact@v3
with:
name: release_id
path: release_id.txt
publish:
if: contains(github.ref, 'tags/v')
needs: [test, release]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-13]
include:
- os: ubuntu-22.04
targets: >
x86_64-unknown-linux-gnu
# aarch64-unknown-linux-gnu
- os: macos-13
targets: >
aarch64-apple-darwin
x86_64-apple-darwin
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Load Release URL File from release job
uses: actions/download-artifact@v3
with:
path: release_id
name: release_id
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Build
run: sh ./scripts/build.sh "${{ matrix.targets }}"
- name: Get Release Upload URL
id: get_release_info
run: |
value=`cat release_id/release_id.txt`
echo "upload_id=$value" >> $GITHUB_OUTPUT
env:
TAG_REF_NAME: ${{ github.ref }}
REPOSITORY_NAME: ${{ github.repository }}
- name: Upload Release Asset
id: upload-release-asset
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.get_release_info.outputs.upload_id }}
assets_path: target/artifacts