Skip to content

workflow updated

workflow updated #33

Workflow file for this run

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 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 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
# -------------------------------------------
# CUSTOM SVN DEPLOY LOGIC
# -------------------------------------------
- name: Checkout WP.org SVN
run: |
svn co https://plugins.svn.wordpress.org/${{ github.event.repository.name }}/ svn-wp
- name: Clean trunk
run: |
rm -rf svn-wp/trunk/*
mkdir -p svn-wp/trunk
# -------------------------------------------
# Copy vendor WITHOUT autoload.php
# -------------------------------------------
- name: Copy vendor folder (excluding autoload.php)
run: |
if [ -d "vendor" ]; then
mkdir -p svn-wp/trunk/vendor
rsync -av \
--exclude='autoload.php' \
./vendor/ svn-wp/trunk/vendor/
fi
# -------------------------------------------
# Commit vendor folders one-by-one
# -------------------------------------------
- name: Commit vendor subfolders
run: |
if [ -d "svn-wp/trunk/vendor" ]; then
cd svn-wp/trunk/vendor
for dir in */; do
echo "Processing vendor folder: $dir"
cd "$dir"
svn add --force .
svn status
svn commit -m "Add vendor folder: ${dir%/} for version ${{ github.ref_name }}" \
--username "${{ secrets.SVN_USERNAME }}" \
--password "${{ secrets.SVN_PASSWORD }}" \
|| echo "Nothing to commit for $dir"
cd ..
done
fi
# -------------------------------------------
# Copy remaining plugin files (excluding readme.txt + vendor)
# -------------------------------------------
- name: Copy remaining plugin files
run: |
rsync -av \
--exclude='vendor' \
--exclude='readme.txt' \
--exclude='svn-wp' \
./ svn-wp/trunk/
# -------------------------------------------
# Commit remaining plugin files
# -------------------------------------------
- name: Commit the rest of the plugin files
run: |
cd svn-wp
svn add --force trunk
svn status
svn commit -m "Add remaining plugin files for version ${{ github.ref_name }}" \
--username "${{ secrets.SVN_USERNAME }}" \
--password "${{ secrets.SVN_PASSWORD }}"
# -------------------------------------------
# Create the tag from trunk
# -------------------------------------------
- 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 }}"
# -------------------------------------------
# Add readme.txt AND vendor/autoload.php in trunk + tag
# -------------------------------------------
- name: Add final files: readme + vendor/autoload.php

Check failure on line 169 in .github/workflows/deploy.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/deploy.yml

Invalid workflow file

You have an error in your yaml syntax on line 169
run: |
version="${GITHUB_REF##*/}"
# add readme.txt to trunk
cp readme.txt svn-wp/trunk/readme.txt
svn -q add svn-wp/trunk/readme.txt || true
# add readme.txt to tag
cp readme.txt svn-wp/tags/$version/readme.txt
svn -q add svn-wp/tags/$version/readme.txt || true
# add autoload.php if exists
if [ -f "vendor/autoload.php" ]; then
cp vendor/autoload.php svn-wp/trunk/vendor/autoload.php
cp vendor/autoload.php svn-wp/tags/$version/vendor/autoload.php
svn -q add svn-wp/trunk/vendor/autoload.php || true
svn -q add svn-wp/tags/$version/vendor/autoload.php || true
fi
# -------------------------------------------
# Update stable tag in both readmes
# -------------------------------------------
- name: Update readme stable tag in trunk + tag
run: |
version="${GITHUB_REF##*/}"
sed -i "s/^Stable tag:.*/Stable tag: $version/" svn-wp/trunk/readme.txt
sed -i "s/^Stable tag:.*/Stable tag: $version/" svn-wp/tags/$version/readme.txt
# -------------------------------------------
# Commit final updates (readme + autoload.php)
# -------------------------------------------
- name: Commit final readme + autoload.php
run: |
cd svn-wp
svn commit -m "Finalize stable tag and autoloader for version ${GITHUB_REF##*/}" \
--username "${{ secrets.SVN_USERNAME }}" \
--password "${{ secrets.SVN_PASSWORD }}"
# -------------------------------------------
# CREATE GITHUB RELEASE (unchanged)
# -------------------------------------------
- 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 }}