-
-
Notifications
You must be signed in to change notification settings - Fork 8
140 lines (119 loc) · 3.32 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
name: Rust
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- published
env:
CARGO_TERM_COLOR: always
jobs:
checks:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt,clippy
- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ github.token }}
args: --all-features
- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --check
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
build:
strategy:
matrix:
target:
- x86_64-pc-windows-msvc
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
include:
- target: x86_64-pc-windows-msvc
host: windows-2022
artifact: ghr.exe
- target: x86_64-apple-darwin
host: macos-12
artifact: ghr
- target: aarch64-apple-darwin
host: macos-12
artifact: ghr
- target: x86_64-unknown-linux-gnu
host: ubuntu-22.04
artifact: ghr
- target: aarch64-unknown-linux-gnu
host: ubuntu-22.04
artifact: ghr
runs-on: ${{ matrix.host }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
target: ${{ matrix.target }}
- id: cache-key
run: echo "::set-output name=key::$(echo '${{ toJSON(matrix) }}' | shasum -a 256)"
- uses: Swatinem/rust-cache@v2
with:
key: ${{ steps.cache-key.outputs.key }}
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --features vendored --target '${{ matrix.target }}'
- name: Compress artifacts into .tar.gz file
run: tar -C ./target/${{ matrix.target }}/release -czf ghr-${{ matrix.target }}.tar.gz ${{ matrix.artifact }}
- uses: actions/upload-artifact@v3
with:
path: ghr-${{ matrix.target }}.tar.gz
- uses: svenstaro/upload-release-action@v2
if: ${{ github.event_name == 'release' }}
with:
file: ghr-${{ matrix.target }}.tar.gz
overwrite: true
deploy:
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'release' }}
needs:
- checks
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Log into crates.io
uses: actions-rs/cargo@v1
with:
command: login
args: ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish to crates.io
uses: actions-rs/cargo@v1
with:
command: publish
args: --allow-dirty