Skip to content

Commit fba740c

Browse files
committed
Deploy Workflow now creates tag & release on GH
1 parent 00c2c37 commit fba740c

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Deploy to WordPress.org
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
jobs:
8+
deploy:
9+
name: Deploy to WordPress.org SVN
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
env:
14+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
submodules: true
20+
fetch-depth: 2
21+
22+
- name: Check if version changed
23+
id: version_check
24+
run: |
25+
CURRENT_VERSION=$(grep -m1 'Version:' Waymark.php | awk '{print $NF}')
26+
27+
if git show HEAD~1:Waymark.php > /dev/null 2>&1; then
28+
PREVIOUS_VERSION=$(git show HEAD~1:Waymark.php | grep -m1 'Version:' | awk '{print $NF}')
29+
else
30+
PREVIOUS_VERSION=""
31+
fi
32+
33+
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
34+
echo "previous=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT
35+
36+
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
37+
echo "changed=true" >> $GITHUB_OUTPUT
38+
echo "Version changed: $PREVIOUS_VERSION → $CURRENT_VERSION"
39+
else
40+
echo "changed=false" >> $GITHUB_OUTPUT
41+
echo "Version unchanged ($CURRENT_VERSION), skipping deploy."
42+
fi
43+
44+
- name: Strip waymark-js to dist/ only
45+
if: steps.version_check.outputs.changed == 'true'
46+
run: find waymark-js -mindepth 1 -maxdepth 1 ! -name 'dist' -exec rm -rf {} +
47+
48+
- name: Deploy to WordPress.org
49+
if: steps.version_check.outputs.changed == 'true'
50+
uses: 10up/action-wordpress-plugin-deploy@stable
51+
env:
52+
SVN_USERNAME: ${{ secrets.WORDPRESS_USERNAME }}
53+
SVN_PASSWORD: ${{ secrets.WORDPRESS_PASSWORD }}
54+
SLUG: waymark
55+
VERSION: ${{ steps.version_check.outputs.current }}
56+
57+
- name: Create tag and release
58+
if: steps.version_check.outputs.changed == 'true'
59+
uses: softprops/action-gh-release@v2
60+
with:
61+
tag_name: v${{ steps.version_check.outputs.current }}
62+
name: v${{ steps.version_check.outputs.current }}
63+
make_latest: true
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)