-
Notifications
You must be signed in to change notification settings - Fork 1
263 lines (258 loc) · 13.9 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
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# GENERATED BY ./ci.generate.ts -- DO NOT DIRECTLY EDIT
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- '*'
concurrency:
group: '${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}'
cancel-in-progress: true
jobs:
build:
name: '${{ matrix.config.target }}'
runs-on: '${{ matrix.config.os }}'
strategy:
matrix:
config:
- os: macos-12
run_tests: 'true'
target: x86_64-apple-darwin
- os: macos-latest
run_tests: 'true'
target: aarch64-apple-darwin
- os: windows-latest
run_tests: 'true'
target: x86_64-pc-windows-msvc
- os: ubuntu-20.04
run_tests: 'true'
target: x86_64-unknown-linux-gnu
- os: ubuntu-20.04
run_tests: 'false'
target: x86_64-unknown-linux-musl
- os: ubuntu-20.04
run_tests: 'false'
target: aarch64-unknown-linux-gnu
- os: ubuntu-20.04
run_tests: 'false'
target: aarch64-unknown-linux-musl
outputs:
ZIP_CHECKSUM_X86_64_APPLE_DARWIN: '${{steps.pre_release_x86_64_apple_darwin.outputs.ZIP_CHECKSUM}}'
ZIP_CHECKSUM_AARCH64_APPLE_DARWIN: '${{steps.pre_release_aarch64_apple_darwin.outputs.ZIP_CHECKSUM}}'
ZIP_CHECKSUM_X86_64_PC_WINDOWS_MSVC: '${{steps.pre_release_x86_64_pc_windows_msvc.outputs.ZIP_CHECKSUM}}'
ZIP_CHECKSUM_X86_64_UNKNOWN_LINUX_GNU: '${{steps.pre_release_x86_64_unknown_linux_gnu.outputs.ZIP_CHECKSUM}}'
ZIP_CHECKSUM_X86_64_UNKNOWN_LINUX_MUSL: '${{steps.pre_release_x86_64_unknown_linux_musl.outputs.ZIP_CHECKSUM}}'
ZIP_CHECKSUM_AARCH64_UNKNOWN_LINUX_GNU: '${{steps.pre_release_aarch64_unknown_linux_gnu.outputs.ZIP_CHECKSUM}}'
ZIP_CHECKSUM_AARCH64_UNKNOWN_LINUX_MUSL: '${{steps.pre_release_aarch64_unknown_linux_musl.outputs.ZIP_CHECKSUM}}'
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: full
steps:
- uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- name: Cache cargo
if: 'startsWith(github.ref, ''refs/tags/'') != true'
uses: Swatinem/rust-cache@v2
- uses: denoland/setup-deno@v1
- name: Setup (Linux x86_64-musl)
if: matrix.config.target == 'x86_64-unknown-linux-musl'
run: |-
sudo apt update
sudo apt install musl musl-dev musl-tools
rustup target add x86_64-unknown-linux-musl
- name: Setup (Linux aarch64)
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |-
sudo apt update
sudo apt install -y gcc-aarch64-linux-gnu
rustup target add aarch64-unknown-linux-gnu
- name: Setup (Linux aarch64-musl)
if: matrix.config.target == 'aarch64-unknown-linux-musl'
run: |-
sudo apt update
sudo apt install gcc-aarch64-linux-gnu
sudo apt install musl musl-dev musl-tools
rustup target add aarch64-unknown-linux-musl
- name: Build (Debug)
if: '!startsWith(github.ref, ''refs/tags/'')'
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
run: 'cargo build --locked --all-targets --target ${{matrix.config.target}}'
- name: Build release
if: 'startsWith(github.ref, ''refs/tags/'')'
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
run: 'cargo build --locked --all-targets --target ${{matrix.config.target}} --release'
- name: Lint
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.config.target == ''x86_64-unknown-linux-gnu'''
run: cargo clippy
- name: Test (Debug)
if: 'matrix.config.run_tests == ''true'' && !startsWith(github.ref, ''refs/tags/'')'
run: cargo test --locked --all-features
- name: Test (Release)
if: 'matrix.config.run_tests == ''true'' && startsWith(github.ref, ''refs/tags/'')'
run: cargo test --locked --all-features --release
- name: Pre-release (x86_64-apple-darwin)
id: pre_release_x86_64_apple_darwin
if: 'matrix.config.target == ''x86_64-apple-darwin'' && startsWith(github.ref, ''refs/tags/'')'
run: |-
cd target/x86_64-apple-darwin/release
zip -r dprint-plugin-exec-x86_64-apple-darwin.zip dprint-plugin-exec
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-exec-x86_64-apple-darwin.zip | awk '{print $1}')"
- name: Pre-release (aarch64-apple-darwin)
id: pre_release_aarch64_apple_darwin
if: 'matrix.config.target == ''aarch64-apple-darwin'' && startsWith(github.ref, ''refs/tags/'')'
run: |-
cd target/aarch64-apple-darwin/release
zip -r dprint-plugin-exec-aarch64-apple-darwin.zip dprint-plugin-exec
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-exec-aarch64-apple-darwin.zip | awk '{print $1}')"
- name: Pre-release (x86_64-pc-windows-msvc)
id: pre_release_x86_64_pc_windows_msvc
if: 'matrix.config.target == ''x86_64-pc-windows-msvc'' && startsWith(github.ref, ''refs/tags/'')'
run: |-
Compress-Archive -CompressionLevel Optimal -Force -Path target/x86_64-pc-windows-msvc/release/dprint-plugin-exec.exe -DestinationPath target/x86_64-pc-windows-msvc/release/dprint-plugin-exec-x86_64-pc-windows-msvc.zip
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 target/x86_64-pc-windows-msvc/release/dprint-plugin-exec-x86_64-pc-windows-msvc.zip | awk '{print $1}')"
- name: Pre-release (x86_64-unknown-linux-gnu)
id: pre_release_x86_64_unknown_linux_gnu
if: 'matrix.config.target == ''x86_64-unknown-linux-gnu'' && startsWith(github.ref, ''refs/tags/'')'
run: |-
cd target/x86_64-unknown-linux-gnu/release
zip -r dprint-plugin-exec-x86_64-unknown-linux-gnu.zip dprint-plugin-exec
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-exec-x86_64-unknown-linux-gnu.zip | awk '{print $1}')"
- name: Pre-release (x86_64-unknown-linux-musl)
id: pre_release_x86_64_unknown_linux_musl
if: 'matrix.config.target == ''x86_64-unknown-linux-musl'' && startsWith(github.ref, ''refs/tags/'')'
run: |-
cd target/x86_64-unknown-linux-musl/release
zip -r dprint-plugin-exec-x86_64-unknown-linux-musl.zip dprint-plugin-exec
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-exec-x86_64-unknown-linux-musl.zip | awk '{print $1}')"
- name: Pre-release (aarch64-unknown-linux-gnu)
id: pre_release_aarch64_unknown_linux_gnu
if: 'matrix.config.target == ''aarch64-unknown-linux-gnu'' && startsWith(github.ref, ''refs/tags/'')'
run: |-
cd target/aarch64-unknown-linux-gnu/release
zip -r dprint-plugin-exec-aarch64-unknown-linux-gnu.zip dprint-plugin-exec
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-exec-aarch64-unknown-linux-gnu.zip | awk '{print $1}')"
- name: Pre-release (aarch64-unknown-linux-musl)
id: pre_release_aarch64_unknown_linux_musl
if: 'matrix.config.target == ''aarch64-unknown-linux-musl'' && startsWith(github.ref, ''refs/tags/'')'
run: |-
cd target/aarch64-unknown-linux-musl/release
zip -r dprint-plugin-exec-aarch64-unknown-linux-musl.zip dprint-plugin-exec
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-exec-aarch64-unknown-linux-musl.zip | awk '{print $1}')"
- name: Upload artifacts (x86_64-apple-darwin)
if: 'matrix.config.target == ''x86_64-apple-darwin'' && startsWith(github.ref, ''refs/tags/'')'
uses: actions/upload-artifact@v2
with:
name: x86_64-apple-darwin-artifacts
path: target/x86_64-apple-darwin/release/dprint-plugin-exec-x86_64-apple-darwin.zip
- name: Upload artifacts (aarch64-apple-darwin)
if: 'matrix.config.target == ''aarch64-apple-darwin'' && startsWith(github.ref, ''refs/tags/'')'
uses: actions/upload-artifact@v2
with:
name: aarch64-apple-darwin-artifacts
path: target/aarch64-apple-darwin/release/dprint-plugin-exec-aarch64-apple-darwin.zip
- name: Upload artifacts (x86_64-pc-windows-msvc)
if: 'matrix.config.target == ''x86_64-pc-windows-msvc'' && startsWith(github.ref, ''refs/tags/'')'
uses: actions/upload-artifact@v2
with:
name: x86_64-pc-windows-msvc-artifacts
path: target/x86_64-pc-windows-msvc/release/dprint-plugin-exec-x86_64-pc-windows-msvc.zip
- name: Upload artifacts (x86_64-unknown-linux-gnu)
if: 'matrix.config.target == ''x86_64-unknown-linux-gnu'' && startsWith(github.ref, ''refs/tags/'')'
uses: actions/upload-artifact@v2
with:
name: x86_64-unknown-linux-gnu-artifacts
path: target/x86_64-unknown-linux-gnu/release/dprint-plugin-exec-x86_64-unknown-linux-gnu.zip
- name: Upload artifacts (x86_64-unknown-linux-musl)
if: 'matrix.config.target == ''x86_64-unknown-linux-musl'' && startsWith(github.ref, ''refs/tags/'')'
uses: actions/upload-artifact@v2
with:
name: x86_64-unknown-linux-musl-artifacts
path: target/x86_64-unknown-linux-musl/release/dprint-plugin-exec-x86_64-unknown-linux-musl.zip
- name: Upload artifacts (aarch64-unknown-linux-gnu)
if: 'matrix.config.target == ''aarch64-unknown-linux-gnu'' && startsWith(github.ref, ''refs/tags/'')'
uses: actions/upload-artifact@v2
with:
name: aarch64-unknown-linux-gnu-artifacts
path: target/aarch64-unknown-linux-gnu/release/dprint-plugin-exec-aarch64-unknown-linux-gnu.zip
- name: Upload artifacts (aarch64-unknown-linux-musl)
if: 'matrix.config.target == ''aarch64-unknown-linux-musl'' && startsWith(github.ref, ''refs/tags/'')'
uses: actions/upload-artifact@v2
with:
name: aarch64-unknown-linux-musl-artifacts
path: target/aarch64-unknown-linux-musl/release/dprint-plugin-exec-aarch64-unknown-linux-musl.zip
draft_release:
name: draft_release
if: 'startsWith(github.ref, ''refs/tags/'')'
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
- uses: denoland/setup-deno@v1
- name: Move downloaded artifacts to root directory
run: |-
mv x86_64-apple-darwin-artifacts/dprint-plugin-exec-x86_64-apple-darwin.zip .
mv aarch64-apple-darwin-artifacts/dprint-plugin-exec-aarch64-apple-darwin.zip .
mv x86_64-pc-windows-msvc-artifacts/dprint-plugin-exec-x86_64-pc-windows-msvc.zip .
mv x86_64-unknown-linux-gnu-artifacts/dprint-plugin-exec-x86_64-unknown-linux-gnu.zip .
mv x86_64-unknown-linux-musl-artifacts/dprint-plugin-exec-x86_64-unknown-linux-musl.zip .
mv aarch64-unknown-linux-gnu-artifacts/dprint-plugin-exec-aarch64-unknown-linux-gnu.zip .
mv aarch64-unknown-linux-musl-artifacts/dprint-plugin-exec-aarch64-unknown-linux-musl.zip .
- name: Output checksums
run: |-
echo "dprint-plugin-exec-x86_64-apple-darwin.zip: ${{needs.build.outputs.ZIP_CHECKSUM_X86_64_APPLE_DARWIN}}"
echo "dprint-plugin-exec-aarch64-apple-darwin.zip: ${{needs.build.outputs.ZIP_CHECKSUM_AARCH64_APPLE_DARWIN}}"
echo "dprint-plugin-exec-x86_64-pc-windows-msvc.zip: ${{needs.build.outputs.ZIP_CHECKSUM_X86_64_PC_WINDOWS_MSVC}}"
echo "dprint-plugin-exec-x86_64-unknown-linux-gnu.zip: ${{needs.build.outputs.ZIP_CHECKSUM_X86_64_UNKNOWN_LINUX_GNU}}"
echo "dprint-plugin-exec-x86_64-unknown-linux-musl.zip: ${{needs.build.outputs.ZIP_CHECKSUM_X86_64_UNKNOWN_LINUX_MUSL}}"
echo "dprint-plugin-exec-aarch64-unknown-linux-gnu.zip: ${{needs.build.outputs.ZIP_CHECKSUM_AARCH64_UNKNOWN_LINUX_GNU}}"
echo "dprint-plugin-exec-aarch64-unknown-linux-musl.zip: ${{needs.build.outputs.ZIP_CHECKSUM_AARCH64_UNKNOWN_LINUX_MUSL}}"
- name: Create plugin file
run: deno run --allow-read=. --allow-write=. scripts/create_plugin_file.ts
- name: Get tag version
id: get_tag_version
run: 'echo ::set-output name=TAG_VERSION::${GITHUB_REF/refs\/tags\//}'
- name: Get plugin file checksum
id: get_plugin_file_checksum
run: 'echo "::set-output name=CHECKSUM::$(shasum -a 256 plugin.json | awk ''{print $1}'')"'
- name: Update Config Schema Version
run: 'sed -i ''s/exec\/0.0.0/exec\/${{ steps.get_tag_version.outputs.TAG_VERSION }}/'' deployment/schema.json'
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
with:
files: |-
dprint-plugin-exec-x86_64-apple-darwin.zip
dprint-plugin-exec-aarch64-apple-darwin.zip
dprint-plugin-exec-x86_64-pc-windows-msvc.zip
dprint-plugin-exec-x86_64-unknown-linux-gnu.zip
dprint-plugin-exec-x86_64-unknown-linux-musl.zip
dprint-plugin-exec-aarch64-unknown-linux-gnu.zip
dprint-plugin-exec-aarch64-unknown-linux-musl.zip
plugin.json
deployment/schema.json
body: |-
## Install
Dependencies:
- Install dprint's CLI >= 0.40.0
In a dprint configuration file:
1. Specify the plugin url and checksum in the `"plugins"` array or run `dprint config add exec`:
```jsonc
{
// etc...
"plugins": [
"https://plugins.dprint.dev/exec-${{ steps.get_tag_version.outputs.TAG_VERSION }}.json@${{ steps.get_plugin_file_checksum.outputs.CHECKSUM }}"
]
}
```
2. Follow the configuration setup instructions found at https://github.com/dprint/dprint-plugin-exec#configuration
draft: false