Skip to content

Commit 0660df1

Browse files
committed
workflow updated
1 parent c12d21c commit 0660df1

File tree

1 file changed

+48
-36
lines changed

1 file changed

+48
-36
lines changed

.github/workflows/deploy.yml

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,7 @@ jobs:
4141
run: |
4242
changelog_section_start="== Changelog =="
4343
readme_file="$readme_file"
44-
45-
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
46-
plugin_version="${GITHUB_REF#refs/tags/}"
47-
else
48-
echo "::error::This workflow must be triggered by a tag push."
49-
exit 1
50-
fi
44+
plugin_version="${GITHUB_REF#refs/tags/}"
5145
5246
in_changelog=0
5347
found_version=0
@@ -72,9 +66,8 @@ jobs:
7266
break
7367
fi
7468
75-
if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^\*'; then
69+
if [[ $found_version -eq 1 ]]; then
7670
release_notes+="${line}\n"
77-
continue
7871
fi
7972
done < "$readme_file"
8073
@@ -83,16 +76,17 @@ jobs:
8376
exit 1
8477
fi
8578
86-
# Output in a format usable by later jobs
79+
# Output for GitHub environment
8780
release_notes="${release_notes//'%'/'%25'}"
8881
release_notes="${release_notes//$'\n'/'%0A'}"
8982
release_notes="${release_notes//$'\r'/'%0D'}"
9083
echo "release_notes=$release_notes" >> $GITHUB_OUTPUT
9184
9285
update-trunk:
93-
name: Update trunk in WordPress SVN
86+
name: Upload to trunk
9487
runs-on: ubuntu-latest
9588
needs: extract-release-notes
89+
9690
steps:
9791
- uses: actions/checkout@v3
9892

@@ -101,54 +95,72 @@ jobs:
10195
sudo apt-get update
10296
sudo apt-get install -y subversion
10397
104-
- name: Deploy to trunk
105-
uses: 10up/action-wordpress-plugin-deploy@stable
106-
with:
107-
skip-tags: true
108-
generate-zip: false
98+
- name: Deploy trunk manually
99+
run: |
100+
PLUGIN_SLUG="${{ github.event.repository.name }}"
101+
VERSION="${GITHUB_REF#refs/tags/}"
102+
SVN_URL="https://plugins.svn.wordpress.org/${PLUGIN_SLUG}"
103+
SVN_DIR="$HOME/svn-${PLUGIN_SLUG}"
104+
105+
echo "Checking out SVN..."
106+
svn checkout "$SVN_URL" "$SVN_DIR" --depth immediates
107+
svn update "$SVN_DIR/trunk" --set-depth infinity
108+
109+
echo "Copying plugin files..."
110+
rsync -a --exclude='.git*' --exclude='.github' --exclude='svn-*' ./ "$SVN_DIR/trunk/"
111+
112+
cd "$SVN_DIR/trunk"
113+
114+
echo "Adding all new files to SVN..."
115+
svn add . --force --quiet
116+
117+
echo "Committing to trunk..."
118+
svn commit -m "Update trunk for version ${VERSION}" \
119+
--username "${SVN_USERNAME}" \
120+
--password "${SVN_PASSWORD}" \
121+
--non-interactive
109122
110123
tag-release:
111-
name: Tag SVN Release
124+
name: Tag release in SVN
112125
runs-on: ubuntu-latest
113126
needs: update-trunk
114-
steps:
115-
- uses: actions/checkout@v3
116127

117-
- name: Install SVN
128+
steps:
129+
- name: Tag from trunk
118130
run: |
119-
sudo apt-get update
120-
sudo apt-get install -y subversion
131+
PLUGIN_SLUG="${{ github.event.repository.name }}"
132+
VERSION="${GITHUB_REF#refs/tags/}"
133+
SVN_URL="https://plugins.svn.wordpress.org/${PLUGIN_SLUG}"
134+
SVN_DIR="$HOME/svn-${PLUGIN_SLUG}"
121135
122-
- name: Extract Plugin Version
123-
id: version
124-
run: |
125-
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
136+
svn checkout "$SVN_URL" "$SVN_DIR" --depth immediates
137+
svn update "$SVN_DIR/trunk" --set-depth infinity
126138
127-
- name: Deploy tag
128-
uses: 10up/action-wordpress-plugin-deploy@stable
129-
with:
130-
skip-trunk: true
131-
skip-assets: true
132-
generate-zip: false
133-
tag: ${{ steps.version.outputs.version }}
139+
echo "Tagging version ${VERSION}..."
140+
svn copy "$SVN_DIR/trunk" "$SVN_DIR/tags/${VERSION}" \
141+
-m "Tagging version ${VERSION}" \
142+
--username "${SVN_USERNAME}" \
143+
--password "${SVN_PASSWORD}" \
144+
--non-interactive
134145
135146
github-release:
136147
name: Create GitHub Release
137148
runs-on: ubuntu-latest
138149
needs: [tag-release, extract-release-notes]
150+
139151
steps:
140152
- uses: actions/checkout@v3
141153

142-
- name: Extract Plugin Version
154+
- name: Extract Version
143155
id: version
144156
run: |
145157
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
146158
147-
- name: Create ZIP Archive
159+
- name: Create ZIP
148160
run: |
149161
zip -r "${{ github.event.repository.name }}.zip" . -x ".git/*" ".github/*"
150162
151-
- name: Publish GitHub Release
163+
- name: Create GitHub Release
152164
uses: softprops/action-gh-release@v2
153165
with:
154166
tag_name: ${{ steps.version.outputs.version }}

0 commit comments

Comments
 (0)