Repository navigation
workflow updated #30
Workflow file for this run
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: | |
| tag: | |
| name: New tag | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Debug File List | |
| run: ls -R | |
| - name: Install SVN | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install subversion | |
| # ------------------------------------------- | |
| # KEEPING YOUR EXISTING README-FINDING LOGIC | |
| # ------------------------------------------- | |
| - name: Find Readme File | |
| id: find_readme | |
| run: | | |
| readme_file=$(find . -maxdepth 1 -type f -iname "readme.txt" | head -n 1) | |
| if [ -n "$readme_file" ]; then | |
| echo "Readme file found: $readme_file" | |
| echo "readme_file=$readme_file" >> $GITHUB_ENV | |
| else | |
| echo "::error::Readme file not found." | |
| exit 1 | |
| fi | |
| # ------------------------------------------- | |
| # KEEPING YOUR EXISTING RELEASE NOTES LOGIC | |
| # ------------------------------------------- | |
| - name: Extract Release Notes | |
| id: release_notes | |
| run: | | |
| changelog_section_start="== Changelog ==" | |
| current_tag="${{ github.ref_name }}" | |
| readme_file="${{ env.readme_file }}" | |
| version=${current_tag#refs/tags/} | |
| in_changelog=0 | |
| release_notes="" | |
| capturing_version=0 | |
| while IFS= read -r line; do | |
| if [[ "$line" == "$changelog_section_start" ]]; then | |
| in_changelog=1 | |
| continue | |
| fi | |
| if [[ $in_changelog -eq 1 && "$line" =~ ^= ]]; then | |
| if [[ "$line" == "= $version =" ]]; then | |
| capturing_version=1 | |
| elif [[ $capturing_version -eq 1 ]]; then | |
| break | |
| fi | |
| fi | |
| if [[ $capturing_version -eq 1 && -n "$line" ]]; then | |
| release_notes+="$line\n" | |
| fi | |
| done < "$readme_file" | |
| if [[ -z "$release_notes" ]]; then | |
| echo "::error::Failed to extract release notes for version $version." | |
| exit 1 | |
| fi | |
| echo "notes<<EOF" >> $GITHUB_OUTPUT | |
| printf "%b\n" "$release_notes" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| # ------------------------------------------- | |
| # BEGIN CUSTOM SVN DEPLOY LOGIC | |
| # ------------------------------------------- | |
| - name: Checkout WP.org SVN | |
| run: | | |
| svn co https://plugins.svn.wordpress.org/${{ github.event.repository.name }}/ svn-wp | |
| - name: Copy plugin files to trunk (excluding readme.txt) | |
| run: | | |
| rm -rf svn-wp/trunk/* | |
| rsync -av --exclude='readme.txt' --exclude='svn-wp' ./ svn-wp/trunk/ | |
| - name: Commit trunk update | |
| run: | | |
| cd svn-wp | |
| svn add --force trunk | |
| svn status | |
| svn commit -m "Update trunk for version ${{ github.ref_name }}" \ | |
| --username "${{ secrets.SVN_USERNAME }}" \ | |
| --password "${{ secrets.SVN_PASSWORD }}" | |
| - name: Create new SVN tag | |
| run: | | |
| version="${GITHUB_REF##*/}" | |
| cd svn-wp | |
| svn cp trunk tags/$version | |
| svn commit -m "Tag version $version" \ | |
| --username "${{ secrets.SVN_USERNAME }}" \ | |
| --password "${{ secrets.SVN_PASSWORD }}" | |
| - name: Update readme stable tag in both trunk and tag | |
| run: | | |
| version="${GITHUB_REF##*/}" | |
| # update readme in trunk | |
| sed -i "s/^Stable tag:.*/Stable tag: $version/" svn-wp/trunk/readme.txt | |
| # update readme in tag dir | |
| sed -i "s/^Stable tag:.*/Stable tag: $version/" svn-wp/tags/$version/readme.txt | |
| - name: Commit updated readmes (final) | |
| run: | | |
| cd svn-wp | |
| svn commit -m "Update stable tag to ${GITHUB_REF##*/}" \ | |
| --username "${{ secrets.SVN_USERNAME }}" \ | |
| --password "${{ secrets.SVN_PASSWORD }}" | |
| # ------------------------------------------- | |
| # CREATE GITHUB RELEASE (KEEP THIS AS IS) | |
| # ------------------------------------------- | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| body: ${{ steps.release_notes.outputs.notes }} | |
| env: | |
| SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} | |
| SVN_USERNAME: ${{ secrets.SVN_USERNAME }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |