-
Notifications
You must be signed in to change notification settings - Fork 14
64 lines (56 loc) · 2.02 KB
/
Copy pathrelease.yml
File metadata and controls
64 lines (56 loc) · 2.02 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
name: Release
on:
push:
branches:
- trunk
permissions:
actions: write
contents: write
jobs:
check_and_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Check for version change
id: version_check
run: |
OLD_VERSION=$(git show HEAD^:remote-data-blocks.php 2>/dev/null | sed -n 's/.*Version: *//p' | head -n1 | tr -d '[:space:]')
NEW_VERSION=$(git show HEAD:remote-data-blocks.php | sed -n 's/.*Version: *//p' | head -n1 | tr -d '[:space:]')
if [ -z "$OLD_VERSION" ] || [ "$OLD_VERSION" = "$NEW_VERSION" ]; then
echo "No version change detected"
exit 0
fi
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "Version changed from $OLD_VERSION to $NEW_VERSION"
- name: Setup PHP
if: steps.version_check.outputs.new_version
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # 2.37.1
with:
php-version: '8.1'
- name: Setup Node
if: steps.version_check.outputs.new_version
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- name: Build plugin zip
if: steps.version_check.outputs.new_version
run: npm ci && npm run plugin-zip
- name: Create Release
if: steps.version_check.outputs.new_version
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1
with:
tag_name: v${{ steps.version_check.outputs.new_version }}
files: remote-data-blocks.zip
generate_release_notes: true
- name: Deploy to WordPress.org
if: steps.version_check.outputs.new_version
env:
GH_TOKEN: ${{ github.token }}
run: |
gh workflow run deploy.yml \
--ref trunk \
-f version=${{ steps.version_check.outputs.new_version }} \
-f ref=v${{ steps.version_check.outputs.new_version }}