From b8c1284c435a45fc5ef3c55bb732e02795a8dd2a Mon Sep 17 00:00:00 2001 From: ingeniumed Date: Wed, 7 Jan 2026 15:20:38 +1100 Subject: [PATCH 1/2] Add an automated release workflow --- .github/workflows/release.yml | 67 +++++++++++++++++++++++++++++++++++ RELEASE.md | 66 +++++++--------------------------- package.json | 3 +- 3 files changed, 80 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a7e8152 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,67 @@ +name: Release +on: + push: + branches: + - trunk + +permissions: + contents: write + +jobs: + check_and_release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up NodeJS + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + cache: npm + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + tools: composer + php-version: '8.1' + + - name: Build the plugin + run: | + npm ci + + - name: Check for version change + id: version_check + run: | + OLD_VERSION=$(git show HEAD^:vip-governance.php | sed -n 's/.*Version: *//p' | tr -d '[:space:]') + NEW_VERSION=$(git show HEAD:vip-governance.php | sed -n 's/.*Version: *//p' | tr -d '[:space:]') + DEFINED_VERSION=$(git show HEAD:vip-governance.php | sed -n "s/.*define( 'WPCOMVIP__GOVERNANCE__PLUGIN_VERSION', '\\([^']*\\)'.*/\\1/p") + + if [ "$NEW_VERSION" != "$DEFINED_VERSION" ]; then + echo "Error: Version mismatch detected!" + echo "Plugin header version: $NEW_VERSION" + echo "Defined constant version: $DEFINED_VERSION" + exit 1 + fi + + if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "Version changed from $OLD_VERSION to $NEW_VERSION" + else + echo "No version change detected" + fi + + - name: Build plugin zip + if: steps.version_check.outputs.new_version + run: | + VERSION="${{ steps.version_check.outputs.new_version }}" + git archive --prefix "vip-governance/" HEAD -o "vip-governance-${VERSION}.zip" + + - name: Create Release + if: steps.version_check.outputs.new_version + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ steps.version_check.outputs.new_version }} + files: vip-governance-${{ steps.version_check.outputs.new_version }}.zip + generate_release_notes: true diff --git a/RELEASE.md b/RELEASE.md index add198b..d7f35d3 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,64 +1,22 @@ # Release steps -## 1. Create a release branch - -1. Before merging a feature, create a release branch for the next target version, e.g. - - ```bash - git checkout trunk - git checkout -b planned-release/0.2.1 - ``` - -2. In GitHub, select the base branch as the `planned-release/...` branch. -3. Merge feature branches into the `planned-release/...` branch. - -## 2. Update build files - -```bash -npm run build -composer install --no-dev -``` - -Note: If new production dependencies have been added, modify the root `.gitignore` file to include new `vendor/` subfolders. - -Now commit these build changes in. - -## 3. Bump plugin version - -1. When the version is ready for release, inside the `planned-release/...` branch, bump the version number in `vip-governance.php`. Change plugin header and `WPCOMVIP__GOVERNANCE__PLUGIN_VERSION` to match new version. -2. In `package.json`, also bump the `version` field to match, and run `npm install` to update `package-lock.json`. -3. Commit the changed files to the `planned-release/...` branch. -4. Create a PR for the planned release branch (e.g. "Planned release 0.2.1") and merge to `trunk`. - -## 4. Tag branch for release - -1. In `trunk`, add a signed tag for the release: +# Release steps - ```bash - git checkout trunk - git pull - git tag -s -a -m "Release " +## 1. Bump plugin version - # e.g. git tag -s -a 1.0.2 -m "Release 1.0.2" - ``` +1. When the version is ready for release, bump the version number in `vip-governance.php` and `package.json`. Change plugin header and `WPCOMVIP__GOVERNANCE__PLUGIN_VERSION` to match new version. +2. PR version changes (e.g. "Release 1.2.3") and merge to `trunk`. When a version change is detected, the `release` workflow will generate a new tag and release ZIP. -2. Run `git push --tags`. +## 2. Update integrations -## 5. Create a release +Patch updates (e.g. `1.2.3` -> `1.2.4`) do not require any additional steps. -1. In the `vip-governance` folder, run this command to create a plugin ZIP: +This section applies if the plugin has increased by a minor (e.g. `1.2` -> `1.3`) or major (e.g. `1.2` -> `2.0`) version. - ```bash - git archive --prefix "vip-governance/" -o vip-governance-.zip +For an example updating an integration version, [see this mu-plugins PR](https://github.com/Automattic/vip-go-mu-plugins/pull/5409). - # e.g. git archive --prefix "vip-governance/" 1.0.2 -o vip-governance-1.0.2.zip - # - # Creates a ZIP archive with the prefix folder "vip-governance/" containing files from tag 1.0.2 - ``` +1. Ensure that the latest release of the VIP Governance plugin has been [pulled in `vip-go-mu-plugins-ext`](https://github.com/Automattic/vip-go-mu-plugins-ext/tree/trunk/vip-integrations). Updates are synced by minor version, so a patch update of `1.2.3` will be pulled into `vip-integrations/vip-governance-1.2`. If it's not, wait for the [**Update versioned external dependencies** workflow](https://github.com/Automattic/vip-go-mu-plugins-ext/actions/workflows/update-deps.yml) to pull in the latest changes, or run it manually. -2. Visit the [vip-governance create release page](https://github.com/automattic/vip-governance-plugin/releases/new). -3. Select the newly created version tag in the dropdown. -4. For the title, enter the release version name (e.g. `1.0.2`) -5. Add a description of release changes. -6. Attach the plugin ZIP. -7. Click "Publish release." +2. Create a branch on [vip-go-mu-plugins](https://github.com/Automattic/vip-go-mu-plugins). +3. Update the `integrations/vip-governance.php` version to match the minor version of the plugin, e.g. `1.2`. This will correspond with the folder path for the plugin [in `vip-go-mu-plugins-ext`](https://github.com/Automattic/vip-go-mu-plugins-ext/tree/trunk/vip-integrations). +4. Submit the PR, get it approved, and merge. diff --git a/package.json b/package.json index fe49216..b9cc499 100644 --- a/package.json +++ b/package.json @@ -46,9 +46,8 @@ "lint:phpcs": "vendor/bin/phpcs --cache", "lint:phpcs:fix": "vendor/bin/phpcbf", "packages-update": "wp-scripts packages-update", - "plugin-zip": "npm run build && composer install --prefer-dist --optimize-autoloader --no-dev && wp-scripts plugin-zip", "prepare": "npx simple-git-hooks", - "postinstall": "composer install", + "postinstall": "composer install --no-dev", "test": "npm run test:unit", "test:unit": "npm run test:php && npm run test:js", "test:e2e": "npx playwright test", From 967b8513b70a0d5736980ba912879b2a19827196 Mon Sep 17 00:00:00 2001 From: ingeniumed Date: Thu, 8 Jan 2026 07:39:38 +1100 Subject: [PATCH 2/2] Drop the extra v --- .github/workflows/release.yml | 4 ++-- vip-governance.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7e8152..4e40715 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,8 +60,8 @@ jobs: - name: Create Release if: steps.version_check.outputs.new_version - uses: softprops/action-gh-release@v2 + uses: softprops/action-gh-release@v2'd with: - tag_name: v${{ steps.version_check.outputs.new_version }} + tag_name: ${{ steps.version_check.outputs.new_version }} files: vip-governance-${{ steps.version_check.outputs.new_version }}.zip generate_release_notes: true diff --git a/vip-governance.php b/vip-governance.php index c4fe72d..49c4d26 100644 --- a/vip-governance.php +++ b/vip-governance.php @@ -5,7 +5,7 @@ * Description: Add additional governance capabilities to the block editor. * Author: WordPress VIP * Text Domain: vip-governance - * Version: 1.0.15 + * Version: 1.0.16 * Requires at least: 6.0 * Tested up to: 6.9 * Requires PHP: 8.1 @@ -33,7 +33,7 @@ return; } - define( 'WPCOMVIP__GOVERNANCE__PLUGIN_VERSION', '1.0.15' ); + define( 'WPCOMVIP__GOVERNANCE__PLUGIN_VERSION', '1.0.16' ); define( 'WPCOMVIP__GOVERNANCE__RULES_SCHEMA_VERSION', '1.0.0' ); if ( ! defined( 'WPCOMVIP_GOVERNANCE_ROOT_PLUGIN_FILE' ) ) {