Skip to content

Commit 70576c9

Browse files
committed
workflow updated
1 parent 84f4006 commit 70576c9

1 file changed

Lines changed: 58 additions & 107 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 58 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -5,154 +5,105 @@ on:
55
tags:
66
- "*"
77

8-
permissions:
9-
contents: write
10-
118
jobs:
12-
deploy:
13-
name: Deploy WordPress Plugin
9+
tag:
10+
name: New tag
1411
runs-on: ubuntu-latest
15-
1612
steps:
17-
- name: Checkout Git repository
18-
uses: actions/checkout@v4
19-
with:
20-
fetch-depth: 0
13+
- uses: actions/checkout@v3
2114

22-
- name: Install SVN
23-
run: sudo apt-get update && sudo apt-get install -y subversion
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
2422
25-
# 🔍 Find Readme File (from your original workflow)
2623
- name: Find Readme File
2724
id: find_readme
2825
run: |
29-
for file in readme.txt Readme.txt README.txt README.md Readme.md readme.md; do
30-
if [ -f "$file" ]; then
31-
echo "Readme file found: $file"
32-
echo "readme_file=$file" >> $GITHUB_ENV
33-
break
34-
fi
35-
done
36-
37-
source $GITHUB_ENV
38-
if [ -z "$readme_file" ]; then
26+
#readme_file=$(find . -type f -iname "readme.*" | head -n 1)
27+
readme_file=$(find . -maxdepth 1 -type f -iname "readme.txt" | head -n 1)
28+
if [ -n "$readme_file" ]; then
29+
echo "Readme file found: $readme_file"
30+
echo "readme_file=$readme_file" >> $GITHUB_ENV
31+
else
3932
echo "::error::Readme file not found."
4033
exit 1
4134
fi
4235
43-
# 🧾 Extract Release Notes (from your original workflow)
4436
- name: Extract Release Notes
4537
id: release_notes
4638
run: |
4739
changelog_section_start="== Changelog =="
48-
readme_file="$readme_file"
40+
current_tag="${{ github.ref_name }}"
41+
readme_file="${{ env.readme_file }}"
4942
50-
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
51-
plugin_version="${GITHUB_REF#refs/tags/}"
52-
echo "Plugin version: $plugin_version"
53-
else
54-
echo "::error::This workflow must be triggered by a tag push."
55-
exit 1
56-
fi
43+
# Extract the version (strip 'refs/tags/' if it exists)
44+
version=${current_tag#refs/tags/}
5745
46+
# Read lines from the changelog section
5847
in_changelog=0
59-
found_version=0
6048
release_notes=""
61-
49+
capturing_version=0
6250
while IFS= read -r line; do
51+
# Start capturing after finding the changelog section
6352
if [[ "$line" == "$changelog_section_start" ]]; then
6453
in_changelog=1
6554
continue
6655
fi
6756
68-
if [[ $in_changelog -eq 0 ]]; then
69-
continue
57+
# Stop capturing if we encounter a new version or the end of the file
58+
if [[ $in_changelog -eq 1 && "$line" =~ ^= ]]; then
59+
# Check if this is the current version
60+
if [[ "$line" == "= $version =" ]]; then
61+
capturing_version=1
62+
elif [[ $capturing_version -eq 1 ]]; then
63+
# Stop if we see the next version
64+
break
65+
fi
7066
fi
7167
72-
if [[ "$line" == "= ${plugin_version} =" ]]; then
73-
found_version=1
74-
continue
75-
fi
76-
77-
if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^= [0-9]+\.[0-9]+\.[0-9]+ =$'; then
78-
break
79-
fi
80-
81-
if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^\*'; then
82-
release_notes+="${line}\n"
68+
# Capture lines only for the current version
69+
if [[ $capturing_version -eq 1 && -n "$line" ]]; then
70+
release_notes+="$line\n"
8371
fi
8472
done < "$readme_file"
8573
8674
if [[ -z "$release_notes" ]]; then
87-
echo "::error::Failed to extract release notes for version ${plugin_version}."
75+
echo "::error::Failed to extract release notes for version $version."
8876
exit 1
8977
fi
9078
91-
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
92-
echo -e "$release_notes" >> $GITHUB_ENV
93-
echo "EOF" >> $GITHUB_ENV
79+
# Debug: Print extracted release notes
80+
echo "Extracted release notes for version $version:"
81+
printf "%b" "$release_notes"
9482
95-
- name: Prepare environment variables
96-
id: vars
97-
run: |
98-
VERSION="${GITHUB_REF#refs/tags/}"
99-
SLUG=$(basename "${GITHUB_REPOSITORY}")
100-
echo "version=${VERSION}" >> $GITHUB_ENV
101-
echo "slug=${SLUG}" >> $GITHUB_ENV
102-
echo "🔧 Detected plugin slug: ${SLUG}"
83+
# Set output (fixed, now using Environment File)
84+
echo "notes<<EOF" >> $GITHUB_OUTPUT
85+
printf "%b\n" "$release_notes" >> $GITHUB_OUTPUT
86+
echo "EOF" >> $GITHUB_OUTPUT
10387
104-
- name: Checkout WordPress.org SVN
88+
- name: Debug Release Notes
10589
run: |
106-
SVN_URL="https://plugins.svn.wordpress.org/${slug}"
107-
SVN_DIR="$HOME/svn-wordpress"
108-
echo "📦 Checking out SVN repo..."
109-
svn co "$SVN_URL" "$SVN_DIR" --depth immediates
110-
svn update "$SVN_DIR/trunk" --set-depth infinity
111-
svn update "$SVN_DIR/tags" --set-depth immediates
112-
113-
- name: Sync files to trunk
114-
run: |
115-
SVN_DIR="$HOME/svn-wordpress"
116-
echo "🚀 Syncing files to trunk..."
117-
rsync -rc --exclude-from=.distignore ./ "$SVN_DIR/trunk/" --delete
118-
cp readme.txt "$SVN_DIR/readme.txt" || true
119-
120-
- name: Commit trunk changes to SVN
121-
env:
122-
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
123-
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
124-
run: |
125-
SVN_DIR="$HOME/svn-wordpress"
126-
cd "$SVN_DIR/trunk"
127-
echo "🧩 Committing trunk updates..."
128-
svn add --force . --auto-props --parents --depth infinity -q
129-
svn ci -m "Update trunk for version ${version}" \
130-
--username "$SVN_USERNAME" \
131-
--password "$SVN_PASSWORD" \
132-
--non-interactive
133-
134-
- name: Tag the new version in SVN
135-
env:
136-
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
137-
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
138-
run: |
139-
SVN_DIR="$HOME/svn-wordpress"
140-
cd "$SVN_DIR"
141-
echo "🏷️ Creating tag ${version}..."
142-
svn copy trunk "tags/${version}" \
143-
-m "Tagging version ${version}" \
144-
--username "$SVN_USERNAME" \
145-
--password "$SVN_PASSWORD" \
146-
--non-interactive
147-
148-
# 🎉 Create GitHub Release (from your original workflow)
90+
echo "Debugging Release Notes:"
91+
echo "${{ steps.release_notes.outputs.notes }}"
92+
93+
- name: WordPress Plugin Deploy
94+
id: deploy
95+
uses: 10up/action-wordpress-plugin-deploy@stable
96+
with:
97+
generate-zip: true
98+
14999
- name: Create GitHub Release
150100
uses: softprops/action-gh-release@v2
151101
with:
152102
tag_name: ${{ github.ref_name }}
153-
body: ${{ env.RELEASE_NOTES }}
154-
env:
155-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
body: ${{ steps.release_notes.outputs.notes }}
104+
files: ${{github.workspace}}/${{ github.event.repository.name }}.zip
156105

157106
env:
158-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
108+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)