|
6 | 6 | - "*" |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - tag: |
10 | | - name: New tag |
| 9 | + update-trunk: |
| 10 | + name: Update trunk in WordPress SVN |
11 | 11 | runs-on: ubuntu-latest |
| 12 | + |
12 | 13 | steps: |
13 | 14 | - uses: actions/checkout@v3 |
14 | 15 |
|
15 | | - - name: Debug File List |
16 | | - run: ls -R |
17 | | - |
18 | | - - name: Install SVN (Subversion) |
| 16 | + - name: Install SVN |
19 | 17 | run: | |
20 | 18 | sudo apt-get update |
21 | | - sudo apt-get install subversion |
| 19 | + sudo apt-get install -y subversion |
| 20 | +
|
| 21 | + - name: WordPress Plugin Deploy (Trunk Only) |
| 22 | + uses: 10up/action-wordpress-plugin-deploy@stable |
| 23 | + with: |
| 24 | + skip-existing-assets: true |
| 25 | + skip-tags: true |
| 26 | + generate-zip: false |
| 27 | + |
| 28 | + env: |
| 29 | + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} |
| 30 | + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} |
| 31 | + |
| 32 | + tag-release: |
| 33 | + name: Tag SVN Release |
| 34 | + runs-on: ubuntu-latest |
| 35 | + needs: update-trunk |
22 | 36 |
|
23 | | - - name: Find Readme File |
24 | | - id: find_readme |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v3 |
| 39 | + |
| 40 | + - name: Install SVN |
25 | 41 | run: | |
26 | | - for file in readme.txt Readme.txt README.txt README.md Readme.md readme.md; do |
27 | | - if [ -f "$file" ]; then |
28 | | - echo "Readme file found: $file" |
29 | | - echo "readme_file=$file" >> $GITHUB_ENV |
30 | | - break |
31 | | - fi |
32 | | - done |
33 | | -
|
34 | | - # Ensure the variable is available within the current step |
35 | | - source $GITHUB_ENV |
36 | | -
|
37 | | - if [ -z "$readme_file" ]; then |
38 | | - echo "::error::Readme file not found." |
39 | | - exit 1 |
40 | | - fi |
41 | | -
|
42 | | - - name: Extract Release Notes |
43 | | - id: release_notes |
| 42 | + sudo apt-get update |
| 43 | + sudo apt-get install -y subversion |
| 44 | +
|
| 45 | + - name: Extract Plugin Version |
| 46 | + id: version |
44 | 47 | run: | |
45 | | - changelog_section_start="== Changelog ==" |
46 | | - readme_file="$readme_file" |
47 | | -
|
48 | | - # Extract the tag name from GITHUB_REF (plugin_version) |
49 | | - if [[ "$GITHUB_REF" == refs/tags/* ]]; then |
50 | | - plugin_version="${GITHUB_REF#refs/tags/}" |
51 | | - echo "DEBUG: Plugin latest version found: $plugin_version." |
52 | | - else |
53 | | - echo "::error::This workflow must be triggered by a tag push." |
54 | | - exit 1 |
55 | | - fi |
56 | | -
|
57 | | - in_changelog=0 |
58 | | - found_version=0 |
59 | | - release_notes="" |
60 | | -
|
61 | | - echo "DEBUG: Starting to extract release notes from $readme_file for version $plugin_version." |
62 | | -
|
63 | | - while IFS= read -r line; do |
64 | | - echo "DEBUG: Processing line: $line" |
65 | | -
|
66 | | - # Start processing after the changelog header |
67 | | - if [[ "$line" == "$changelog_section_start" ]]; then |
68 | | - in_changelog=1 |
69 | | - echo "DEBUG: Found changelog section header." |
70 | | - continue |
71 | | - fi |
72 | | -
|
73 | | - # Skip if not in changelog section |
74 | | - if [[ $in_changelog -eq 0 ]]; then |
75 | | - echo "DEBUG: Skipping line (not in changelog section)." |
76 | | - continue |
77 | | - fi |
78 | | -
|
79 | | - # Check for the current version header |
80 | | - if [[ "$line" == "= ${plugin_version} =" ]]; then |
81 | | - found_version=1 |
82 | | - echo "DEBUG: Found version header for $plugin_version." |
83 | | - continue |
84 | | - fi |
85 | | -
|
86 | | - # Break if a new version header is found after the current version |
87 | | - if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^= [0-9]+\.[0-9]+\.[0-9]+ =$'; then |
88 | | - echo "DEBUG: Found a new version header. Stopping collection." |
89 | | - break |
90 | | - fi |
91 | | -
|
92 | | - # Collect lines starting with '*' if we are in the current version section |
93 | | - if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^\*'; then |
94 | | - echo "DEBUG: Found changelog entry: $line" |
95 | | - release_notes+="${line}\n" |
96 | | - continue |
97 | | - fi |
98 | | -
|
99 | | - # Log skipped lines in the current version section |
100 | | - if [[ $found_version -eq 1 ]]; then |
101 | | - echo "DEBUG: Skipping line (not a changelog entry): $line" |
102 | | - fi |
103 | | - done < "$readme_file" |
104 | | -
|
105 | | - if [[ -z "$release_notes" ]]; then |
106 | | - echo "::error::Failed to extract release notes for version ${plugin_version}." |
107 | | - exit 1 |
108 | | - fi |
109 | | -
|
110 | | - echo "DEBUG: Successfully extracted release notes." |
111 | | - echo "DEBUG: Release notes content:" |
112 | | - echo -e "$release_notes" |
113 | | -
|
114 | | - # Write the release notes with actual line breaks |
115 | | - echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV |
116 | | - echo -e "$release_notes" >> $GITHUB_ENV |
117 | | - echo "EOF" >> $GITHUB_ENV |
118 | | -
|
119 | | - #- name: Deploy WordPress.org Assets |
120 | | - # uses: 10up/action-wordpress-plugin-asset-update@stable |
121 | | - # env: |
122 | | - # SVN_USERNAME: ${{ secrets.SVN_USERNAME }} |
123 | | - # SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} |
124 | | - |
125 | | - - name: WordPress Plugin Deploy |
126 | | - id: deploy |
| 48 | + echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 49 | +
|
| 50 | + - name: WordPress Plugin Deploy (Tag Only) |
127 | 51 | uses: 10up/action-wordpress-plugin-deploy@stable |
128 | 52 | with: |
129 | | - generate-zip: true |
| 53 | + skip-trunk: true |
| 54 | + skip-assets: true |
| 55 | + generate-zip: false |
| 56 | + tag: ${{ steps.version.outputs.version }} |
| 57 | + |
| 58 | + env: |
| 59 | + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} |
| 60 | + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} |
| 61 | + |
| 62 | + github-release: |
| 63 | + name: Create GitHub Release |
| 64 | + runs-on: ubuntu-latest |
| 65 | + needs: [tag-release] |
| 66 | + |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v3 |
| 69 | + |
| 70 | + - name: Extract Plugin Version |
| 71 | + id: version |
| 72 | + run: | |
| 73 | + echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 74 | +
|
| 75 | + - name: Create ZIP |
| 76 | + run: | |
| 77 | + zip -r "${{ github.event.repository.name }}.zip" . -x ".git/*" ".github/*" |
| 78 | +
|
| 79 | + - name: Create GitHub Release |
| 80 | + uses: softprops/action-gh-release@v2 |
| 81 | + with: |
| 82 | + tag_name: ${{ steps.version.outputs.version }} |
| 83 | + files: ${{ github.event.repository.name }}.zip |
130 | 84 |
|
131 | | - - name: Create GitHub Release |
132 | | - uses: softprops/action-gh-release@v2 |
133 | | - with: |
134 | | - tag_name: ${{ github.ref_name }} |
135 | | - body: ${{ env.RELEASE_NOTES }} |
136 | | - files: ${{github.workspace}}/${{ github.event.repository.name }}.zip |
137 | | - |
138 | | -env: |
139 | | - SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} |
140 | | - SVN_USERNAME: ${{ secrets.SVN_USERNAME }} |
141 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments