62 lines
1.9 KiB
YAML
62 lines
1.9 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
container:
|
|
image: php:8.2-cli-alpine
|
|
|
|
steps:
|
|
- name: Install dependencies
|
|
run: apk add --no-cache nodejs git zip curl jq
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: PHP syntax check
|
|
run: |
|
|
find . -name "*.php" -not -path "./.git/*" -print0 \
|
|
| xargs -0 -n1 php -l
|
|
|
|
- name: Build ZIP
|
|
run: |
|
|
MODULE=simple_withdrawalbutton
|
|
cp -rp . /tmp/$MODULE
|
|
rm -rf /tmp/$MODULE/.git \
|
|
/tmp/$MODULE/.gitea \
|
|
/tmp/$MODULE/CLAUDE.md \
|
|
/tmp/$MODULE/release.sh
|
|
cd /tmp && zip -r ${MODULE}.zip $MODULE/
|
|
mkdir -p $GITHUB_WORKSPACE/dist
|
|
mv /tmp/${MODULE}.zip $GITHUB_WORKSPACE/dist/
|
|
|
|
- name: Create Gitea release and upload ZIP
|
|
env:
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
TAG: ${{ github.ref_name }}
|
|
run: |
|
|
RESPONSE=$(curl -s -X POST \
|
|
-H "Authorization: token $TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
"$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases" \
|
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\"}")
|
|
echo "API response: $RESPONSE"
|
|
|
|
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
|
|
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
|
|
echo "Failed to create release" && exit 1
|
|
fi
|
|
|
|
curl -sf -X POST \
|
|
-H "Authorization: token $TOKEN" \
|
|
-F "attachment=@$GITHUB_WORKSPACE/dist/simple_withdrawalbutton.zip" \
|
|
"$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID/assets?name=simple_withdrawalbutton.zip"
|
|
|
|
echo "Release $TAG created: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$TAG"
|