-
-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (150 loc) · 4.82 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
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
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: 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'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
with:
version: 9
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: dom, curl, libxml, mbstring, zip
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: none
- name: Cache composer vendor files
id: cache-composer
uses: actions/cache@v3
env:
cache-name: cache-composer
with:
path: /vendor
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }}
- 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