From ea241908266dd082676f9869d29e492b65fdda5c Mon Sep 17 00:00:00 2001 From: Alec Geatches Date: Wed, 31 Dec 2025 10:10:48 -0700 Subject: [PATCH 1/6] Add release workflow --- .github/workflows/release.yml | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) 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..668f1af --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: Release +on: + push: + branches: + - trunk + +jobs: + check_and_release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check for version change + id: version_check + run: | + OLD_VERSION=$(git show HEAD^:vip-block-data-api.php | sed -n 's/.*Version: *//p' | tr -d '[:space:]') + NEW_VERSION=$(git show HEAD:vip-block-data-api.php | sed -n 's/.*Version: *//p' | tr -d '[:space:]') + DEFINED_VERSION=$(git show HEAD:vip-block-data-api.php | sed -n "s/.*define( 'WPCOMVIP__BLOCK_DATA_API__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" + 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-block-data-api/" HEAD -o "vip-block-data-api-${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-block-data-api-${{ steps.version_check.outputs.new_version }}.zip + generate_release_notes: true From d695732726663355033dd9fe5162d5cd8a4471a5 Mon Sep 17 00:00:00 2001 From: Alec Geatches Date: Wed, 31 Dec 2025 10:24:42 -0700 Subject: [PATCH 2/6] Simplify RELEASE.md instructions --- RELEASE.md | 56 +++++------------------------------------------------- 1 file changed, 5 insertions(+), 51 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 0e35baa..5b5dcee 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,61 +1,15 @@ # Release steps -## 1. Create a release branch +## 1. Bump plugin version -1. Before merging a feature, create a release branch for the next target version, e.g. +1. When the version is ready for release, bump the version number in `vip-block-data-api.php`. Change plugin header and `WPCOMVIP__BLOCK_DATA_API__PLUGIN_VERSION` to match new version. +2. PR version changes and merge to `trunk`. On version change, the release workflow will generate a new tag and release ZIP. - ```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. Bump plugin version - -1. When the version is ready for release, inside the `planned-release/...` branch, bump the version number in `vip-block-data-api.php`. Change plugin header and `WPCOMVIP__BLOCK_DATA_API__PLUGIN_VERSION` to match new version. -2. Push the `planned-release/...` branch to GitHub. -3. PR version changes with feature changes and merge to `trunk`. - -## 3. Tag branch for release - -1. In `trunk`, add a signed tag for the release: - - ```bash - git checkout trunk - git pull - git tag -s -a -m "Release " - - # e.g. git tag -s -a 1.0.2 -m "Release 1.0.2" - ``` - -2. Run `git push --tags`. - -## 4. Create a release - -1. In the `vip-block-data-api` folder, run this command to create a plugin ZIP: - - ```bash - git archive --prefix "vip-block-data-api/" -o vip-block-data-api-.zip - - # e.g. git archive --prefix "vip-block-data-api/" 1.0.2 -o vip-block-data-api-1.0.2.zip - # - # Creates a ZIP archive with the prefix folder "vip-block-data-api/" containing files from tag 1.0.2 - ``` - -2. Visit the [vip-block-data-api create release page](https://github.com/Automattic/vip-block-data-api/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." - -## 5. Update integrations +## 2. Update integrations Patch updates (e.g. `1.2.3` -> `1.2.4`) do not require any additional steps. -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. +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. For an example updating an integration version, [see this mu-plugins PR](https://github.com/Automattic/vip-go-mu-plugins/pull/5409). From 51f378801717b73386aef07361d6901885216198 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 17:25:40 +0000 Subject: [PATCH 3/6] Initial plan From 1708737962cf6c1feabef6db67df8056f73dc4c1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 17:29:25 +0000 Subject: [PATCH 4/6] Fix release workflow: add permissions and fail on version mismatch Co-authored-by: alecgeatches <17870752+alecgeatches@users.noreply.github.com> --- .github/workflows/release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 668f1af..400518c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,9 @@ on: branches: - trunk +permissions: + contents: write + jobs: check_and_release: runs-on: ubuntu-latest @@ -23,6 +26,7 @@ jobs: 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 From 1c127a15b05f2731709b56d81222508b667196c2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 17:32:38 +0000 Subject: [PATCH 5/6] Remove exit 1 from version mismatch check Co-authored-by: alecgeatches <17870752+alecgeatches@users.noreply.github.com> --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 400518c..19de46b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,6 @@ jobs: 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 From 9dd0765b0801aa7abf3ced3973b681c8903eb4f8 Mon Sep 17 00:00:00 2001 From: Alec Geatches Date: Wed, 31 Dec 2025 10:34:20 -0700 Subject: [PATCH 6/6] Add error exit state when there's a define version mismatch --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 668f1af..cece8fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,7 @@ jobs: 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