Created
November 9, 2025 04:37
-
-
Save manchumahara/94ac9d3bb7ad22696f0d43516ff89789 to your computer and use it in GitHub Desktop.
github to wordpress dir plugin release workflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to WordPress.org | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| jobs: | |
| deploy: | |
| name: Deploy WordPress Plugin | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Lightweight checkout | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 1 | |
| - name: Install SVN (Subversion) | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y subversion | |
| - name: Find Readme File | |
| id: find_readme | |
| run: | | |
| for file in readme.txt Readme.txt README.txt README.md Readme.md readme.md; do | |
| if [ -f "$file" ]; then | |
| echo "Readme file found: $file" | |
| echo "readme_file=$file" >> $GITHUB_ENV | |
| break | |
| fi | |
| done | |
| source $GITHUB_ENV | |
| if [ -z "$readme_file" ]; then | |
| echo "::error::Readme file not found." | |
| exit 1 | |
| fi | |
| - name: Extract Release Notes | |
| id: release_notes | |
| run: | | |
| changelog_section_start="== Changelog ==" | |
| readme_file="$readme_file" | |
| if [[ "$GITHUB_REF" == refs/tags/* ]]; then | |
| plugin_version="${GITHUB_REF#refs/tags/}" | |
| echo "Plugin version: $plugin_version" | |
| else | |
| echo "::error::This workflow must be triggered by a tag push." | |
| exit 1 | |
| fi | |
| in_changelog=0 | |
| found_version=0 | |
| release_notes="" | |
| while IFS= read -r line; do | |
| # Start processing after the changelog header | |
| if [[ "$line" == "$changelog_section_start" ]]; then | |
| in_changelog=1 | |
| continue | |
| fi | |
| # Skip until changelog section found | |
| if [[ $in_changelog -eq 0 ]]; then | |
| continue | |
| fi | |
| # Detect version header | |
| if [[ "$line" == "= ${plugin_version} =" ]]; then | |
| found_version=1 | |
| continue | |
| fi | |
| # Stop when next version header found | |
| if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^= [0-9]+\.[0-9]+\.[0-9]+ =$'; then | |
| break | |
| fi | |
| # Collect lines for current version | |
| if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^\*'; then | |
| release_notes+="${line}\n" | |
| fi | |
| done < "$readme_file" | |
| if [[ -z "$release_notes" ]]; then | |
| echo "::error::Failed to extract release notes for version ${plugin_version}." | |
| exit 1 | |
| fi | |
| echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV | |
| echo -e "$release_notes" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Cleanup unnecessary files before deploy | |
| run: | | |
| find . -type f -name "*.zip" -delete | |
| find . -type f -name "*.psd" -delete | |
| # Phase 1: Deploy only trunk | |
| - name: Deploy trunk (safe commit) | |
| uses: 10up/[email protected] | |
| with: | |
| skip-assets: true | |
| skip-tag: true | |
| generate-zip: true | |
| # Phase 2: Tag the release | |
| - name: Tag release version | |
| uses: 10up/[email protected] | |
| with: | |
| skip-trunk: true | |
| generate-zip: false | |
| # Optional retry if SVN commit fails (e.g., connection reset) | |
| - name: Retry SVN Deploy (if failed) | |
| if: failure() | |
| run: | | |
| echo "Retrying SVN deploy after 30 seconds..." | |
| sleep 30 | |
| shell: bash | |
| - name: Retry Trunk Deploy | |
| if: failure() | |
| uses: 10up/[email protected] | |
| with: | |
| skip-assets: true | |
| skip-tag: true | |
| generate-zip: true | |
| # Create GitHub release with extracted changelog | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| body: ${{ env.RELEASE_NOTES }} | |
| files: ${{github.workspace}}/${{ github.event.repository.name }}.zip | |
| env: | |
| SVN_URL: https://plugins.svn.wordpress.org/${{ github.event.repository.name }} | |
| SVN_USERNAME: ${{ secrets.SVN_USERNAME }} | |
| SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment