-
-
Notifications
You must be signed in to change notification settings - Fork 0
222 lines (189 loc) · 7.08 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
# This checks out the code, and compiles and uploads the binaries.
name: Continuous Deployment
on:
push:
branches: ["main"]
tags:
- "v*"
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: "full"
concurrency:
group: CD-${{ github.ref }}
cancel-in-progress: true
jobs:
crates-io-publish:
name: Publish to crates.io
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
crate:
[
surrealqlx-macros-impl,
surrealqlx-macros,
surrealqlx,
one-or-many,
mecomp-analysis,
mecomp-storage,
mecomp-core,
mecomp-daemon,
mecomp-cli,
mecomp-tui,
]
max-parallel: 1
fail-fast: false # Continue with other crates even if one fails, this is necessary because not all crates need to be published for any given release
runs-on: ubuntu-latest
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y --no-install-recommends libasound2-dev pkg-config wget libavutil-dev libavformat-dev
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
- name: Setup cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install cargo-hakari
uses: taiki-e/install-action@v2
with:
tool: cargo-hakari
- name: Publish to crates.io
run: cargo hakari publish --package ${{ matrix.crate }} --token=$CARGO_REGISTRY_TOKEN
build:
name: Build - ${{ matrix.binary}} for ${{ matrix.platform.os_name }}
strategy:
matrix:
binary: [mecomp-tui, mecomp-cli, mecomp-daemon]
platform:
- os_name: Linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os_name: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
# NOTE: once surrealdb-jsonwebtoken no longer depends on ring 0.16, we can re-add this
# - os_name: Windows-aarch64
# os: windows-latest
# target: aarch64-pc-windows-msvc
- os_name: macOS-x86_64
os: macOS-latest
target: x86_64-apple-darwin
- os_name: macOS-aarch64
os: macOS-latest
target: aarch64-apple-darwin
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}
# - name: Install musl-tools on Linux
# run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools musl-dev
# if: contains(matrix.platform.os, 'ubuntu')
- name: Install linux dependencies
run: |
sudo apt update
sudo apt install -y --no-install-recommends libasound2-dev pkg-config wget libavutil-dev libavformat-dev
if: contains(matrix.platform.os, 'ubuntu')
- name: Setup cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build binary (Linux)
shell: bash
run: |
PKG_CONFIG_SYSROOT_DIR=/ cargo build --locked --release --target ${{ matrix.platform.target }} --package ${{ matrix.binary}} --bin ${{ matrix.binary }}
if: ${{ contains(matrix.platform.os, 'ubuntu') }}
- name: Build binary (macOS)
run: |
cargo build --locked --release --target ${{ matrix.platform.target }} --package ${{ matrix.binary}} --bin ${{ matrix.binary }}
if: ${{ contains(matrix.platform.os, 'macOS') }}
- name: Build binary (Windows)
# We have to use the platform's native shell. If we use bash on
# Windows then OpenSSL complains that the Perl it finds doesn't use
# the platform's native paths and refuses to build.
shell: powershell
run: |
& cargo build --locked --release --target ${{ matrix.platform.target }} --package ${{ matrix.binary}} --bin ${{ matrix.binary }}
if: contains(matrix.platform.os, 'windows')
- name: Package as archive
shell: bash
run: |
cd target/${{ matrix.platform.target }}/release
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
7z a ../../../${{ matrix.binary }}-${{ matrix.platform.os_name }}.zip ${{ matrix.binary }}.exe
else
chmod +x ${{ matrix.binary }}
tar czvf ../../../${{ matrix.binary }}-${{ matrix.platform.os_name }}.tar.gz ${{ matrix.binary }}
fi
cd -
- name: Publish build artifacts
uses: actions/upload-artifact@v4.4.3
with:
name: ${{ matrix.binary }}-${{ matrix.platform.os_name }}
path: "${{ matrix.binary }}-${{ matrix.platform.os_name }}.*"
gh-release:
if: startsWith(github.ref, 'refs/tags/')
name: Release
needs: build
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
id: download_artifacts
uses: actions/download-artifact@v4.1.8
with:
path: dist/
- name: List files
run: ls -R ${{ steps.download_artifacts.outputs.download-path }}
- name: Generate checksums
id: checksums
run: |
cd ${{ steps.download_artifacts.outputs.download-path }}
for dir in $(ls -d */); do
cd $dir
for file in $(ls *.tar.gz *.zip); do
sha256sum $file > $file.sha256
done
cd -
done
- name: Get the release tag
id: get_release_tag
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create release body
id: body
shell: bash
run: |
touch body.txt
echo "Release for ${{ steps.get_release_tag.outputs.RELEASE_TAG }}" >> body.txt
echo "SHA256 Checksums:" >> body.txt
echo '```' >> body.txt
for file in ${{ steps.download_artifacts.outputs.download-path }}/**/*.sha256; do
echo "$(cat $file)" >> body.txt
done
echo '```' >> body.txt
echo "BODY<<EOF" >> $GITHUB_OUTPUT
cat body.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create or Update GitHub Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_release_tag.outputs.RELEASE_TAG }}
draft: false
prerelease: false
generate_release_notes: true
body: ${{ steps.body.outputs.BODY }}
files: |
${{ steps.download_artifacts.outputs.download-path }}/**/*.tar.gz
${{ steps.download_artifacts.outputs.download-path }}/**/*.zip
${{ steps.download_artifacts.outputs.download-path }}/**/*.sha256