Skip to content

Update update-docs-latest-release-links.yml #13

Update update-docs-latest-release-links.yml

Update update-docs-latest-release-links.yml #13

on:
push:
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Zip all plugins and themes
run: |
for dir in wordpress/plugins/* wordpress/theme/*; do
if [ -d "$dir" ]; then
item_name=$(basename "$dir")
# For plugins, look for a PHP file with the same name as the directory
if [[ "$dir" == wordpress/plugins/* ]]; then
version=$(grep -Po '(?<=Version: )(\d+\.\d+\.?\d*)' "$dir/$item_name.php")
fi
# For themes, look for the version in style.css
if [[ "$dir" == wordpress/theme/* ]]; then
version=$(grep -Po '(?<=Version: )(\d+\.\d+\.?\d*)' "$dir/style.css")
fi
# If version is found, append it to the zip filename
if [ ! -z "$version" ]; then
zip -r "${item_name}-v${version}.zip" "$dir"
else
zip -r "${item_name}.zip" "$dir"
fi
fi
done
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false
- name: Upload all zipped items to Release
run: |
for zip_file in *.zip; do
echo "Uploading ${zip_file}..."
gh release upload ${{ github.ref_name }} "${zip_file}" --clobber
done
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
# Trigger the update-docs-latest-release-links.yml workflow here
- name: Trigger update-docs workflow
run: gh workflow run update-docs-latest-release-links.yml
env:
GITHUB_TOKEN: ${{ secrets.PAT }}