Skip to content

Commit 82eb7bc

Browse files
authored
Merge pull request #94 from Automattic/add/release-automation
Add release workflow automation
2 parents ddc91c9 + 800f6d8 commit 82eb7bc

2 files changed

Lines changed: 56 additions & 51 deletions

File tree

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- trunk
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
check_and_release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Check for version change
19+
id: version_check
20+
run: |
21+
OLD_VERSION=$(git show HEAD^:vip-block-data-api.php | sed -n 's/.*Version: *//p' | tr -d '[:space:]')
22+
NEW_VERSION=$(git show HEAD:vip-block-data-api.php | sed -n 's/.*Version: *//p' | tr -d '[:space:]')
23+
DEFINED_VERSION=$(git show HEAD:vip-block-data-api.php | sed -n "s/.*define( 'WPCOMVIP__BLOCK_DATA_API__PLUGIN_VERSION', '\\([^']*\\)'.*/\\1/p")
24+
25+
if [ "$NEW_VERSION" != "$DEFINED_VERSION" ]; then
26+
echo "Error: Version mismatch detected!"
27+
echo "Plugin header version: $NEW_VERSION"
28+
echo "Defined constant version: $DEFINED_VERSION"
29+
exit 1
30+
fi
31+
32+
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
33+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
34+
echo "Version changed from $OLD_VERSION to $NEW_VERSION"
35+
else
36+
echo "No version change detected"
37+
fi
38+
39+
- name: Build plugin zip
40+
if: steps.version_check.outputs.new_version
41+
run: |
42+
VERSION="${{ steps.version_check.outputs.new_version }}"
43+
git archive --prefix "vip-block-data-api/" HEAD -o "vip-block-data-api-${VERSION}.zip"
44+
45+
- name: Create Release
46+
if: steps.version_check.outputs.new_version
47+
uses: softprops/action-gh-release@v2
48+
with:
49+
tag_name: v${{ steps.version_check.outputs.new_version }}
50+
files: vip-block-data-api-${{ steps.version_check.outputs.new_version }}.zip
51+
generate_release_notes: true

RELEASE.md

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,15 @@
11
# Release steps
22

3-
## 1. Create a release branch
3+
## 1. Bump plugin version
44

5-
1. Before merging a feature, create a release branch for the next target version, e.g.
5+
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.
6+
2. PR version changes and merge to `trunk`. On version change, the release workflow will generate a new tag and release ZIP.
67

7-
```bash
8-
git checkout trunk
9-
git checkout -b planned-release/0.2.1
10-
```
11-
12-
2. In GitHub, select the base branch as the `planned-release/...` branch.
13-
3. Merge feature branches into the `planned-release/...` branch.
14-
15-
## 2. Bump plugin version
16-
17-
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.
18-
2. Push the `planned-release/...` branch to GitHub.
19-
3. PR version changes with feature changes and merge to `trunk`.
20-
21-
## 3. Tag branch for release
22-
23-
1. In `trunk`, add a signed tag for the release:
24-
25-
```bash
26-
git checkout trunk
27-
git pull
28-
git tag -s -a <version> -m "Release <version>"
29-
30-
# e.g. git tag -s -a 1.0.2 -m "Release 1.0.2"
31-
```
32-
33-
2. Run `git push --tags`.
34-
35-
## 4. Create a release
36-
37-
1. In the `vip-block-data-api` folder, run this command to create a plugin ZIP:
38-
39-
```bash
40-
git archive --prefix "vip-block-data-api/" <version> -o vip-block-data-api-<version>.zip
41-
42-
# e.g. git archive --prefix "vip-block-data-api/" 1.0.2 -o vip-block-data-api-1.0.2.zip
43-
#
44-
# Creates a ZIP archive with the prefix folder "vip-block-data-api/" containing files from tag 1.0.2
45-
```
46-
47-
2. Visit the [vip-block-data-api create release page](https://github.com/Automattic/vip-block-data-api/releases/new).
48-
3. Select the newly created version tag in the dropdown.
49-
4. For the title, enter the release version name (e.g. `1.0.2`)
50-
5. Add a description of release changes.
51-
6. Attach the plugin ZIP.
52-
7. Click "Publish release."
53-
54-
## 5. Update integrations
8+
## 2. Update integrations
559

5610
Patch updates (e.g. `1.2.3` -> `1.2.4`) do not require any additional steps.
5711

58-
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.
12+
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.
5913

6014
For an example updating an integration version, [see this mu-plugins PR](https://github.com/Automattic/vip-go-mu-plugins/pull/5409).
6115

0 commit comments

Comments
 (0)