-
-
Notifications
You must be signed in to change notification settings - Fork 79
288 lines (255 loc) · 11.3 KB
/
cd.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
name: Continuous Deployment
on:
push:
tags:
- "v*.*.*"
jobs:
create-github-release:
name: create-github-release
runs-on: ubuntu-latest
steps:
- name: Create artifacts directory
run: mkdir artifacts
- name: Get the release version from the tag
if: env.VERSION == ''
run: |
if [[ -n "${{ github.event.inputs.tag }}" ]]; then
echo "Manual run against a tag; overriding actual tag in the environment..."
echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
else
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi
- name: Validate version environment variable
run: |
echo "Version being built against is version ${{ env.VERSION }}"!
- name: Save version number to artifact
run: echo "${{ env.VERSION }}" > artifacts/release-version
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: artifacts
path: artifacts
build-release:
name: build-release
needs: [create-github-release]
runs-on: ${{ matrix.job.os }}
env:
RUST_BACKTRACE: 1
strategy:
fail-fast: false
matrix:
rust: [stable]
job:
- { os: "macOS-latest", target: "x86_64-apple-darwin", artifact_prefix: "macos" }
- { os: "windows-latest", target: "x86_64-pc-windows-msvc", artifact_prefix: "windows" }
- { os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", artifact_prefix: "linux", }
- { os: "ubuntu-latest", target: "x86_64-unknown-linux-musl", artifact_prefix: "linux-musl", }
- { os: "ubuntu-latest", target: "aarch64-unknown-linux-gnu", artifact_prefix: "aarch64-gnu", use-cross: true, test-bin: "--bin kdash" }
- { os: "ubuntu-latest", target: "aarch64-unknown-linux-musl", artifact_prefix: "aarch64-musl", use-cross: true, test-bin: "--bin kdash" }
- { os: "ubuntu-latest", target: "arm-unknown-linux-gnueabihf", artifact_prefix: "arm-gnu", use-cross: true, test-bin: "--bin kdash" }
- { os: "ubuntu-latest", target: "arm-unknown-linux-musleabihf", artifact_prefix: "arm-musl", use-cross: true, test-bin: "--bin kdash" }
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Get shared artifacts
uses: actions/download-artifact@v2
with:
name: artifacts
path: artifacts
- name: Set release version
shell: bash
run: |
release_version="$(cat ./artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables
run: |
echo "Release version: ${{ env.RELEASE_VERSION }}"
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
target: ${{ matrix.job.target }}
profile: minimal # minimal component installation (ie, no documentation)
- name: Installing needed macOS dependencies
if: matrix.job.os == 'macos-latest'
run: brew install [email protected]
- name: Installing needed Ubuntu dependencies
if: matrix.job.os == 'ubuntu-latest'
shell: bash
run: |
sudo apt-get -y update
sudo apt-get -y install -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev musl-tools
case ${{ matrix.job.target }} in
arm-unknown-linux-*) sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
aarch64-unknown-linux-*) sudo apt-get -y install gcc-aarch64-linux-gnu ;;
esac
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.use-cross }}
command: build
args: --release --verbose --target=${{ matrix.job.target }}
toolchain: ${{ matrix.rust }}
- name: Test
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.use-cross }}
command: test
args: --target=${{ matrix.job.target }} ${{ matrix.job.test-bin }}
- name: Packaging final binary (Windows)
if: matrix.job.os == 'windows-latest'
shell: bash
run: |
cd target/${{ matrix.job.target }}/release
BINARY_NAME=kdash.exe
# strip the binary
strip $BINARY_NAME
RELEASE_NAME=kdash-${{ matrix.job.artifact_prefix }}
tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
# create sha checksum files
certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
- name: Packaging final binary (macOS and Linux)
if: matrix.job.os != 'windows-latest'
shell: bash
run: |
# set the right strip executable
STRIP="strip";
case ${{ matrix.job.target }} in
arm-*-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
aarch64-*-linux-*) STRIP="aarch64-linux-gnu-strip" ;;
esac;
cd target/${{ matrix.job.target }}/release
BINARY_NAME=kdash
# strip the binary
"$STRIP" "$BINARY_NAME"
RELEASE_NAME=kdash-${{ matrix.job.artifact_prefix }}
tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
# create sha checksum files
shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
- name: Releasing assets
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.job.target }}/release/${{ env.RELEASE_NAME }}.tar.gz
target/${{ matrix.job.target }}/release/${{ env.RELEASE_NAME }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add SHA to artifacts
run: |
cp target/${{ matrix.job.target }}/release/${{ env.RELEASE_NAME }}.sha256 artifacts/
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: artifacts
path: artifacts
publish-package-formula:
needs: [build-release]
name: Update homebrew & choco formulas
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Get release artifacts
uses: actions/download-artifact@v2
with:
name: artifacts
path: artifacts
- name: Set release assets and version
shell: bash
run: |
macos_sha="$(cat ./artifacts/kdash-macos.sha256 | awk '{print $1}')"
echo "MACOS_SHA=$macos_sha" >> $GITHUB_ENV
linux_sha="$(cat ./artifacts/kdash-linux-musl.sha256 | awk '{print $1}')"
echo "LINUX_SHA=$linux_sha" >> $GITHUB_ENV
windows_sha="$(cat ./artifacts/kdash-windows.sha256 | awk '{print $1}')"
echo "WINDOWS_SHA=$windows_sha" >> $GITHUB_ENV
release_version="$(cat ./artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables
run: |
echo "Release SHA macos: ${{ env.MACOS_SHA }}"
echo "Release SHA linux: ${{ env.LINUX_SHA }}"
echo "Release SHA windows: ${{ env.WINDOWS_SHA }}"
echo "Release version: ${{ env.RELEASE_VERSION }}"
- name: Execute Homebrew packaging script
run: |
# run packaging script
python "./deployment/homebrew/packager.py" ${{ env.RELEASE_VERSION }} "./deployment/homebrew/kdash.rb.template" "./kdash.rb" ${{ env.MACOS_SHA }} ${{ env.LINUX_SHA }}
# push to Git
git config --global user.email "[email protected]"
git config --global user.name "deepu105"
git clone https://deepu105:${{ secrets.TAP_GITHUB_TOKEN }}@github.com/kdash-rs/homebrew-kdash.git --branch=main brew
rm brew/Formula/kdash.rb
cp kdash.rb brew/Formula
cd brew
git add .
git diff-index --quiet HEAD || git commit -am "Update formula for KDash release ${{ env.RELEASE_VERSION }}"
git push origin main
- name: Execute chocolatey packaging script
run: |
# run packaging script
python "./deployment/chocolatey/packager.py" ${{ env.RELEASE_VERSION }} "./deployment/chocolatey/kdash.nuspec.template" "./kdash.nuspec" ${{ env.WINDOWS_SHA }}
python "./deployment/chocolatey/packager.py" ${{ env.RELEASE_VERSION }} "./deployment/chocolatey/chocolateyinstall.ps1.template" "./chocolateyinstall.ps1" ${{ env.WINDOWS_SHA }}
# push to Git
git config --global user.email "[email protected]"
git config --global user.name "deepu105"
git clone https://deepu105:${{ secrets.CHOCO_GITHUB_TOKEN }}@github.com/kdash-rs/choco-kdash --branch=main choco
rm choco/kdash.nuspec
rm choco/tools/chocolateyinstall.ps1
cp kdash.nuspec choco/kdash.nuspec
cp chocolateyinstall.ps1 choco/tools/chocolateyinstall.ps1
cd choco
git add .
git diff-index --quiet HEAD || git commit -am "Update package for KDash release ${{ env.RELEASE_VERSION }}"
git push origin main
- name: Execute Scoop packaging script
run: |
# run packaging script
python "./deployment/scoop/packager.py" ${{ env.RELEASE_VERSION }} "./deployment/scoop/kdash.json.template" "./kdash.json" ${{ env.WINDOWS_SHA }}
# push to Git
git config --global user.email "[email protected]"
git config --global user.name "deepu105"
git clone https://deepu105:${{ secrets.CHOCO_GITHUB_TOKEN }}@github.com/kdash-rs/scoop-kdash --branch=main scoop
rm scoop/kdash.json
cp kdash.json scoop/kdash.json
cd scoop
git add .
git diff-index --quiet HEAD || git commit -am "Update package for KDash release ${{ env.RELEASE_VERSION }}"
git push origin main
publish-cargo:
name: Publishing to Cargo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal # minimal component installation (ie, no documentation)
- run: |
sudo apt-get update
sudo apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
- uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CARGO_API_KEY }} --allow-dirty
publish-docker-image:
name: Publishing Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: deepu105/kdash
tag_with_ref: true