1- name : Release Plugin
1+ name : Deploy to WordPress.org
22
33on :
44 push :
55 branches :
66 - main
7+ tags :
8+ - ' *'
9+
10+ permissions :
11+ contents : read
712
813jobs :
9- build-and-release :
10- name : Build and Release
14+ deploy :
15+ name : Build and Deploy Plugin
1116 runs-on : ubuntu-latest
1217 permissions :
13- contents : write # Required to create releases and tags
18+ contents : read
1419
1520 steps :
21+ # actions/checkout v4 is intentionally used here instead of a newer major version.
22+ # 10up/action-wordpress-plugin-deploy requires v4 for compatibility.
23+ # See: https://github.com/marketplace/actions/wordpress-plugin-deploy#example-workflow-files
1624 - name : Checkout Code
17- uses : actions/checkout@v4
25+ uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
26+ with :
27+ fetch-depth : 0
28+
29+ - name : Ensure tag is on main
30+ if : startsWith(github.ref, 'refs/tags/')
31+ shell : bash
32+ run : |
33+ git fetch origin main:refs/remotes/origin/main
34+ TAG_COMMIT="$(git rev-list -n 1 "${GITHUB_REF_NAME}")"
35+
36+ if ! git merge-base --is-ancestor "${TAG_COMMIT}" origin/main; then
37+ echo "::error::Release tags must point to commits that exist on main."
38+ exit 1
39+ fi
40+
41+ - name : Validate release tag format
42+ if : startsWith(github.ref, 'refs/tags/')
43+ shell : bash
44+ run : |
45+ if [[ ! "${GITHUB_REF_NAME}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
46+ echo "::error::Release tags must use numeric format like 1.0.0, not v1.0.0."
47+ exit 1
48+ fi
1849
1950 - name : Setup PHP
20- uses : shivammathur/setup-php@v2
51+ uses : shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # 2.37.1
2152 with :
2253 php-version : ' 8.2'
23- tools : composer
54+ tools : composer:v2
55+ coverage : none
2456
25- - name : Setup Node.js
26- uses : actions/setup-node@v4
57+ - name : Install PHP dependencies
58+ uses : ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
2759 with :
28- node-version : ' 20 '
60+ composer-options : ' --no-dev --optimize-autoloader '
2961
30- - name : Get Version
31- id : get_version
32- run : echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
62+ - name : Setup Node.js
63+ uses : actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # 6.4.0
64+ with :
65+ node-version-file : ' .nvmrc'
66+ cache : ' npm'
3367
34- - name : Build Plugin ZIP
35- run : make zip
68+ - name : Install npm dependencies & build assets
69+ shell : bash
70+ run : |
71+ npm ci
72+ npm run build
3673
37- - name : Create Release and Upload Asset
38- uses : softprops/action-gh-release@v1
74+ - name : WordPress Plugin Deploy
75+ id : deploy
76+ uses : 10up/action-wordpress-plugin-deploy@54bd289b8525fd23a5c365ec369185f2966529c2 # 2.3.0
3977 with :
40- tag_name : v${{ steps.get_version.outputs.VERSION }}
41- name : v${{ steps.get_version.outputs.VERSION }}
42- generate_release_notes : true
43- files : rt-carousel.zip
78+ generate-zip : ' true'
79+ dry-run : ${{ github.ref == 'refs/heads/main' }}
4480 env :
45- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
81+ SLUG : ' rt-carousel'
82+ ASSETS_DIR : ' wp-assets'
83+ SVN_USERNAME : ${{ secrets.SVN_USERNAME }}
84+ SVN_PASSWORD : ${{ secrets.SVN_PASSWORD }}
85+ VERSION : ' ${{ github.ref_name }}'
4686
47-
87+ - name : Upload Package Artifact
88+ uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
89+ with :
90+ name : rt-carousel-${{ github.ref_name }}
91+ path : ${{ steps.deploy.outputs.zip-path }}
92+
93+ github-release :
94+ name : Upload GitHub Release Artifact
95+ needs : deploy
96+ if : startsWith(github.ref, 'refs/tags/')
97+ runs-on : ubuntu-latest
98+ permissions :
99+ contents : write
100+
101+ steps :
102+ - name : Download Package Artifact
103+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
104+ with :
105+ name : rt-carousel-${{ github.ref_name }}
106+ path : release-artifact
107+
108+ - name : Upload Release Artifact
109+ uses : softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
110+ with :
111+ tag_name : ${{ github.ref_name }}
112+ name : ${{ github.ref_name }}
113+ generate_release_notes : true
114+ files : release-artifact/rt-carousel.zip
0 commit comments