-
Notifications
You must be signed in to change notification settings - Fork 8
218 lines (218 loc) · 8.62 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
---
# 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: Get cargo stable
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Get cargo nightly
uses: dtolnay/rust-toolchain@nightly
with:
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: Get cargo stable
uses: dtolnay/rust-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: Get cargo stable
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Get cargo nightly
uses: dtolnay/rust-toolchain@nightly
with:
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\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\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"
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-windows-msvc
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: Get cargo stable
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Get cargo nightly
uses: dtolnay/rust-toolchain@nightly
with:
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: Build binary
if: "matrix.os == 'ubuntu-latest'"
run: cargo build --release
working-directory: "${{ matrix.root }}"
env:
RUSTFLAGS: "${{ matrix.rustflags }}"
- name: Upload binary
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