Files
wp-digital-download/.gitea/workflows/release.yml
jknapp cec5daa0b0
All checks were successful
Create Release / build (push) Successful in 3s
removing unneeded files from repo and plugin
2025-09-10 06:02:50 -07:00

120 lines
5.1 KiB
YAML

name: Create Release
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
username: ${{ secrets.CI_USER }}
password: ${{ secrets.CI_TOKEN }}
fetch-depth: 0 # Important: Fetch all history for commit messages
- name: Get version
id: get_version
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "version=$(date +'%Y.%m.%d-%H%M')" >> $GITHUB_OUTPUT
fi
- name: Generate release notes
id: release_notes
run: |
# Find the most recent tag
LATEST_TAG=$(git describe --tags --abbrev=0 --always 2>/dev/null || echo "none")
if [ "$LATEST_TAG" = "none" ]; then
# If no previous tag exists, get all commits
COMMITS=$(git log --pretty=format:"* %s (%h)" --no-merges)
else
# Get commits since the last tag
COMMITS=$(git log --pretty=format:"* %s (%h)" ${LATEST_TAG}..HEAD --no-merges)
fi
# Create release notes with header (without encoding newlines)
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "## What's New in ${{ steps.get_version.outputs.version }}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "$COMMITS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Update plugin version
run: |
# Replace version placeholder in plugin header
sed -i "s/Version: .*/Version: ${{ steps.get_version.outputs.version }}/" wp-digital-download.php
# Replace version placeholder in PHP constant
sed -i "s/define('WPDD_VERSION', '[^']*');/define('WPDD_VERSION', '${{ steps.get_version.outputs.version }}');/" wp-digital-download.php
# Verify the changes were made
echo "Plugin header version:"
grep "Version:" wp-digital-download.php
echo "PHP constant version:"
grep "WPDD_VERSION" wp-digital-download.php
- name: Create ZIP archive
run: |
# Create a temp directory with the correct plugin folder name
mkdir -p /tmp/wp-digital-download
# Copy files to the temp directory (excluding git and other unnecessary files)
cp -r * /tmp/wp-digital-download/ 2>/dev/null || true
# Exclude development and sensitive files from plugin distribution
# Remove version control and CI/CD files
rm -rf /tmp/wp-digital-download/.git 2>/dev/null || true
rm -rf /tmp/wp-digital-download/.gitea 2>/dev/null || true
rm -rf /tmp/wp-digital-download/.github 2>/dev/null || true
rm -f /tmp/wp-digital-download/.gitignore 2>/dev/null || true
# Remove testing and development files
rm -rf /tmp/wp-digital-download/.playwright-mcp 2>/dev/null || true
rm -rf /tmp/wp-digital-download/tests 2>/dev/null || true
rm -rf /tmp/wp-digital-download/test 2>/dev/null || true
rm -rf /tmp/wp-digital-download/node_modules 2>/dev/null || true
# Remove documentation and config files that might contain sensitive data
rm -f /tmp/wp-digital-download/CLAUDE.md 2>/dev/null || true
rm -f /tmp/wp-digital-download/README.md 2>/dev/null || true
# Remove ALL JSON files (package.json, composer.json, and any test configs)
find /tmp/wp-digital-download -type f -name "*.json" -delete 2>/dev/null || true
# Remove any lock files
rm -f /tmp/wp-digital-download/package-lock.json 2>/dev/null || true
rm -f /tmp/wp-digital-download/composer.lock 2>/dev/null || true
# Remove any .env files that might contain credentials
find /tmp/wp-digital-download -type f -name ".env*" -delete 2>/dev/null || true
# Remove any backup or temporary files
find /tmp/wp-digital-download -type f -name "*~" -delete 2>/dev/null || true
find /tmp/wp-digital-download -type f -name "*.bak" -delete 2>/dev/null || true
find /tmp/wp-digital-download -type f -name "*.tmp" -delete 2>/dev/null || true
# Remove any log files
find /tmp/wp-digital-download -type f -name "*.log" -delete 2>/dev/null || true
# List what's being included (for verification)
echo "Files being included in the release:"
ls -la /tmp/wp-digital-download/
# Create the ZIP file with the proper structure
cd /tmp
zip -r $GITHUB_WORKSPACE/wp-digital-download.zip wp-digital-download
- name: Create Release
uses: softprops/action-gh-release@v2
with:
token: "${{ secrets.REPO_TOKEN }}"
title: "WP Digital Download Release ${{ steps.get_version.outputs.version }}"
tag_name: ${{ steps.get_version.outputs.version }}
body: "${{ steps.release_notes.outputs.notes }}"
files: |
wp-digital-download.zip