forked from ferronweb/ferron
-
Notifications
You must be signed in to change notification settings - Fork 0
293 lines (257 loc) · 9.8 KB
/
release.yml
File metadata and controls
293 lines (257 loc) · 9.8 KB
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
289
290
291
292
293
name: Release
on:
push:
branches: ["main"]
paths:
- ".dockerignore"
- "Cargo.lock"
- "Cargo.toml"
- "Dockerfile"
- "Dockerfile.*"
- "ferron*.yaml"
- "ferron/**"
- "ferron-passwd/**"
- "wwwroot/**"
- ".github/workflows/release.yml"
jobs:
release:
runs-on: ${{ matrix.runner }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
command: cross
- target: x86_64-unknown-linux-musl
runner: ubuntu-latest
command: cross
- target: i686-unknown-linux-gnu
runner: ubuntu-latest
command: cross
- target: i686-unknown-linux-musl
runner: ubuntu-latest
command: cross
- target: aarch64-unknown-linux-gnu
runner: ubuntu-latest
command: cross
- target: aarch64-unknown-linux-musl
runner: ubuntu-latest
command: cross
- target: armv7-unknown-linux-gnueabihf
runner: ubuntu-latest
command: cross
- target: armv7-unknown-linux-musleabihf
runner: ubuntu-latest
command: cross
- target: riscv64gc-unknown-linux-gnu
runner: ubuntu-latest
command: cross
- target: s390x-unknown-linux-gnu
runner: ubuntu-latest
command: cross
- target: powerpc64le-unknown-linux-gnu
runner: ubuntu-latest
command: cross
- target: x86_64-unknown-freebsd
runner: ubuntu-latest
command: cross
- target: x86_64-pc-windows-msvc
runner: windows-latest
command: cargo
- target: i686-pc-windows-msvc
runner: windows-latest
command: cargo
- target: aarch64-pc-windows-msvc
runner: windows-latest
command: cargo
- target: x86_64-apple-darwin
runner: macos-latest
command: cargo
- target: aarch64-apple-darwin
runner: macos-latest
command: cargo
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: "${{ matrix.target }}"
- name: Setup cache
if: matrix.command != 'cross'
uses: Swatinem/rust-cache@v2
- name: Determine Ferron version
shell: bash
run: |
FERRON_VERSION_CARGO="$(cat ferron/Cargo.toml | grep -E '^version' | sed -E 's|.*"([0-9a-zA-Z.+-]+)"$|\1|g')"
FERRON_VERSION_GIT="$(git tag --sort=-committerdate | head -n 1 | sed s/[^0-9a-zA-Z.+-]//g)"
if [ "$FERRON_VERSION_CARGO" != "" ]; then
echo "Version determined from Cargo.toml file"
echo "FERRON_VERSION=$FERRON_VERSION_CARGO" >> $GITHUB_ENV
elif [ "$FERRON_VERSION_GIT" != "" ]; then
echo "Version determined from the Git tag"
echo "FERRON_VERSION=$FERRON_VERSION_GIT" >> $GITHUB_ENV
else
echo "Can't determine the server version!" 2>&1
exit 1
fi
- name: Install Cross
if: matrix.command == 'cross'
shell: bash
run: |
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall --no-confirm cross --force
- name: Build binaries
run: "${{ matrix.command }} build --verbose --locked --release --target ${{ matrix.target }}"
- name: Prepare for packaging
shell: bash
run: |
mkdir release
find target/${{ matrix.target }}/release -mindepth 1 -maxdepth 1 -type f ! -name "*.*" -o -name "*.exe" -o -name "*.dll" -o -name "*.dylib" -o -name "*.so" | sed -E "s|(.*)|cp -a \1 release|" | bash
cp -a ferron-release.yaml release/ferron.yaml
cp -a wwwroot release
- name: Create a release ZIP archive
uses: thedoctor0/zip-release@0.7.6
with:
type: "zip"
filename: "../ferron-${{ env.FERRON_VERSION }}-${{ matrix.target }}.zip"
directory: "release"
- name: Set up SSH
uses: LuisEnMarroquin/setup-ssh-action@v3.0.0
with:
ORIGIN: ${{ secrets.SSH_HOSTNAME }}
SSHKEY: ${{ secrets.SSH_KEY }}
NAME: ferron-servers
PORT: ${{ secrets.SSH_PORT }}
USER: ${{ secrets.SSH_USERNAME }}
- name: Release Ferron on Ferron's servers
shell: bash
run: |
ssh ferron-servers "mkdir -p ferron/${{ env.FERRON_VERSION }} || true"
scp ferron-${{ env.FERRON_VERSION }}-${{ matrix.target }}.zip ferron-servers:ferron/${{ env.FERRON_VERSION }}/ferron-${{ env.FERRON_VERSION }}-${{ matrix.target }}.zip
# The "move-ferron-archive" is a custom command that moves the ZIP archive to be served by the download server
ssh ferron-servers "/usr/bin/sudo-rs move-ferron-archive ${{ env.FERRON_VERSION }} ${{ matrix.target }}"
# - name: Release Ferron to GitHub
# uses: ncipollo/release-action@v1
# with:
# allowUpdates: true
# artifacts: "ferron-${{ env.FERRON_VERSION }}-${{ matrix.target }}.zip"
# tag: "${{ env.FERRON_VERSION }}"
# commit: "main"
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: main
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Setup cache
uses: Swatinem/rust-cache@v2
- name: Generate the Rust crate documentation
run: "cargo doc --verbose --locked --release"
- name: Create the documentation ZIP archive
uses: thedoctor0/zip-release@0.7.6
with:
type: "zip"
filename: "../../ferron-rustdocs.zip"
directory: "target/doc"
- name: Set up SSH
uses: LuisEnMarroquin/setup-ssh-action@v3.0.0
with:
ORIGIN: ${{ secrets.SSH_HOSTNAME }}
SSHKEY: ${{ secrets.SSH_KEY }}
NAME: ferron-servers
PORT: ${{ secrets.SSH_PORT }}
USER: ${{ secrets.SSH_USERNAME }}
- name: Deploy the documentation
shell: bash
run: |
scp ferron-rustdocs.zip ferron-servers:.
# The "deploy-ferron-rustdocs" is a custom command that deploys the Ferron's Rust crate documentation
ssh ferron-servers "/usr/bin/sudo-rs deploy-ferron-rustdocs ferron-rustdocs.zip && rm ferron-rustdocs.zip"
docker:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
strategy:
fail-fast: false
matrix:
include:
- group: latest
dockerfile: ./Dockerfile
- group: alpine
dockerfile: ./Dockerfile.alpine
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
- name: Log in to Docker Hub
uses: docker/login-action@v3.7.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine Ferron version
shell: bash
run: |
FERRON_VERSION_CARGO="$(cat ferron/Cargo.toml | grep -E '^version' | sed -E 's|.*"([0-9a-zA-Z.+-]+)"$|\1|g')"
FERRON_VERSION_GIT="$(git tag --sort=-committerdate | head -n 1 | sed s/[^0-9a-zA-Z.+-]//g)"
if [ "$FERRON_VERSION_CARGO" != "" ]; then
echo "Version determined from Cargo.toml file"
echo "FERRON_VERSION=$FERRON_VERSION_CARGO" >> $GITHUB_ENV
elif [ "$FERRON_VERSION_GIT" != "" ]; then
echo "Version determined from the Git tag"
echo "FERRON_VERSION=$FERRON_VERSION_GIT" >> $GITHUB_ENV
else
echo "Can't determine the server version!" 2>&1
exit 1
fi
- name: Determine Docker tags
shell: bash
run: |
TAG_TYPE=${{ matrix.group }}
FERRON_MAJOR_VERSION=$(echo "$FERRON_VERSION" | cut -d '.' -f 1)
if [ "$TAG_TYPE" = "latest" ] || [ "$TAG_TYPE" = "" ]; then
DOCKER_HUB_TAGS="ferronserver/ferron:$FERRON_VERSION,ferronserver/ferron:$FERRON_MAJOR_VERSION"
DOCKER_GHCR_TAGS="ghcr.io/ferronweb/ferron:$FERRON_VERSION,ghcr.io/ferronweb/ferron:$FERRON_MAJOR_VERSION"
else
DOCKER_HUB_TAGS="ferronserver/ferron:$FERRON_VERSION-$TAG_TYPE,ferronserver/ferron:$FERRON_MAJOR_VERSION-$TAG_TYPE"
DOCKER_GHCR_TAGS="ghcr.io/ferronweb/ferron:$FERRON_VERSION-$TAG_TYPE,ghcr.io/ferronweb/ferron:$FERRON_MAJOR_VERSION-$TAG_TYPE"
fi
echo "DOCKER_TAGS=$DOCKER_HUB_TAGS,$DOCKER_GHCR_TAGS" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6.19.2
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ env.DOCKER_TAGS }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v3
with:
subject-name: index.docker.io/ferronserver/ferron
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true