-
-
Notifications
You must be signed in to change notification settings - Fork 8
166 lines (141 loc) · 4.98 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
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@v4
- uses: Swatinem/rust-cache@v2
- name: Install latest stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
components: rustfmt,clippy
- name: Run rustfmt
run: cargo fmt --all --check
- name: Run clippy
uses: giraffate/clippy-action@v1
with:
reporter: 'github-pr-check'
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
run: cargo test --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:
- cargo: cargo
artifact: ghr
- target: x86_64-pc-windows-msvc
host: windows-2022
artifact: ghr.exe
- target: x86_64-apple-darwin
host: macos-12
- target: aarch64-apple-darwin
host: macos-12
- target: x86_64-unknown-linux-gnu
host: ubuntu-22.04
- target: aarch64-unknown-linux-gnu
host: ubuntu-22.04
cargo: cross
runs-on: ${{ matrix.host }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install latest stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: ${{ matrix.cargo == 'cross' }}
run: |
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo-binstall -y cross
- id: cache-key
run: echo "key=$(echo '${{ toJSON(matrix) }}' | shasum -a 256)" >> $GITHUB_OUTPUT
- uses: Swatinem/rust-cache@v2
with:
key: ${{ steps.cache-key.outputs.key }}
- name: Build
run: ${{ matrix.cargo }} build --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@v4
with:
name: ghr-${{ matrix.target }}
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@v4
- uses: Swatinem/rust-cache@v2
- name: Install latest stable
uses: dtolnay/rust-toolchain@stable
- name: Log into crates.io
run: cargo login '${{ secrets.CRATES_IO_TOKEN }}
- name: Publish to crates.io
run: cargo publish --allow-dirty
brew:
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'release' }}
needs:
- build
steps:
- uses: actions/checkout@v4
- name: Release to Homebrew Tap
uses: siketyan/release-to-registry-action@7e2a91ef78e61dccdb2e8b9401ae54ec58fab4fc
with:
path: 'Formula/ghr.rb'
assets: |-
macos_x86_64=ghr-x86_64-apple-darwin.tar.gz
macos_aarch64=ghr-aarch64-apple-darwin.tar.gz
linux_x86_64=ghr-x86_64-unknown-linux-gnu.tar.gz
linux_aarch64=ghr-aarch64-unknown-linux-gnu.tar.gz
message: 'feat(ghr): Release ${{ github.event.release.tag_name }}'
template: './resources/formula/ghr.rb.mustache'
token: '${{ secrets.HOMEBREW_TAP_TOKEN }}'
hash: 'sha256'
targetRepo: 'homebrew-tap'
branch: 'ghr/${{ github.event.release.tag_name }}'
author: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'
committer: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'
- name: Release to Scoop Bucket
uses: siketyan/release-to-registry-action@7e2a91ef78e61dccdb2e8b9401ae54ec58fab4fc
with:
path: 'ghr.json'
assets: |-
windows_x86_64=ghr-x86_64-pc-windows-msvc.tar.gz
message: 'feat(ghr): Release ${{ github.event.release.tag_name }}'
template: './resources/scoop/ghr.json.mustache'
token: '${{ secrets.SCOOP_BUCKET_TOKEN }}'
hash: 'sha256'
targetRepo: 'scoop-bucket'
branch: 'ghr/${{ github.event.release.tag_name }}'
author: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'
committer: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'