diff --git a/.github/workflows/bedrocknexus-publish.yml b/.github/workflows/bedrocknexus-publish.yml new file mode 100644 index 0000000..b0f111b --- /dev/null +++ b/.github/workflows/bedrocknexus-publish.yml @@ -0,0 +1,79 @@ +# Generated by BedrockNexus Plugins. Changes should be reviewed in a pull request. +name: BedrockNexus Publish + +on: + push: + branches: + - "**" + tags: + - "v*" + pull_request: + +permissions: + contents: read + +concurrency: + group: bedrocknexus-publish-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Validate and package + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.2" + tools: composer + - name: Validate PHP sources and dependencies + run: | + set -euo pipefail + find src -type f -name "*.php" -print0 | xargs -0 -n1 php -l + if [ -f composer.json ]; then composer validate --no-check-publish && composer install --no-interaction --no-progress --prefer-dist; fi + - name: Package PocketMine plugin + run: | + set -euo pipefail + mkdir -p dist + include_paths=(plugin.yml src) + for optional_path in resources vendor; do + if [ -e "${optional_path}" ]; then + include_paths+=("${optional_path}") + fi + done + include_csv=$(IFS=,; echo "${include_paths[*]}") + curl --fail --location --retry 3 \ + https://github.com/pmmp/DevTools/releases/latest/download/DevTools.phar \ + --output "${RUNNER_TEMP}/DevTools.phar" + php -dphar.readonly=0 "${RUNNER_TEMP}/DevTools.phar" \ + --make "${include_csv}" \ + --relative . \ + --out "${RUNNER_TEMP}/BedrockNexusExample.phar" + mv "${RUNNER_TEMP}/BedrockNexusExample.phar" 'dist/BedrockNexusExample.phar' + test -s 'dist/BedrockNexusExample.phar' + - name: Upload validation artifact + uses: actions/upload-artifact@v4 + with: + name: plugin-package + path: dist/BedrockNexusExample.phar + if-no-files-found: error + + release: + name: Publish release + if: startsWith(github.ref, 'refs/tags/v') + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download validated package + uses: actions/download-artifact@v4 + with: + name: plugin-package + path: dist + - name: Publish GitHub Release + env: + GH_TOKEN: ${{ github.token }} + run: gh release create "${GITHUB_REF_NAME}" dist/BedrockNexusExample.phar --generate-notes --verify-tag