From 384ad5e26594a342efb936d5e06e83b237db08b5 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 1 Dec 2025 16:13:42 -0800 Subject: [PATCH] Add Gitea CI/CD workflows for automated releases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add automated release creation and versioning workflows similar to the fourthwall plugin. Features: - Automatically creates a release on every push to main branch - Generates release notes from commit messages since last tag - Updates plugin version using timestamp-based versioning (YYYY.MM.DD-HHMM) - Creates and uploads plugin zip file to release - Supports manual release creation/editing to update version Workflows: - .gitea/workflows/release.yml - Triggers on push to main - .gitea/workflows/update-version.yml - Triggers on release creation/edit The release zip will be automatically picked up by the Gitea auto-updater for WordPress. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .gitea/workflows/release.yml | 88 +++++++++++++++++++++++++++++ .gitea/workflows/update-version.yml | 51 +++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 .gitea/workflows/release.yml create mode 100644 .gitea/workflows/update-version.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..61072b1 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,88 @@ +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<> $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: | + # Get current version from plugin file + CURRENT_VERSION=$(grep "Version:" twilio-wp-plugin.php | head -1 | sed 's/.*Version: //' | sed 's/ *$//') + + # Only update if version doesn't match the release version + if [ "$CURRENT_VERSION" != "${{ steps.get_version.outputs.version }}" ]; then + sed -i "s/Version: .*/Version: ${{ steps.get_version.outputs.version }}/" twilio-wp-plugin.php + echo "Updated version from $CURRENT_VERSION to ${{ steps.get_version.outputs.version }}" + else + echo "Version already set to ${{ steps.get_version.outputs.version }}" + fi + + # Verify the change + grep "Version:" twilio-wp-plugin.php + + - name: Create ZIP archive + run: | + # Create a temp directory with the correct plugin folder name + mkdir -p /tmp/twilio-wp-plugin + + # Copy files to the temp directory (excluding git and other unnecessary files) + cp -r * /tmp/twilio-wp-plugin/ 2>/dev/null || true + + # Exclude .git and .gitea directories + rm -rf /tmp/twilio-wp-plugin/.git /tmp/twilio-wp-plugin/.gitea 2>/dev/null || true + + # Create the ZIP file with the proper structure + cd /tmp + zip -r $GITHUB_WORKSPACE/twilio-wp-plugin.zip twilio-wp-plugin + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + token: "${{ secrets.REPO_TOKEN }}" + title: "Twilio WP Plugin Release ${{ steps.get_version.outputs.version }}" + tag_name: ${{ steps.get_version.outputs.version }} + body: "${{ steps.release_notes.outputs.notes }}" + files: | + twilio-wp-plugin.zip diff --git a/.gitea/workflows/update-version.yml b/.gitea/workflows/update-version.yml new file mode 100644 index 0000000..8bfecaa --- /dev/null +++ b/.gitea/workflows/update-version.yml @@ -0,0 +1,51 @@ +name: Update Plugin Version + +on: + release: + types: [created, edited] + +jobs: + update-version: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get release tag + id: get_tag + run: echo "TAG=${GITEA_REF#refs/tags/}" >> $GITEA_ENV + + - name: Update version in plugin file + run: | + # Replace version in main plugin file + sed -i "s/Version: .*/Version: ${{ env.TAG }}/" twilio-wp-plugin.php + + # Verify change + grep "Version:" twilio-wp-plugin.php + + - name: Commit changes + run: | + git config --local user.email "action@gitea.com" + git config --local user.name "Gitea Action" + git add twilio-wp-plugin.php + git commit -m "Update version to ${{ env.TAG }}" || echo "No changes to commit" + git push || echo "Nothing to push" + + - name: Create plugin zip + run: | + mkdir -p /tmp/twilio-wp-plugin + rsync -av --exclude=".git" --exclude=".gitea" --exclude="build" . /tmp/twilio-wp-plugin/ + cd /tmp + zip -r $GITEA_WORK_DIR/twilio-wp-plugin.zip twilio-wp-plugin + + - name: Upload zip to release + uses: actions/upload-release-asset@v1 + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + with: + upload_url: ${{ gitea.event.release.upload_url }} + asset_path: twilio-wp-plugin.zip + asset_name: twilio-wp-plugin.zip + asset_content_type: application/zip