-
Notifications
You must be signed in to change notification settings - Fork 0
236 lines (207 loc) · 6.93 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
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
name: Release
on:
# Runs this workflow when a tag is done to releases branch.
push:
tags:
# Regex for a version number such as 0.2.1
- "v[0-9]+.[0-9]+.[0-9]+"
# Runs this workflow every night at midnight.
schedule:
- cron: 0 0 * * *
# Allows to run this workflow manually from the Actions tab.
workflow_dispatch:
inputs:
tagname:
description: "Tag name for release"
required: false
default: nightly
jobs:
# Build the tagname and branch.
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.output.outputs.version }}
branch: ${{ steps.output.outputs.branch }}
steps:
# Hardcoded on 'schedule'
- if: github.event_name == 'schedule'
run: |
echo "VERSION=nightly" >> $GITHUB_ENV
echo "BRANCH=develop" >> $GITHUB_ENV
# Manual input on 'workflow_dispatch'
- if: github.event_name == 'workflow_dispatch'
run: |
echo "VERSION=${{ github.event.inputs.tagname }}" >> $GITHUB_ENV
echo "BRANCH=develop" >> $GITHUB_ENV
# Based on tag name when pushed on 'releases' branch.
- if: github.event_name == 'push'
run: |
TAGNAME=${{ github.ref }}
echo "VERSION=${TAGNAME#refs/tags/}" >> $GITHUB_ENV
echo "BRANCH=releases" >> $GITHUB_ENV
- id: output
run: |
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
# Builds the frontend using the reusable action.
website:
name: Build FRONTEND
runs-on: windows-latest
needs: prepare
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.branch }}
- uses: ./.github/actions/build_frontend
- name: Upload Frontend
uses: actions/upload-artifact@v4
with:
name: website
path: ./frontend/dist/
retention-days: 1
# Builds multiple version of the backend and package them.
backend:
name: Cross-platform build BACKEND
runs-on: ${{ matrix.os }}
needs:
- prepare
- website
env:
CARGO_TERM_COLOR: always
CROSS_CONFIG: ./backend/Cross.toml
strategy:
matrix:
include:
- name: linux-x86_64
target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cross: true
- name: darwin-x86_64
target: x86_64-apple-darwin
os: macos-latest
cross: false
- name: windows-x86_64
target: x86_64-pc-windows-msvc
os: windows-latest
cross: false
- name: raspberryPi-64bits
target: aarch64-unknown-linux-gnu # raspberryPI OS 64bits
os: ubuntu-latest
cross: true
- name: raspberryPi-32bits
target: armv7-unknown-linux-gnueabihf # raspberryPI OS 32bits
os: ubuntu-latest
cross: true
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.branch }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
target: ${{ matrix.target }}
toolchain: stable
override: true
profile: minimal
- name: Update Cross
uses: actions-rs/cargo@v1
with:
command: install
use-cross: false
args: cross --git https://github.com/cross-rs/cross
- name: Compile BACKEND
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: build
args: --verbose --release --manifest-path "./backend/Cargo.toml" --target ${{ matrix.target }}
- name: Download website
uses: actions/download-artifact@v4
with:
name: website
path: website
merge-multiple: true
- name: Build archive
shell: bash
run: |
binary_name="hermes-studio"
# Build a directory for this version
dirname="$binary_name--${{ matrix.name }}"
mkdir "$dirname"
ls -la
# Move the FRONTEND website into the directory
mv "website" "$dirname"
# Move the release binary (BACKEND) into the directory
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
mv "./backend/target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
else
mv "./backend/target/${{ matrix.target }}/release/$binary_name" "$dirname"
fi
# Compress the directory
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Upload the archive
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET }}
path: ${{ env.ASSET }}
retention-days: 1
publish:
name: Publish release
runs-on: ubuntu-latest
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
needs:
- prepare
- backend
steps:
# Must perform checkout first, since it deletes the target directory
# before running, and would therefore delete the downloaded artifacts
- uses: actions/checkout@v4
- name: Retrieve all artifacts
uses: actions/download-artifact@v4
with:
pattern: hermes-studio--*
merge-multiple: true
- if: needs.prepare.outputs.version == 'nightly'
run: |
ls -la
echo "SUBJECT=Hermes-Studio nightly build" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
echo "DRAFT=false" >> $GITHUB_ENV
echo "BODY=Unstable nightly release: built from the latest status of the develop branch." >> $GITHUB_ENV
gh release delete nightly --yes || true
git tag -d nightly || true
git push origin :refs/tags/nightly || true
git tag -f nightly || true
git push --force origin nightly || true
- if: needs.prepare.outputs.version != 'nightly'
run: |
VERSION=${{ needs.prepare.outputs.version }}
echo "SUBJECT=$VERSION" >> $GITHUB_ENV
echo "PRERELEASE=false" >> $GITHUB_ENV
echo "DRAFT=false" >> $GITHUB_ENV
echo "BODY=" >> $GITHUB_ENV
- name: Publish release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.prepare.outputs.version }}
files: hermes-studio--*
generate_release_notes: true
draft: ${{ env.DRAFT }}
name: ${{ env.SUBJECT }}
body: ${{ env.BODY }}
prerelease: ${{ env.PRERELEASE }}
latest: true