|
1 | 1 | name: Deploy to WordPress.org |
| 2 | + |
2 | 3 | on: |
3 | 4 | push: |
4 | 5 | tags: |
5 | | - - "*" |
| 6 | + - "*" |
| 7 | + |
6 | 8 | jobs: |
7 | 9 | tag: |
8 | 10 | name: New tag |
9 | 11 | runs-on: ubuntu-latest |
10 | 12 | steps: |
11 | | - - uses: actions/checkout@master |
12 | | - #- name: Build # Remove or modify this step as needed |
13 | | - # run: | |
14 | | - # npm install |
15 | | - # npm run build |
16 | | - - name: Install SVN ( Subversion ) |
17 | | - run: | |
18 | | - sudo apt-get update |
19 | | - sudo apt-get install subversion |
20 | | - - name: WordPress Plugin Deploy |
21 | | - id: deploy |
22 | | - uses: 10up/action-wordpress-plugin-deploy@stable |
23 | | - with: |
24 | | - generate-zip: true |
25 | | - env: |
26 | | - SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} |
27 | | - SVN_USERNAME: ${{ secrets.SVN_USERNAME }} |
28 | | - #SLUG: my-super-cool-plugin # optional, remove if GitHub repo name matches SVN slug, including capitalization |
29 | | - - name: Create GitHub release |
30 | | - uses: softprops/action-gh-release@v1 |
31 | | - with: |
32 | | - files: ${{github.workspace}}/${{ github.event.repository.name }}.zip |
33 | | - env: |
34 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 13 | + - uses: actions/checkout@v3 |
| 14 | + |
| 15 | + - name: Debug File List |
| 16 | + run: ls -R |
| 17 | + |
| 18 | + - name: Install SVN (Subversion) |
| 19 | + run: | |
| 20 | + sudo apt-get update |
| 21 | + sudo apt-get install subversion |
| 22 | +
|
| 23 | + - name: Find Readme File |
| 24 | + id: find_readme |
| 25 | + run: | |
| 26 | + readme_file=$(find . -type f -iname "readme.*" | head -n 1) |
| 27 | + if [ -n "$readme_file" ]; then |
| 28 | + echo "Readme file found: $readme_file" |
| 29 | + echo "readme_file=$readme_file" >> $GITHUB_ENV |
| 30 | + else |
| 31 | + echo "::error::Readme file not found." |
| 32 | + exit 1 |
| 33 | + fi |
| 34 | +
|
| 35 | + - name: Extract Release Notes |
| 36 | + id: release_notes |
| 37 | + run: | |
| 38 | + changelog_section_start="== Changelog ==" |
| 39 | + current_tag="${{ github.ref_name }}" |
| 40 | + readme_file="${{ env.readme_file }}" |
| 41 | +
|
| 42 | + # Extract the version (strip 'refs/tags/' if it exists) |
| 43 | + version=${current_tag#refs/tags/} |
| 44 | +
|
| 45 | + # Read lines from the changelog section |
| 46 | + in_changelog=0 |
| 47 | + release_notes="" |
| 48 | + capturing_version=0 |
| 49 | + while IFS= read -r line; do |
| 50 | + # Start capturing after finding the changelog section |
| 51 | + if [[ "$line" == "$changelog_section_start" ]]; then |
| 52 | + in_changelog=1 |
| 53 | + continue |
| 54 | + fi |
| 55 | +
|
| 56 | + # Stop capturing if we encounter a new version or the end of the file |
| 57 | + if [[ $in_changelog -eq 1 && "$line" =~ ^= ]]; then |
| 58 | + # Check if this is the current version |
| 59 | + if [[ "$line" == "= $version =" ]]; then |
| 60 | + capturing_version=1 |
| 61 | + elif [[ $capturing_version -eq 1 ]]; then |
| 62 | + # Stop if we see the next version |
| 63 | + break |
| 64 | + fi |
| 65 | + fi |
| 66 | +
|
| 67 | + # Capture lines only for the current version |
| 68 | + if [[ $capturing_version -eq 1 && -n "$line" ]]; then |
| 69 | + release_notes+="$line\n" |
| 70 | + fi |
| 71 | + done < "$readme_file" |
| 72 | +
|
| 73 | + if [[ -z "$release_notes" ]]; then |
| 74 | + echo "::error::Failed to extract release notes for version $version." |
| 75 | + exit 1 |
| 76 | + fi |
| 77 | +
|
| 78 | + # Debug: Print extracted release notes |
| 79 | + echo "Extracted release notes for version $version:" |
| 80 | + printf "%b" "$release_notes" |
| 81 | +
|
| 82 | + # Set output |
| 83 | + echo "::set-output name=notes::$(printf "%b" "$release_notes")" |
| 84 | +
|
| 85 | + - name: Debug Release Notes |
| 86 | + run: | |
| 87 | + echo "Debugging Release Notes:" |
| 88 | + echo "${{ steps.release_notes.outputs.notes }}" |
| 89 | +
|
| 90 | + - name: WordPress Plugin Deploy |
| 91 | + id: deploy |
| 92 | + uses: 10up/action-wordpress-plugin-deploy@stable |
| 93 | + with: |
| 94 | + generate-zip: true |
| 95 | + |
| 96 | + - name: Create GitHub Release |
| 97 | + uses: softprops/action-gh-release@v2 |
| 98 | + with: |
| 99 | + tag_name: ${{ github.ref_name }} |
| 100 | + body: ${{ steps.release_notes.outputs.notes }} |
| 101 | + files: ${{github.workspace}}/${{ github.event.repository.name }}.zip |
| 102 | + |
| 103 | +env: |
| 104 | + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} |
| 105 | + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} |
| 106 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments