Add Gitea Actions workflow: test gate, then versioned zip release
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2e3abf33d9
commit
0b9e6e7cbb
1 file changed
+98
@@ -0,0 +1,98 @@
|
||||
name: Test and Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.3'
|
||||
tools: composer
|
||||
coverage: none
|
||||
|
||||
- name: Install dev dependencies
|
||||
run: composer install --no-interaction --prefer-dist
|
||||
|
||||
- name: PHP syntax check
|
||||
run: find . -path ./vendor -prune -o -name '*.php' -print0 | xargs -0 -n1 php -l > /dev/null
|
||||
|
||||
- name: JavaScript syntax check
|
||||
run: |
|
||||
if command -v node >/dev/null; then
|
||||
find assets -name '*.js' -print0 | xargs -0 -n1 node --check
|
||||
else
|
||||
echo "node not available on runner; skipping JS syntax check"
|
||||
fi
|
||||
|
||||
- name: Unit tests
|
||||
run: vendor/bin/phpunit
|
||||
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Compute version
|
||||
id: ver
|
||||
run: echo "version=$(date -u +'%Y.%m.%d-%H%M')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Generate release notes
|
||||
id: notes
|
||||
run: |
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
||||
if [ -z "$LATEST_TAG" ]; then
|
||||
COMMITS=$(git log --pretty=format:"* %s (%h)" --no-merges)
|
||||
else
|
||||
COMMITS=$(git log --pretty=format:"* %s (%h)" "${LATEST_TAG}..HEAD" --no-merges)
|
||||
fi
|
||||
{
|
||||
echo "notes<<EOF"
|
||||
echo "## What's New in ${{ steps.ver.outputs.version }}"
|
||||
echo ""
|
||||
echo "$COMMITS"
|
||||
echo "EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Stamp version into plugin
|
||||
run: |
|
||||
V="${{ steps.ver.outputs.version }}"
|
||||
sed -i -E "s/^( \* Version: ).*/\1${V}/" streamgoals-donate.php
|
||||
sed -i -E "s/(define\( 'STREAMGOALS_VERSION', ')[^']*(' \);)/\1${V}\2/" streamgoals-donate.php
|
||||
grep -E "Version:|STREAMGOALS_VERSION" streamgoals-donate.php
|
||||
|
||||
- name: Build installable zip (runtime files only)
|
||||
run: |
|
||||
set -e
|
||||
PKG=/tmp/streamgoals-donate
|
||||
mkdir -p "$PKG"
|
||||
cp streamgoals-donate.php "$PKG"/
|
||||
cp -r includes assets "$PKG"/
|
||||
[ -d languages ] && cp -r languages "$PKG"/ || true
|
||||
[ -f LICENSE ] && cp LICENSE "$PKG"/ || true
|
||||
[ -f readme.txt ] && cp readme.txt "$PKG"/ || true
|
||||
find "$PKG" -type f \( -name '*.bak' -o -name '*~' -o -name '*.log' -o -name '.env*' \) -delete
|
||||
(cd /tmp && zip -r -q "$GITHUB_WORKSPACE/streamgoals-donate.zip" streamgoals-donate)
|
||||
unzip -l streamgoals-donate.zip | tail -n 15
|
||||
|
||||
- name: Create release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
token: ${{ secrets.REPO_TOKEN || github.token }}
|
||||
name: "StreamGoals Donate ${{ steps.ver.outputs.version }}"
|
||||
tag_name: ${{ steps.ver.outputs.version }}
|
||||
body: ${{ steps.notes.outputs.notes }}
|
||||
files: streamgoals-donate.zip
|
||||
Reference in new issue
Block a user