name: Package Plugin on: push: tags: - 'v*' pull_request: branches: - main workflow_dispatch: permissions: actions: write contents: write jobs: package: name: Package plugin runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v4 - name: Install gettext run: sudo apt-get update && sudo apt-get install --yes gettext - name: Build installable plugin archive id: package run: | set -eu version="$(grep -E '^ \* Version:' vblg-oi-contest-schedule.php | sed -E 's/^ \* Version: *//')" archive_name="vblg-oi-contest-schedule-${version}.zip" if [ "${GITHUB_REF_TYPE}" = "tag" ] && [ "${GITHUB_REF_NAME}" != "v${version}" ]; then printf 'Tag %s does not match plugin version %s.\n' "${GITHUB_REF_NAME}" "${version}" >&2 exit 1 fi ./build.sh build printf 'archive=%s\n' "${archive_name}" >> "$GITHUB_OUTPUT" - name: Upload plugin archive uses: actions/upload-artifact@v4 with: name: vblg-oi-contest-schedule-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 }} - name: Deploy GitHub Release to WordPress.org SVN if: startsWith( github.ref, 'refs/tags/v' ) env: DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} GH_TOKEN: ${{ github.token }} run: | gh workflow run deploy-wordpress-svn.yml \ --ref "${DEFAULT_BRANCH}" \ --field release_tag="${GITHUB_REF_NAME}"