-
-
Notifications
You must be signed in to change notification settings - Fork 0
205 lines (179 loc) · 5.87 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
name: tag-release
on:
push:
branches:
- main
jobs:
# Perform a Dry Run on the tag action and get the proposed version
check_tag:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Bump version and push tag
id: check_tag
uses: anothrNick/[email protected]
env:
WITH_V: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: none
RELEASE_BRANCHES: main
DRY_RUN: true
outputs:
bump: ${{ steps.check_tag.outputs.part }}
new_tag: ${{ steps.check_tag.outputs.new_tag }}
# With the version from the last step, write it to the entry PHP file and create the changelog file
version:
runs-on: ubuntu-latest
needs: check_tag
if: needs.check_tag.outputs.bump != '' && needs.check_tag.outputs.bump != 'none'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Update version in PHP file
run: |
VERSION=${{ needs.check_tag.outputs.new_tag }}
VERSION=${VERSION#v}
sed -i "s/Version: .*/Version: $VERSION/" inertia-wordpress.php
- name: Process changelog
id: changelog_file
run: |
if [[ ! -z $(cat changelog/next.md) ]] ; then
echo "changelog=${{ needs.check_tag.outputs.new_tag }}-$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
mv changelog/next.md changelog/${{ needs.check_tag.outputs.new_tag }}-$(date +'%Y-%m-%d').md
touch changelog/next.md
else
echo "changelog=next" >> $GITHUB_OUTPUT
fi
- name: Commit changes to changelog folder
continue-on-error: true
run: |
git config --global user.email "[email protected]"
git config --global user.name "evoMark Action"
git add changelog/ inertia-wordpress.php
git commit -m "Chore: Updated changelog and version"
git push
outputs:
changelog: ${{ steps.changelog_file.outputs.changelog }}
# Actually create the git tag
tag:
runs-on: ubuntu-latest
needs:
- check_tag
- version
if: needs.check_tag.outputs.bump != '' && needs.check_tag.outputs.bump != 'none'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Fetch and checkout the latest commit
run: |
git fetch origin main
git checkout origin/main
- name: Bump version and push tag
id: tag
uses: anothrNick/[email protected]
env:
WITH_V: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: none
RELEASE_BRANCHES: main
outputs:
bump: ${{ steps.tag.outputs.part }}
new_tag: ${{ steps.tag.outputs.new_tag }}
# Create a release with asset
release:
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- tag
- version
if: needs.tag.outputs.bump != '' && needs.tag.outputs.bump != 'none'
env:
PHP_VERSION: "8.3"
PHP_EXTENSIONS: dom, curl, libxml, mbstring, zip
PHP_CACHE_KEY: extension-cache-v1
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch and checkout the latest commit
run: |
git fetch origin main
git checkout origin/main
- uses: pnpm/action-setup@v2
with:
version: 9
- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ env.PHP_VERSION }}
extensions: ${{ env.PHP_EXTENSIONS }}
key: ${{ env.PHP_CACHE_KEY }}
- name: Cache PHP extensions
uses: actions/cache@v4
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: ${{ env.PHP_EXTENSIONS }}
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: none
- name: Get Composer cache dir
id: composer-cache-dir
run: echo dir=$(composer config cache-files-dir) >> $GITHUB_OUTPUT
- name: Cache composer vendor files
id: cache-composer
uses: actions/[email protected]
with:
key: composer-cache-${{ hashFiles('**/composer.lock') }}
path: ${{ steps.composer-cache-dir.outputs.dir }}
restore-keys: composer-cache-
- name: Install dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 1
max_attempts: 5
command: composer install --no-interaction
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- run: pnpm -r install
- name: Build assets
run: pnpm -r run build
- name: Create ZIP for release
run: |
mkdir -p temp_inertia-wordpress
rsync -a --exclude-from=exclude.txt . temp_inertia-wordpress/
mv temp_inertia-wordpress inertia-wordpress
zip -r inertia-wordpress.zip inertia-wordpress
rm -rf inertia-wordpress
- name: Create Github release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.tag.outputs.new_tag }}
name: ${{ needs.tag.outputs.new_tag }}
body_path: changelog/${{ needs.version.outputs.changelog }}.md
draft: false
prerelease: false
files: inertia-wordpress.zip