-
Notifications
You must be signed in to change notification settings - Fork 9
169 lines (150 loc) · 5.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
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.72.0]
os: [ubuntu-20.04, macos-11, windows-2019]
include:
- platform: linux
os: ubuntu-20.04
features: z3,boolector,kissat,varisat
target: x86_64-unknown-linux-gnu
extension: ""
- platform: macos
os: macos-11
features: z3,boolector,kissat,varisat
target: x86_64-apple-darwin
extension: ""
- platform: windows
os: windows-2019
features: z3,varisat
target: x86_64-pc-windows-msvc
extension: ".exe"
steps:
- name: Checkout
uses: actions/checkout@v3
- 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/[email protected]
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@v3
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: "[email protected]"
GIT_COMMITTER_NAME: "Github Action"
GIT_COMMITTER_EMAIL: "[email protected]"
steps:
- name: Checkout
uses: actions/checkout@v3
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.72.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@v3
with:
name: monster-linux
- uses: actions/download-artifact@v3
with:
name: monster-windows
- uses: actions/download-artifact@v3
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/[email protected]
@semantic-release/[email protected]
@saithodev/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SEMANTIC_RELEASE_SLACK_WEBHOOK }}