-
-
Notifications
You must be signed in to change notification settings - Fork 10
267 lines (220 loc) · 9.63 KB
/
CI.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
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
name: CI
on:
push:
branches:
- '*'
tags:
- '*'
jobs:
check-release:
name: Check release
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
if: startsWith(github.ref, 'refs/tags/')
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Save release URL
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "${{ steps.create_release.outputs.upload_url }}" > release-url.txt
- name: Store release URL into artifact
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v2
with:
name: release-url
path: release-url.txt
build-ubuntu:
runs-on: ${{ matrix.os }}
needs: [check-release]
strategy:
matrix:
os: [ubuntu-latest]
rust: [stable]
steps:
- uses: actions/checkout@master
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Setup PHP cache
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup Rust cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- name: (release only) Fetch release URL
uses: actions/download-artifact@v2
id: download_artifacts
if: startsWith(github.ref, 'refs/tags/')
with:
name: release-url
path: artifacts
- name: Prepare build metadata
id: vars
run: |
artifacts_path="${{ steps.download_artifacts.outputs.download-path }}"
[[ $artifacts_path == "" ]] && artifacts_path="." # Prevents touching the "/" path.
if touch "$artifacts_path/release-url.txt" ; then
RELEASE_URL="$(cat "$artifacts_path/release-url.txt")"
echo "Release url: $RELEASE_URL"
echo "RELEASE_URL=$RELEASE_URL" >> $GITHUB_OUTPUT
fi
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION="${GITHUB_REF#refs/tags/*}"" >> $GITHUB_OUTPUT
export RELEASE_OS="${{ matrix.os }}"
echo "RELEASE_OS=${RELEASE_OS/-latest/}" >> $GITHUB_OUTPUT
echo "RELEASE_DATE=`date "+%Y-%m-%d %H:%M:%S"`" >> $GITHUB_OUTPUT
- name: (release only) Save build metadata
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "${{ steps.vars.outputs.RELEASE_VERSION }} ${{ steps.vars.outputs.RELEASE_OS }} (${{ steps.vars.outputs.RELEASE_DATE }})" > .version
- name: (main branch only) Save build metadata
if: github.ref == 'refs/heads/main'
run: |
echo "nightly ${{ steps.vars.outputs.GITHUB_SHA_SHORT }} ${{ steps.vars.outputs.RELEASE_OS }} (${{ steps.vars.outputs.RELEASE_DATE }})" > .version
- name: (Mac only) Install "coreutils" to be able to get file hash
if: runner.os == 'macOS'
run: |
brew install coreutils
- name: 🛒 Download Caddy
run: |
bin/download_caddy.bash
- name: 🏗 Build
run: |
cat .version
cargo build --release
- name: 🐘 Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- name: 🧪 Prepare test setup
run: |
composer install
- name: ⚗️ Execute tests
run: |
php vendor/bin/phpunit
- name: (main branch only) Push nightly build
uses: actions/upload-artifact@v2
if: github.ref == 'refs/heads/main'
with:
name: rymfony.${{ steps.vars.outputs.RELEASE_OS }}
path: target/release/rymfony
- name: (release only) Upload Release
uses: actions/upload-release-asset@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.vars.outputs.RELEASE_URL }}
asset_path: target/release/rymfony
asset_name: rymfony-${{ steps.vars.outputs.RELEASE_OS }}-${{ steps.vars.outputs.RELEASE_VERSION }}
asset_content_type: application/zip
build-windows:
runs-on: ${{ matrix.os }}
needs: [check-release]
strategy:
matrix:
os: [windows-latest]
rust: [stable]
steps:
- uses: actions/checkout@master
- name: Setup Rust cache
uses: actions/cache@v2
with:
path: |
%HOME%/.cargo/bin/
%HOME%/.cargo/registry/index/
%HOME%/.cargo/registry/cache/
%HOME%/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- name: (release only) Fetch release URL
uses: actions/download-artifact@v2
id: download_artifacts
if: startsWith(github.ref, 'refs/tags/')
with:
name: release-url
path: artifacts
- name: Prepare build metadata
id: vars
shell: bash
run: |
artifacts_path="${{ steps.download_artifacts.outputs.download-path }}"
[[ $artifacts_path == "" ]] && artifacts_path="." # Prevents touching the "/" path.
if touch "$artifacts_path/release-url.txt" ; then
RELEASE_URL="$(cat "$artifacts_path/release-url.txt")"
echo "Release url: $RELEASE_URL"
echo "RELEASE_URL=$RELEASE_URL" >> $GITHUB_OUTPUT
fi
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION="${GITHUB_REF#refs/tags/*}"" >> $GITHUB_OUTPUT
export RELEASE_OS="${{ matrix.os }}"
echo "RELEASE_OS=${RELEASE_OS/-latest/}" >> $GITHUB_OUTPUT
echo "RELEASE_DATE=`date "+%Y-%m-%d %H:%M:%S"`" >> $GITHUB_OUTPUT
- name: (release only) Save build metadata
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "${{ steps.vars.outputs.RELEASE_VERSION }} ${{ steps.vars.outputs.RELEASE_OS }} (${{ steps.vars.outputs.RELEASE_DATE }})" > .version
- name: (main branch only) Save build metadata
if: github.ref == 'refs/heads/main'
run: |
echo "nightly ${{ steps.vars.outputs.GITHUB_SHA_SHORT }} ${{ steps.vars.outputs.RELEASE_OS }} (${{ steps.vars.outputs.RELEASE_DATE }})" > .version
- name: 🛒 Download Caddy
run: |
bin/download_caddy.ps1
- name: 🏗 Build
run: |
cat .version
cargo build --release
- name: (main branch only) Push nightly build
uses: actions/upload-artifact@v2
if: github.ref == 'refs/heads/main'
with:
name: rymfony.${{ steps.vars.outputs.RELEASE_OS }}
path: target/release/rymfony.exe
- name: (release only) Upload Release
uses: actions/upload-release-asset@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.vars.outputs.RELEASE_URL }}
asset_path: target/release/rymfony.exe
asset_name: rymfony-${{ steps.vars.outputs.RELEASE_OS }}-${{ steps.vars.outputs.RELEASE_VERSION }}.exe
asset_content_type: application/zip
remove-artifacts:
name: Remove artifacts
runs-on: ubuntu-latest
needs:
- build-ubuntu
- build-windows
steps:
- name: Remove URL artifacts
uses: geekyeggo/delete-artifact@v1
if: startsWith(github.ref, 'refs/tags/')
with: { name: release-url }