59 lines
1.5 KiB
YAML
59 lines
1.5 KiB
YAML
name: Package Plugin
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
package:
|
|
name: Package plugin
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build installable plugin archive
|
|
id: package
|
|
run: |
|
|
set -eu
|
|
plugin_slug="btranslate"
|
|
version="$(grep -E '^ \* Version:' btranslate.php | sed -E 's/^ \* Version: *//')"
|
|
archive_name="${plugin_slug}-${version}.zip"
|
|
|
|
rm -rf build
|
|
mkdir -p "build/${plugin_slug}"
|
|
cp btranslate.php README.md "build/${plugin_slug}/"
|
|
cp -R includes "build/${plugin_slug}/"
|
|
(
|
|
cd build
|
|
zip -qr "../${archive_name}" "${plugin_slug}"
|
|
)
|
|
|
|
unzip -p "${archive_name}" "${plugin_slug}/btranslate.php" | grep -q '^ \* Plugin Name: Btranslate$'
|
|
|
|
printf 'archive=%s\n' "${archive_name}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Upload plugin archive
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: btranslate-plugin
|
|
path: ${{ steps.package.outputs.archive }}
|
|
if-no-files-found: error
|
|
retention-days: 30
|
|
|
|
- name: Publish plugin ZIP to GitHub Release
|
|
if: startsWith( github.ref, 'refs/tags/v' )
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: ${{ steps.package.outputs.archive }} |