forked from chaaz/versio
-
Notifications
You must be signed in to change notification settings - Fork 0
299 lines (299 loc) · 12.8 KB
/
release.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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
---
# DO NOT EDIT
# Created from template "release.yml".
name: release
"on":
- workflow_dispatch
env:
RUSTFLAGS: "-D warnings"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_USER: "${{ github.actor }}"
jobs:
project-matrixes:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
outputs:
cargo-matrix: "${{ steps.find-cargo-matrix.outputs.matrix }}"
all-matrix: "${{ steps.find-all-matrix.outputs.matrix }}"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get versio
uses: chaaz/versio-actions/[email protected]
- name: Find cargo matrix
id: find-cargo-matrix
run: "echo \"::set-output name=matrix::{\\\"include\\\":$(versio -l none info -l cargo -R -N)}\""
- name: Find all matrix
id: find-all-matrix
run: "echo \"::set-output name=matrix::{\\\"include\\\":$(versio -l none info -a -R -N)}\""
versio-checks:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get versio
uses: chaaz/versio-actions/[email protected]
- name: Fetch history
run: git fetch --unshallow
- name: Check projects
run: versio check
- name: Output plan
run: versio plan
cargo-checks:
needs: project-matrixes
runs-on: ubuntu-latest
strategy:
matrix: "${{ fromJson(needs.project-matrixes.outputs.cargo-matrix) }}"
if: "!contains(github.event.head_commit.message, 'skip ci')"
defaults:
run:
working-directory: "${{ matrix.root }}"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libgpg-error-dev libgpgme-dev
- name: Get cargo stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
- name: Get cargo nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
- name: Find paths
id: cargo-find-paths
run: "echo ::set-output name=cargo-lock-glob::\"${{ matrix.root }}\"/**/Cargo.lock"
- name: Cache cargo and target
uses: actions/cache@v1
with:
path: "~/.cargo/registry\n~/.cargo/git\n${{ matrix.root }}/target\n"
key: "${{ runner.os }}-cargo-${{ hashFiles(steps.cargo-find-paths.outputs.cargo-lock-glob) }}"
- name: Check structure
run: cargo clippy
- name: Check format
run: cargo +nightly fmt -- --check
- name: Check tests
run: cargo test
versio-release:
needs:
- cargo-checks
- versio-checks
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get versio
uses: chaaz/versio-actions/[email protected]
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libgpg-error-dev libgpgme-dev
- name: Get cargo stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Cache cargo
uses: actions/cache@v1
with:
path: "~/.cargo/registry\n~/.cargo/git\n"
key: "${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}"
- name: Fetch history
run: git fetch --unshallow
- name: Generate release
run: versio release
cratesio-publish:
needs:
- project-matrixes
- versio-release
runs-on: ubuntu-latest
strategy:
matrix: "${{fromJson(needs.project-matrixes.outputs.cargo-matrix)}}"
if: "!contains(github.event.head_commit.message, 'skip ci')"
defaults:
run:
working-directory: "${{ matrix.root }}"
steps:
- name: Checkout release
uses: actions/checkout@v3
with:
ref: main
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libgpg-error-dev libgpgme-dev
- name: Get cargo stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
- name: Get cargo nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
- name: Find paths
id: cargo-find-paths
run: "echo ::set-output name=cargo-lock-glob::\"${{ matrix.root }}\"/**/Cargo.lock"
- name: Cache cargo and target
uses: actions/cache@v1
with:
path: "~/.cargo/registry\n~/.cargo/git\n${{ matrix.root }}/target\n"
key: "${{ runner.os }}-cargo-${{ hashFiles(steps.cargo-find-paths.outputs.cargo-lock-glob) }}"
- name: Login to crates.io
run: "cargo login ${CRATES_IO_TOKEN}"
env:
CRATES_IO_TOKEN: "${{ secrets.CRATES_IO_TOKEN }}"
- name: Publish to crates.io
run: cargo publish
github-publish:
needs: versio-release
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
outputs:
upload_url: "${{ steps.publish-to-github.outputs.upload_url }}"
steps:
- name: Checkout release
uses: actions/checkout@v3
with:
ref: main
- name: Get versio
uses: chaaz/versio-actions/[email protected]
- name: Find version
id: find-version
run: "echo ::set-output name=version::$(versio -l none info -i 0 -F | jq -r '.[0].full_version')"
- name: Publish to GitHub
id: publish-to-github
uses: actions/create-release@v1
with:
tag_name: "${{ steps.find-version.outputs.version }}"
release_name: "(TODO) RELEASE FOR ${{ steps.find-version.outputs.version }}"
body: "(TODO) SUMMARY\n- (TODO) FEATURE1\n\nNew to Versio? The [repository](https://github.com/chaaz/versio) is the best place to learn about Versio and what it can do. If you want to report a bug or request a feature, you can do so at our [Issues](https://github.com/chaaz/versio/issues) link, but we ask you first read the [Troubleshooting](https://github.com/chaaz/versio/blob/main/docs/troubleshooting.md) page learn about problems and their solutions.\n\nDEPENDENCIES:\n\nOn MacOS and Linux, you must have GPG tools installed. These tools are installed by default on most distributions of Linux and MacOS. If you can run `git`, then you probably have the necessary tools already installed.\n\nOn Windows, you need to install the GpgME package, which is available [here](https://gnupg.org/ftp/gcrypt/binary/gnupg-w32-2.3.1_20210420.exe) (Signature and checksum available from its [parent directory](https://gnupg.org/ftp/gcrypt/binary/)).\n\nIf you have any questions, you should view the [Installation page](https://github.com/chaaz/versio/blob/main/docs/installing.md) for information about installing and testing dependencies.\n\nINSTALLATION: \n\nTo install, follow the instructions for your platform; some files might be zipped for improved download speed. For example, on MacOS you can do something like this (assuming `~/bin` exists and is in your PATH):\n\n```sh\ncurl -L https://github.com/chaaz/versio/releases/download/${{ steps.find-version.outputs.version }}/versio__x86_64-apple-darwin -o ~/bin/versio\nchmod +x ~/bin/versio\n```\n\n**MacOS:** download `versio__x86_64-apple-darwin`, copy to `versio` in your PATH.\n**GNU Linux 64:** download `versio__x86_64-unknown-linux-gnu`, copy to `versio` in your PATH.\n**Windows:** download `versio__x86_64-pc-win32.exe`, copy to `versio.exe` in your %PATH.\n"
draft: true
prerelease: false
commitish: main
publish-versio:
needs: github-publish
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
root: "."
rustflags: "-D warnings -C link-args=-s"
bin_name: versio
- os: macos-latest
target: x86_64-apple-darwin
root: "."
rustflags: "-D warnings"
bin_name: versio
- os: windows-latest
target: x86_64-pc-win32.exe
root: "."
rustflags: "-D warnings"
bin_name: versio.exe
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: "${{ matrix.os }}"
steps:
- name: Checkout release
uses: actions/checkout@v3
with:
ref: main
- name: Install Ubuntu dependencies
if: "matrix.os == 'ubuntu-latest'"
run: sudo apt-get update && sudo apt-get install -y libgpg-error-dev libgpgme-dev
- name: Install MacOS dependencies
if: "matrix.os == 'macos-latest'"
run: brew update; brew install gpgme
- name: Install Windows dependencies
if: "matrix.os == 'windows-latest'"
run: "$env:PATH = \"C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\ProgramData\\chocolatey\\bin\"\n[Environment]::SetEnvironmentVariable(\"Path\", $env:PATH, \"Machine\")\nchoco install -y gnupg\necho \"C:\\Program Files (x86)\\GnuPG\\bin\" >> $env:GITHUB_PATH\n"
- name: Get cargo stable
if: "matrix.os != 'windows-latest'"
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
- name: Get cargo nightly
if: "matrix.os != 'windows-latest'"
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
- name: Get Windows cargo stable
if: "matrix.os == 'windows-latest'"
uses: actions-rs/toolchain@v1
with:
toolchain: stable-i686-pc-windows-msvc
target: i686-pc-windows-gnu
components: clippy
default: true
- name: Get Windows cargo nightly
if: "matrix.os == 'windows-latest'"
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-i686-pc-windows-msvc
target: i686-pc-windows-gnu
components: rustfmt
- name: Update Windows target configuration
if: "matrix.os == 'windows-latest'"
run: rustup set default-host i686-pc-windows-gnu
- name: Find paths
id: cargo-find-paths
run: "echo ::set-output name=cargo-lock-glob::\"${{ matrix.root }}\"/**/Cargo.lock"
- name: Cache cargo and target
uses: actions/cache@v1
with:
path: "~/.cargo/registry\n~/.cargo/git\n${{ matrix.root }}/target\n"
key: "${{ runner.os }}-cargo-${{ hashFiles(steps.cargo-find-paths.outputs.cargo-lock-glob) }}"
- name: Build Ubuntu binary
if: "matrix.os == 'ubuntu-latest'"
run: cargo build --release
working-directory: "${{ matrix.root }}"
env:
RUSTFLAGS: "${{ matrix.rustflags }}"
LIBGPG_ERROR_INCLUDE: /usr/include/x86_64-linux-gnu
LIBGPG_ERROR_LIB_DIR: /usr/lib/x86_64-linux-gnu
LIBGPG_ERROR_LIBS: static=gpg-error
GPGME_INCLUDE: /usr/include
GPGME_LIB_DIR: /usr/lib/x86_64-linux-gnu
GPGME_LIBS: "static=gpgme:static=assuan"
- name: Build MacOS binary
if: "matrix.os == 'macos-latest'"
run: cargo build --release
working-directory: "${{ matrix.root }}"
env:
RUSTFLAGS: "${{ matrix.rustflags }}"
LIBGPG_ERROR_INCLUDE: /usr/local/opt/libgpg-error/include
LIBGPG_ERROR_LIB_DIR: /usr/local/opt/libgpg-error/lib
LIBGPG_ERROR_LIBS: static=gpg-error
GPGME_INCLUDE: "/usr/local/opt/libassuan/include:/usr/local/opt/gpgme/include"
GPGME_LIB_DIR: "/usr/local/opt/libassuan/lib:/usr/local/opt/gpgme/lib"
GPGME_LIBS: "static=gpgme:static=assuan"
- name: Set up MinGW
if: "matrix.os == 'windows-latest'"
uses: egor-tensin/setup-mingw@v2
with:
platform: x86
- name: Build Windows binary
if: "matrix.os == 'windows-latest'"
run: cargo build --release --target i686-pc-windows-gnu
working-directory: "${{ matrix.root }}"
env:
RUSTFLAGS: "${{ matrix.rustflags }}"
- name: Upload binary
if: "matrix.os != 'windows-latest'"
uses: actions/upload-release-asset@v1
with:
upload_url: "${{ needs.github-publish.outputs.upload_url }}"
asset_path: "target/release/${{ matrix.bin_name }}"
asset_name: "versio__${{ matrix.target }}"
asset_content_type: application/octet-stream
- name: Upload Windows binary
if: "matrix.os == 'windows-latest'"
uses: actions/upload-release-asset@v1
with:
upload_url: "${{ needs.github-publish.outputs.upload_url }}"
asset_path: "target/i686-pc-windows-gnu/release/${{ matrix.bin_name }}"
asset_name: "versio__${{ matrix.target }}"
asset_content_type: application/octet-stream