✨feature: Add release action
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
name: Release Plugin
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'aa-events.php'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Extract plugin version
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION=$(grep -m1 '^\s*\*\s*Version:' aa-events.php | sed 's/.*Version:\s*//' | tr -d '[:space:]')
|
||||||
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Check if release already exists
|
||||||
|
id: check_release
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
if gh release view "${{ steps.version.outputs.tag }}" --repo "${{ github.repository }}" > /dev/null 2>&1; then
|
||||||
|
echo "exists=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "exists=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Build plugin zip
|
||||||
|
if: steps.check_release.outputs.exists == 'false'
|
||||||
|
run: |
|
||||||
|
ZIP_NAME="aa-events-${{ steps.version.outputs.version }}.zip"
|
||||||
|
zip -r "$ZIP_NAME" assets includes templates aa-events.php README.md
|
||||||
|
echo "ZIP_NAME=$ZIP_NAME" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Create release
|
||||||
|
if: steps.check_release.outputs.exists == 'false'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
gh release create "${{ steps.version.outputs.tag }}" \
|
||||||
|
--repo "${{ github.repository }}" \
|
||||||
|
--title "AA Events ${{ steps.version.outputs.version }}" \
|
||||||
|
--generate-notes \
|
||||||
|
"${{ env.ZIP_NAME }}"
|
||||||
Reference in New Issue
Block a user