-
Notifications
You must be signed in to change notification settings - Fork 5
195 lines (175 loc) · 6.09 KB
/
build.yaml
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
name: Build
on:
push:
branches:
- main
# Releases are tags named 'v<version>', and must have the "major.minor.micro", for example: "0.1.0".
# Release candidates are tagged as `v<version>-rc<num>`, for example: "0.1.0-rc1".
tags:
- "v*"
pull_request:
jobs:
check:
runs-on: ubuntu-latest
outputs:
do-publish: ${{steps.state.outputs.do-publish}}
release: ${{steps.state.outputs.release}}
version: ${{steps.version.outputs.version}}
prerelease: ${{steps.state.outputs.prerelease}}
steps:
- name: Evaluate state
id: state
shell: bash
run: |
test -z "${{github.head_ref}}" && echo "do-publish=true" >> $GITHUB_OUTPUT
if [[ "${{ github.event.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "release=true" >> $GITHUB_OUTPUT
elif [[ "${{ github.event.ref }}" =~ ^refs/tags/v.*$ ]]; then
echo "release=true" >> $GITHUB_OUTPUT
echo "prerelease=true" >> $GITHUB_OUTPUT
fi
- name: Set version
id: version
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest # main branch
[ "$VERSION" == "merge" ] && VERSION=latest # PR
echo VERSION=$VERSION
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Dump state
run: |
echo "Tag/version: ${VERSION} / ${{needs.check.outputs.version}}"
echo "Should we publish artifacts? - do-publish = ${{needs.check.outputs.do-publish}}"
echo "Release? - release = ${{needs.check.outputs.release}}"
echo "Pre-release? - prerelease = ${{needs.check.outputs.prerelease}}"
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
- run: rustup component add clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
- name: Run Rustfmt
run: cargo fmt -- --check
- name: Cargo check
run: cargo check
build:
needs:
- check
strategy:
matrix:
os: [ubuntu-22.04, macos-12, windows-2019]
include:
- os: ubuntu-22.04
suffix: "linux-amd64"
pkg: "tar.gz"
- os: macos-12
suffix: "macos-amd64"
pkg: "tar.gz"
- os: windows-2019
suffix: "windows-amd64"
exe: ".exe"
pkg: "zip"
runs-on: ${{ matrix.os }}
env:
VERSION: ${{needs.check.outputs.version}}
steps:
- name: Install build tools
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
sudo apt-get update; DEBIAN_FRONTEND="noninteractive" sudo apt-get -y install build-essential curl tzdata
sudo apt install -y libssl-dev pkg-config
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Prepare release asset
shell: bash
run: .github/scripts/package_release.sh "${{matrix.suffix}}" "${{matrix.exe}}" "${{matrix.pkg}}" "${VERSION}"
- name: Build Windows Installer
if: ${{ matrix.os == 'windows-2019' }}
shell: cmd
#
# In the following command we add '.0' to the version, as MSI expects a version in the format 'a.b.c.d'.
# We also switch the version to '0.0.0.0' if it is 'latest'
#
run: |
cd
dir target\release
nuget install WiX -version 3.11.2
set VERSION=%VERSION:latest=0.0.0%
set VERSION=%VERSION%.0
D:\a\drg\drg\WiX.3.11.2\tools\candle -v -dVersion=%VERSION% -arch x64 dist\wix\drg.wxs
D:\a\drg\drg\WiX.3.11.2\tools\light drg.wixobj -o drg-%VERSION%-${{matrix.suffix}}.msi
- uses: actions/upload-artifact@v2
with:
name: package-${{ matrix.os }}
if-no-files-found: error
path: |
drg-*.tar.gz
drg-*.zip
- uses: actions/upload-artifact@v2
if: ${{ matrix.os == 'windows-2019' }}
with:
name: installer-${{ matrix.os }}
if-no-files-found: error
path: |
drg-*.msi
publish:
#
# The publish job will on all branches and tags, except PRs. However, it does only create a release when a
# tag of the right format is pushed.
#
needs:
- check
- build
runs-on: ubuntu-latest
env:
VERSION: ${{needs.check.outputs.version}}
steps:
- name: Dump state
run: |
echo "Tag/version: ${VERSION} / ${{needs.check.outputs.version}}"
echo "Should we publish artifacts? - do-publish = ${{needs.check.outputs.do-publish}}"
echo "Release? - release = ${{needs.check.outputs.release}}"
echo "Pre-release? - prerelease = ${{needs.check.outputs.prerelease}}"
- uses: actions/checkout@v3
- uses: actions/download-artifact@v2
with:
path: downloads
- name: Prepare upload area
run: |
mkdir uploads
mv downloads/package-*/drg-* uploads/
mv downloads/installer-*/drg-* uploads/
- name: Check staging content
run: |
find uploads
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
draft: true
body_path: CHANGELOG.md
fail_on_unmatched_files: true
files: |
uploads/drg-*