-
Notifications
You must be signed in to change notification settings - Fork 3
203 lines (179 loc) · 6.42 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
name: Release
on:
push:
branches:
- release
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
build:
name: Build Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
toolchain: [1.57.0]
os: [ubuntu-20.04, macos-10.15, windows-2019]
include:
- platform: linux
os: ubuntu-20.04
features: z3,boolector
target: x86_64-unknown-linux-gnu
extension: ""
- platform: macos
os: macos-10.15
features: z3,boolector
target: x86_64-apple-darwin
extension: ""
- platform: windows
os: windows-2019
features: z3
target: x86_64-pc-windows-msvc
extension: ".exe"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Rust ${{ matrix.toolchain }}
uses: actions-rs/toolchain@v1
with:
profile: default
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }}
override: true
- name: Compute new Version
id: compute_version
uses: mathieudutour/github-tag-action@v5.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: .*
dry_run: true
- name: Install Sed on Windows
if: ${{ contains(matrix.os, 'windows') }}
run: choco install sed -y
- name: Update Version in Manifest
shell: bash
run: |
${{ format('sed -i -e "s/^version[[:space:]]*=[[:space:]]*\"[[:digit:]]*.[[:digit:]]*.[[:digit:]]*\"/version = \"{0}\"/g" Cargo.toml', steps.compute_version.outputs.new_version) }}
# Sync lock file for build with --locked flag
- name: Update Lock File to New Manifest Version
uses: actions-rs/cargo@v1
with:
command: update
args: --package monster-rs
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }} --features ${{ matrix.features }} --locked
- name: Rename Binary
shell: bash
run: mv target/${{ matrix.target }}/release/monster${{ matrix.extension }} ./monster-${{ matrix.target }}${{ matrix.extension }}
- name: Upload Binary Artifact
uses: actions/upload-artifact@v2
with:
name: monster-${{ matrix.platform }}
path: monster-${{ matrix.target }}${{ matrix.extension }}
if-no-files-found: error
# TODO: Sign bot commits, once this is supported:
# https://github.com/actions/runner/issues/667
release:
name: Semantic Release
needs: build
# secrets of this environment are needed
environment: Release
runs-on: ubuntu-20.04
env:
# Configure author for bot commits using the github-actions bot credentials
GIT_AUTHOR_NAME: "Github Action"
GIT_AUTHOR_EMAIL: "action@github.com"
GIT_COMMITTER_NAME: "Github Action"
GIT_COMMITTER_EMAIL: "action@github.com"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# use credentials, that are allowed to commit to release branch
ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
# full history needed by semantic release (analysis commit messages)
fetch-depth: 0
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.57.0
override: true
- name: Install Semantic Release for Rust
uses: actions-rs/cargo@v1
with:
command: install
args: semantic-release-rust --version 1.0.0-alpha.8 --locked
# The release build is used in the Semantic Release step
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features --locked
# Download all binary artifacts to release
- uses: actions/download-artifact@v2
with:
name: monster-linux
- uses: actions/download-artifact@v2
with:
name: monster-windows
- uses: actions/download-artifact@v2
with:
name: monster-macos
# Executes the following sub steps:
# 1. analyze Git commit messages (conventional commits) and tags
# 2. compute a new version based on commit message types and the latest git tag
# 3. compute the release notes based on commit messages (feat and fix types are included)
# 4. adjust the version in the manifest (Cargo.toml)
# 5. create a Git tag with new version
# 6. create a Github Release with version, release notes and release binaries
# 7. publish the package monster-rs on crates.io
# 8. commit modified Cargo.toml and Cargo.lock on release branch
# 9. merge release branch back into main
# 10. notify developers in Slack
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
with:
semantic_version: 17.4.1
extra_plugins: |
@semantic-release/exec@5.0
@semantic-release/git@9.0
@saithodev/semantic-release-backmerge@1.2
semantic-release-slack-bot@2.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SEMANTIC_RELEASE_SLACK_WEBHOOK }}
publish-book:
name: Publish Book
# secrets of this environment are needed
environment: github-pages
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# use credentials, that are allowed to commit to gh-pages branch
ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
- name: Install Graphviz
run: |
sudo apt-get update
sudo apt-get install -y graphviz
- name: Install mdbook and Dependencies
run: |
cargo install mdbook --locked || true
cargo install mdbook-linkcheck --locked || true
cargo install --git https://github.com/dylanowen/mdbook-graphviz || true
- name: Generate Book as Html
run: mdbook build book
- name: Deploy on Github Pages
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_dir: ./book/book/html
user_name: "Github Action"
user_email: "action@github.com"