Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions .github/workflows/deploy.yml

This file was deleted.

144 changes: 144 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Release
on:
workflow_dispatch:
inputs:
VERSION:
description: 'Version to release (MAJOR.MINOR.PATCH), equal to Version: and Stable tag on dev/main'
required: true
type: string
DRY_RUN:
description: 'Validate and upload the would-be trunk as an artifact, commit nothing to WordPress.org'
type: boolean
default: true
permissions:
contents: read
jobs:
guard:
runs-on: ubuntu-latest
steps:
- name: Require dev/main and a MAJOR.MINOR.PATCH version
env:
VERSION: ${{ inputs.VERSION }}
run: |
if [ "${{ github.ref }}" != 'refs/heads/dev/main' ]; then
echo "::error::Release runs from dev/main only, not ${{ github.ref }}"; exit 1
fi
# Fail before build and tag, not only in wporg after the tag is pushed.
if [[ ! "$VERSION" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
echo "::error::VERSION must be MAJOR.MINOR.PATCH, got '$VERSION'"; exit 1
fi

build:
needs: guard
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.VERSION }} # stamps Version: on main, which wporg requires
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 }}

# Blocks the release: tag and wporg need it. No ignore-codes, so Version/Stable tag are checked strictly.
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'

tag:
needs: [build, plugin-check-built]
runs-on: ubuntu-latest
env:
VERSION: ${{ inputs.VERSION }}
steps:
- name: Check out built main
uses: actions/checkout@v6
with:
ref: main
ssh-key: ${{ secrets.DEPLOYBOT_SSH_PRIVATE_KEY }}
- name: Verify main is this build
run: |
grep -E '^ \* (Version|SHA):' multisyde.php
grep -qF " * SHA: ${{ github.sha }}" multisyde.php || { echo "::error::main is not built from ${{ github.sha }}"; exit 1; }
grep -qE "^ \* Version: +${VERSION//./\\.}\s*$" multisyde.php || { echo "::error::main Version: is not $VERSION"; exit 1; }
- name: Tag built main
run: |
# A dry run already tags; the publishing run after it reuses the tag if it is on this build.
if git ls-remote --exit-code --tags origin "refs/tags/$VERSION" >/dev/null; then
git fetch --no-tags origin "refs/tags/$VERSION:refs/tags/$VERSION"
if [ "$(git rev-parse "$VERSION^{commit}")" != "$(git rev-parse HEAD)" ]; then
echo "::error::Tag $VERSION exists on another commit"; exit 1
fi
echo "Tag $VERSION already points to this build, reusing it"
else
git tag "$VERSION"
git push origin "refs/tags/$VERSION"
fi

wporg:
needs: tag
concurrency:
group: wordpress-org-svn
cancel-in-progress: false
uses: inpsyde/reusable-workflows/.github/workflows/wordpress-org-release.yml@main
with:
SVN_PLUGIN_SLUG: multisyde
PLUGIN_VERSION: ${{ inputs.VERSION }}
GIT_REF: ${{ inputs.VERSION }}
UPDATE_TRUNK_ONLY: false # always a full release; DRY_RUN is the preview (a trunk-only run fails the strict Stable tag check)
DRY_RUN: ${{ inputs.DRY_RUN }}
secrets:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}

# Only after a real WordPress.org release: dry runs create no GitHub Release.
# The attestation compares our zip with the one WordPress.org serves for VERSION; it waits up to 60 minutes for it.
github-release:
needs: [build, wporg]
if: github.server_url == 'https://github.com' && !inputs.DRY_RUN
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
attestations: write
steps:
- name: Download built package
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.artifact }}
path: dist
- name: Zip built package
run: cd dist && zip -qr ../multisyde.zip multisyde
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
VERSION: ${{ inputs.VERSION }}
run: gh release view "$VERSION" >/dev/null 2>&1 || gh release create "$VERSION" --verify-tag --generate-notes multisyde.zip
- name: Attest build provenance
uses: johnbillion/action-wordpress-plugin-attestation@0.7.1
with:
zip-path: multisyde.zip
plugin: multisyde
version: ${{ inputs.VERSION }}
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ If you run into bugs or want to suggest an improvement:
We follow the WordPress Community Code of Conduct.
Be respectful and inclusive in all your interactions.

## Releasing

Releases are built and published by the **Release** workflow. Nothing is published by pushing a tag.
1. On `dev/main`, bump `Version:` in `multisyde.php`, plus `Stable tag` and the changelog in `readme.txt`, and merge.
2. Run **Release** from `dev/main` with that version as `VERSION`. `DRY_RUN` is on by default: the run builds `main`, runs Plugin Check on the built package, tags it, and uploads the would-be SVN trunk as an artifact without committing to WordPress.org. Review it, then run **Release** again with `DRY_RUN` off to publish. The GitHub release is created only by that publishing run.

A failing Plugin Check on the built package stops the release before anything is tagged. `VERSION` must be `MAJOR.MINOR.PATCH`. Every run, including a dry run, tags the built `main` with `VERSION`. A later run reuses that tag only while `dev/main` is unchanged; otherwise delete the tag first.

---

Thanks for helping improve MultiSyde! ❤️
Expand Down
Loading