From fc38601731c66968d27f57e9eafeb2b3d4479b0d Mon Sep 17 00:00:00 2001 From: Niklas Gutberlet Date: Sun, 25 Oct 2026 19:19:41 +0100 Subject: [PATCH] Add build-and-distribute workflow Switch MultiSyde to the inpsyde reusable build-and-distribute workflow and the dev/main branch model: dev/main holds the source and becomes the default branch, while main is generated by CI. Every push to a dev/** branch builds the plugin (composer --no-dev, .distignore applied) and the deploy bot commits the result to the branch without the dev/ prefix, stamping Version and the source SHA into the plugin header. The built main has no .github directory, so bot pushes trigger no workflows. The build changes what ships, so Plugin Check now also runs on the built artifact in a plugin-check-built job, not only on the source. Snapshot builds carry a non-release version that never matches the readme Stable tag, so those two version codes are ignored there; the release workflow is meant to check them strictly. The source Plugin Check now runs on dev/main instead of main, package.json gets the build script the reusable workflow calls, and CONTRIBUTING points pull requests at dev/main. --- .github/workflows/build-and-distribute.yml | 56 ++++++++++++++++++++++ .github/workflows/plugin-check.yml | 2 +- CONTRIBUTING.md | 2 +- package.json | 1 + 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build-and-distribute.yml diff --git a/.github/workflows/build-and-distribute.yml b/.github/workflows/build-and-distribute.yml new file mode 100644 index 0000000..4c32810 --- /dev/null +++ b/.github/workflows/build-and-distribute.yml @@ -0,0 +1,56 @@ +name: Build and distribute +on: + push: + branches: ['dev/**'] + paths-ignore: ['docs/**', '**.md'] + workflow_dispatch: + inputs: + PACKAGE_VERSION: + description: 'Package version (empty = derive from latest release)' + required: false + type: string +permissions: + contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false +jobs: + build: + uses: inpsyde/reusable-workflows/.github/workflows/build-and-distribute.yml@main + with: + PHP_VERSION: '7.4' # lowest supported PHP; the --no-dev install must resolve on it + NODE_VERSION: 'lts/krypton' # npm ci runs the preinstall engines check; matches upstream CI + PACKAGE_VERSION: ${{ inputs.PACKAGE_VERSION }} + secrets: + GITHUB_USER_EMAIL: ${{ secrets.DEPLOYBOT_EMAIL }} + GITHUB_USER_NAME: ${{ secrets.DEPLOYBOT_USER }} + GITHUB_USER_SSH_KEY: ${{ secrets.DEPLOYBOT_SSH_PRIVATE_KEY }} + GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.DEPLOYBOT_SSH_PUBLIC_KEY }} + + # The build changes what ships (.distignore, --no-dev vendor), so check the built package, not the source. + plugin-check-built: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download built package + uses: actions/download-artifact@v4 + with: + name: ${{ needs.build.outputs.artifact }} + path: dist + - name: Verify built package + run: | + grep -E '^ \* (Version|SHA):' dist/multisyde/multisyde.php + grep -qF "SHA: ${{ github.sha }}" dist/multisyde/multisyde.php + test -f dist/multisyde/vendor/autoload.php + for d in .github tests docs bin node_modules .wordpress-org; do + if [ -e "dist/multisyde/$d" ]; then echo "::error::$d must not ship"; exit 1; fi + done + ls -A dist/multisyde + - name: Run plugin check + uses: wordpress/plugin-check-action@v1 + with: + build-dir: './dist/multisyde' + exclude-files: 'modules/**/patches/*.php' + # Snapshot builds carry a non-release version (e.g. 0.0.0+main.), which never matches + # the readme Stable tag. The release workflow checks these two codes strictly. + ignore-codes: 'plugin_header_invalid_plugin_version,stable_tag_mismatch' diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index 5fe6b7b..ddd4bb6 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -3,7 +3,7 @@ on: pull_request: push: branches: - - main + - dev/main permissions: contents: read pull-requests: write diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5edf774..06fd34f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,7 +74,7 @@ composer run phpstan ```bash composer run qa ``` -5. Push your branch and open a pull request against the main branch. +5. Push your branch and open a pull request against the `dev/main` branch. The `main` branch is generated by CI from `dev/main` and must not be targeted or edited directly. Please include in your PR: - A clear description of what your change does diff --git a/package.json b/package.json index 5272c44..ba01403 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "npm": ">=11.16.0" }, "scripts": { + "build": "echo \"No assets to build\"", "preinstall": "npx check-node-version --package", "prewp-env": "npx check-node-version --package", "wp-env": "wp-env",