-
-
Notifications
You must be signed in to change notification settings - Fork 29
266 lines (229 loc) · 8.43 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
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
name: Release
env:
PHP_VERSION: '8.1'
GPG_SIGNATURE: 'false'
GPG_EMAIL: '[email protected]'
on:
release:
types:
- published
jobs:
build:
name: Build `cecil.phar` binary
runs-on: ubuntu-latest
outputs:
previous_release: ${{ steps.previous_release.outputs.tag }}
version: ${{ steps.get_version.outputs.version }}
shasum: ${{ steps.sha256.outputs.shasum }}
permissions:
id-token: write # required for build provenance attestation
attestations: write # required for build provenance attestation
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: :psr, mbstring, intl, gettext, fileinfo, gd
tools: composer, box
coverage: none
- name: Restore/Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: |
vendor
tests/fixtures/website/themes
key: composer-ubuntu-latest-php-${{ env.PHP_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
composer-ubuntu-latest-php-${{ env.PHP_VERSION }}-
- name: Validate `composer.json`
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer validate
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: |
composer install --prefer-dist --no-progress
composer dump-autoload --optimize
- name: Run tests
run: composer run-script test
- name: Get previous release # for changelog generation
id: previous_release
run: |
echo "tag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`)" >> $GITHUB_OUTPUT
- name: Set current version # variable and create `VERSION` file
id: get_version
run: |
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "${GITHUB_REF#refs/tags/}" > VERSION
echo "VERSION: ${GITHUB_REF#refs/tags/}"
- name: Build `cecil.phar` binary
run: composer run-script build
- name: Check `cecil.phar`
run: |
cd dist
mkdir skeleton
php cecil.phar new:site skeleton --demo -f -n
php cecil.phar build skeleton
php cecil.phar show:content skeleton
rm -rf skeleton
- name: Check `cecil.phar` in debug mode
env:
CECIL_DEBUG: 'true'
run: |
cd dist
mkdir skeleton
php cecil.phar new:site skeleton --demo -f -n
php cecil.phar build skeleton -vvv
php cecil.phar show:content skeleton
- name: Calculate SHA256 checksum # for Brew formula
id: sha256
run: |
echo "shasum=$(shasum -a 256 ./dist/cecil.phar | awk '{printf $1}')" >> $GITHUB_OUTPUT
- name: Import GPG key # to sign `cecil.phar`
if: env.GPG_SIGNATURE == 'true' && github.event_name != 'pull_request'
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Sign `cecil.phar` with GPG # for GitHub release verification by PHIVE users
if: env.GPG_SIGNATURE == 'true'
run: |
gpg --local-user ${{ env.GPG_EMAIL }} \
--batch \
--yes \
--passphrase="${{ secrets.GPG_PASSPHRASE }}" \
--detach-sign \
--output dist/cecil.phar.asc \
dist/cecil.phar
- name: Generate build provenance attestation
id: attestation
uses: actions/attest-build-provenance@v2
with:
subject-path: dist/cecil.phar
show-summary: false
- name: Verify the `cecil.phar` binary
env:
GH_TOKEN: ${{ github.token }}
run: gh attestation verify dist/cecil.phar --repo ${{ github.repository }}
- name: Upload files
uses: actions/upload-artifact@v4
with:
name: cecil-${{ github.sha }}.phar
path: |
dist/cecil.*
if-no-files-found: error
- name: Summary
run: |
echo "- Built with PHP ${{ env.PHP_VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- Provenance attestation: ${{ steps.attestation.outputs.attestation-url }}" >> $GITHUB_STEP_SUMMARY
deploy_to_github: # GitHub release
name: Deploy to GitHub
runs-on: ubuntu-latest
needs: build
steps:
- name: Download files
uses: actions/download-artifact@v4
with:
name: cecil-${{ github.sha }}.phar
path: .
- name: Get release
id: release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add `cecil.phar` to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: cecil.phar
asset_name: cecil.phar
asset_content_type: application/octet-stream
- name: Add `cecil.phar.asc` to release
continue-on-error: true
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: cecil.phar.asc
asset_name: cecil.phar.asc
asset_content_type: application/octet-stream
- name: Generate changelog
id: changelog
uses: jaywcjlove/[email protected]
with:
base-ref: ${{ needs.build.outputs.previous_release }}
token: ${{ secrets.GITHUB_TOKEN }}
filter: (^[U|u]pdate|Merge)
- name: Update release # with changelog
id: update_release
uses: tubone24/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: |
${{ steps.changelog.outputs.changelog }}
---
- Documentation: <https://cecil.app/documentation/>
- Download: <https://cecil.app/download/>
- Self Update: `php cecil.phar self-update`
deploy_to_website: # https://cecil.app
name: Deploy to website
runs-on: ubuntu-latest
needs: build
if: "!github.event.release.prerelease"
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Download files
uses: actions/download-artifact@v4
with:
name: cecil-${{ github.sha }}.phar
path: dist
- name: Prepare and deploy files
run: bash ./scripts/deploy-dist.sh
env:
GITHUB_TOKEN: ${{ secrets.REPOS_TOKEN }}
update_homebrew_formula:
name: Update Homebrew Formulae
runs-on: macos-latest
needs: [build, deploy_to_github]
env:
COMMITTER_TOKEN: ${{ secrets.REPOS_TOKEN }}
steps:
- name: Bump Formula
if: "!github.event.release.prerelease"
uses: mislav/bump-homebrew-formula-action@v3
with:
formula-name: cecil
formula-path: Formula/cecil.rb
homebrew-tap: Cecilapp/homebrew-tap
base-branch: main
tag-name: ${{ needs.build.outputs.version }}
download-url: https://github.com/Cecilapp/Cecil/releases/download/${{ needs.build.outputs.version }}/cecil.phar
download-sha256: ${{ needs.build.outputs.shasum }}
commit-message: |
{{formulaName}} {{version}}
Created by https://github.com/mislav/bump-homebrew-formula-action
- name: Bump Beta Formula
if: "github.event.release.prerelease"
uses: mislav/bump-homebrew-formula-action@v3
with:
formula-name: cecil@beta
formula-path: Formula/[email protected]
homebrew-tap: Cecilapp/homebrew-tap
base-branch: main
tag-name: ${{ needs.build.outputs.version }}
download-url: https://github.com/Cecilapp/Cecil/releases/download/${{ needs.build.outputs.version }}/cecil.phar
download-sha256: ${{ needs.build.outputs.shasum }}
commit-message: |
{{formulaName}} {{version}}
Created by https://github.com/mislav/bump-homebrew-formula-action