-
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (132 loc) · 6.14 KB
/
Copy pathrelease.yml
File metadata and controls
163 lines (132 loc) · 6.14 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
name: Release
on:
push:
tags:
- 'v*'
- 'v*.*'
- 'v*.*.*'
permissions:
contents: write
jobs:
release:
name: Build and Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f
# uses: shivammathur/setup-php@2.37.0
with:
php-version: '8.2'
extensions: mbstring, intl, json
tools: composer:v2
coverage: none
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Get version from tag
id: get_version
run: |
TAG="${GITHUB_REF#refs/tags/}"
VERSION="${TAG#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Install PHP dependencies
run: composer install --no-dev --optimize-autoloader --prefer-dist --no-interaction
- name: Install Node dependencies
run: npm ci
- name: Update version in files
run: |
VERSION="${{ steps.get_version.outputs.version }}"
# Update plugin main file version
sed -i "s/Version: [0-9.]\+/Version: $VERSION/" sparxstar-gluon.php
sed -i "s/@version[[:space:]]\+[0-9.]\+/@version $VERSION/" sparxstar-gluon.php
sed -i "s/define( 'SPARXSTAR_GLUON_VERSION', '[0-9.]\+' );/define( 'SPARXSTAR_GLUON_VERSION', '$VERSION' );/" sparxstar-gluon.php
# Update package.json version
npm version $VERSION --no-git-tag-version --allow-same-version
# Update composer.json version if it exists
if grep -q '"version"' composer.json; then
sed -i "s/\"version\": \"[0-9.]\+\"/\"version\": \"$VERSION\"/" composer.json
fi
- name: Build assets
run: |
npm run build
echo "✓ Assets built successfully"
- name: Generate POT file
run: |
# Install WP-CLI if needed
if ! command -v wp &> /dev/null; then
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
fi
# Create languages directory
mkdir -p languages
# Generate POT file
wp i18n make-pot . languages/plugin-textdomain.pot --domain=plugin-textdomain --allow-root || true
- name: Create distribution directory
run: |
mkdir -p dist
# Copy files excluding those in .distignore
rsync -av --exclude-from=.distignore . dist/sparxstar-gluon/
echo "✓ Distribution directory created"
- name: Generate checksums
id: checksums
run: |
cd dist
# Create zip file
zip -r sparxstar-gluon.zip sparxstar-gluon/
# Generate checksums
md5sum sparxstar-gluon.zip > sparxstar-gluon.zip.md5
sha256sum sparxstar-gluon.zip > sparxstar-gluon.zip.sha256
# Save checksums to output
MD5=$(cat sparxstar-gluon.zip.md5 | awk '{print $1}')
SHA256=$(cat sparxstar-gluon.zip.sha256 | awk '{print $1}')
echo "md5=$MD5" >> $GITHUB_OUTPUT
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
echo "MD5: $MD5"
echo "SHA256: $SHA256"
- name: Generate changelog
id: changelog
run: |
# Extract changelog for current version if CHANGELOG.md exists
if [ -f CHANGELOG.md ]; then
VERSION="${{ steps.get_version.outputs.version }}"
sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | sed '$d' > /tmp/current_changelog.md
if [ -s /tmp/current_changelog.md ]; then
cat /tmp/current_changelog.md
else
echo "Release $VERSION" > /tmp/current_changelog.md
fi
else
echo "Release ${{ steps.get_version.outputs.version }}" > /tmp/current_changelog.md
fi
# Add checksums to changelog
echo "" >> /tmp/current_changelog.md
echo "## Checksums" >> /tmp/current_changelog.md
echo "" >> /tmp/current_changelog.md
echo "**MD5:** \`${{ steps.checksums.outputs.md5 }}\`" >> /tmp/current_changelog.md
echo "**SHA256:** \`${{ steps.checksums.outputs.sha256 }}\`" >> /tmp/current_changelog.md
- name: Create GitHub Release
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe
# uses: softprops/action-gh-release@v2.6.1
with:
files: |
dist/sparxstar-gluon.zip
dist/sparxstar-gluon.zip.md5
dist/sparxstar-gluon.zip.sha256
body_path: /tmp/current_changelog.md
draft: false
prerelease: ${{ contains(steps.get_version.outputs.version, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: plugin-release-${{ steps.get_version.outputs.version }}
path: dist/sparxstar-gluon.zip
retention-days: 30