Add release automation for GitHub and Gitea

This commit is contained in:
2025-04-07 05:43:29 +01:00
parent d1d8c0bad1
commit 9370d0746d
4 changed files with 172 additions and 0 deletions

42
.distignore Normal file
View File

@ -0,0 +1,42 @@
# Git
.git
.github
.gitignore
.gitattributes
# Build tools
.distignore
build.sh
build
# Documentation
CONTRIBUTING.md
CODE_OF_CONDUCT.md
# Development files
node_modules
.editorconfig
.eslintrc
.eslintignore
.stylelintrc
phpcs.xml
phpunit.xml
tests
.travis.yml
.gitlab-ci.yml
Gruntfile.js
gulpfile.js
package.json
package-lock.json
composer.json
composer.lock
# Miscellaneous
.DS_Store
Thumbs.db
.idea
.vscode
*.log
*.bak
*.tmp
*.zip

39
.drone.yml Normal file
View File

@ -0,0 +1,39 @@
kind: pipeline
type: docker
name: build-release
trigger:
event:
- tag
ref:
- refs/tags/v*
steps:
- name: build
image: alpine:latest
commands:
- apk add --no-cache bash zip
- VERSION=${DRONE_TAG#v}
- mkdir -p build/plugin-reference-cleaner
- cp plugin-reference-cleaner.php build/plugin-reference-cleaner/
- cp readme.txt build/plugin-reference-cleaner/
- cp LICENSE build/plugin-reference-cleaner/
- cp README.md build/plugin-reference-cleaner/
- cp CHANGELOG.md build/plugin-reference-cleaner/
- cd build
- zip -r ../plugin-reference-cleaner-$VERSION.zip plugin-reference-cleaner
- cd ..
- name: release
image: plugins/gitea-release
settings:
api_key:
from_secret: gitea_token
base_url: https://gitea.wpallstars.com
files:
- plugin-reference-cleaner-*.zip
title: Release ${DRONE_TAG}
note: |
Plugin Reference Cleaner ${DRONE_TAG}
See [CHANGELOG.md](https://gitea.wpallstars.com/wpallstars/plugin-reference-cleaner/src/branch/main/CHANGELOG.md) for details.

49
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,49 @@
name: Build Release
on:
push:
tags:
- 'v*'
jobs:
build:
name: Build and Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Create build directory
run: mkdir -p build/plugin-reference-cleaner
- name: Copy plugin files
run: |
cp plugin-reference-cleaner.php build/plugin-reference-cleaner/
cp readme.txt build/plugin-reference-cleaner/
cp LICENSE build/plugin-reference-cleaner/
cp README.md build/plugin-reference-cleaner/
- name: Create ZIP file
run: |
cd build
zip -r ../plugin-reference-cleaner-${{ steps.get_version.outputs.VERSION }}.zip plugin-reference-cleaner
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
name: Release v${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
files: |
plugin-reference-cleaner-${{ steps.get_version.outputs.VERSION }}.zip
body: |
Plugin Reference Cleaner v${{ steps.get_version.outputs.VERSION }}
See [CHANGELOG.md](https://github.com/wpallstars/plugin-reference-cleaner/blob/main/CHANGELOG.md) for details.

42
build.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
# Exit on error
set -e
# Check if version is provided
if [ -z "$1" ]; then
echo "Error: Please provide a version number. Example: ./build.sh 1.2"
exit 1
fi
VERSION=$1
PLUGIN_SLUG="plugin-reference-cleaner"
BUILD_DIR="build/$PLUGIN_SLUG"
ZIP_FILE="${PLUGIN_SLUG}-${VERSION}.zip"
# Create build directory
echo "Creating build directory..."
mkdir -p $BUILD_DIR
# Copy required files
echo "Copying plugin files..."
cp plugin-reference-cleaner.php $BUILD_DIR/
cp readme.txt $BUILD_DIR/
cp LICENSE $BUILD_DIR/
cp README.md $BUILD_DIR/
cp CHANGELOG.md $BUILD_DIR/
# Create ZIP file
echo "Creating ZIP file..."
cd build
zip -r ../$ZIP_FILE $PLUGIN_SLUG
cd ..
# Verify the ZIP file was created
if [ -f "$ZIP_FILE" ]; then
echo "✅ Build successful: $ZIP_FILE created"
echo "File path: $(pwd)/$ZIP_FILE"
else
echo "❌ Build failed: ZIP file was not created"
exit 1
fi