Skip to content

Commit f5694c1

Browse files
committed
Add release workflow and build script
Add a GitHub Actions workflow to detect plugin version bumps, build a distributable zip, tag the repo and create a GitHub release. Add an executable bin/build-zip.sh script to locally produce dist/workos-for-wordpress-{version}.zip (installs production Composer deps and packages the plugin). Ignore /dist/ in .gitignore. Bump plugin header and WORKOS_WP_VERSION constant to 0.9.0 to match the packaged version.
1 parent 3a55026 commit f5694c1

4 files changed

Lines changed: 168 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'workos-for-wordpress.php'
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
check-version:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
version: ${{ steps.detect.outputs.version }}
18+
changed: ${{ steps.detect.outputs.changed }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 2
24+
25+
- name: Detect version bump
26+
id: detect
27+
run: |
28+
VERSION=$(grep -oP "Version:\s*\K[0-9]+\.[0-9]+\.[0-9]+" workos-for-wordpress.php)
29+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
30+
31+
# Check if the version line changed in this commit.
32+
if git diff HEAD~1 HEAD -- workos-for-wordpress.php | grep -qP '^\+.*Version:\s'; then
33+
echo "changed=true" >> "$GITHUB_OUTPUT"
34+
else
35+
echo "changed=false" >> "$GITHUB_OUTPUT"
36+
fi
37+
38+
- name: Skip if no version change
39+
if: steps.detect.outputs.changed != 'true'
40+
run: echo "No version bump detected — skipping release."
41+
42+
release:
43+
needs: check-version
44+
if: needs.check-version.outputs.changed == 'true'
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
50+
- name: Check tag doesn't already exist
51+
run: |
52+
if git ls-remote --tags origin | grep -q "refs/tags/v${{ needs.check-version.outputs.version }}$"; then
53+
echo "::error::Tag v${{ needs.check-version.outputs.version }} already exists."
54+
exit 1
55+
fi
56+
57+
- name: Setup PHP
58+
uses: shivammathur/setup-php@v2
59+
with:
60+
php-version: '8.1'
61+
tools: composer:v2
62+
63+
- name: Install production dependencies
64+
run: composer install --no-dev --optimize-autoloader --no-interaction
65+
66+
- name: Build plugin zip
67+
run: |
68+
PLUGIN_SLUG="workos-for-wordpress"
69+
VERSION="${{ needs.check-version.outputs.version }}"
70+
BUILD_DIR=$(mktemp -d)
71+
DEST="$BUILD_DIR/$PLUGIN_SLUG"
72+
mkdir -p "$DEST"
73+
74+
rsync -a \
75+
--exclude='.git' \
76+
--exclude='.github' \
77+
--exclude='node_modules' \
78+
--exclude='dist' \
79+
--exclude='bin' \
80+
--exclude='tests' \
81+
--exclude='.env' \
82+
--exclude='composer.lock' \
83+
--exclude='phpunit.xml*' \
84+
--exclude='.phpcs.xml*' \
85+
--exclude='.editorconfig' \
86+
--exclude='.gitignore' \
87+
--exclude='.claude' \
88+
--exclude='CLAUDE.md' \
89+
./ "$DEST/"
90+
91+
cd "$BUILD_DIR"
92+
zip -rq "$GITHUB_WORKSPACE/$PLUGIN_SLUG-$VERSION.zip" "$PLUGIN_SLUG"
93+
94+
- name: Create tag and GitHub Release
95+
env:
96+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
run: |
98+
VERSION="${{ needs.check-version.outputs.version }}"
99+
git tag "v$VERSION"
100+
git push origin "v$VERSION"
101+
gh release create "v$VERSION" \
102+
"workos-for-wordpress-$VERSION.zip" \
103+
--title "v$VERSION" \
104+
--generate-notes

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/vendor/
2+
/dist/
23
composer.lock

bin/build-zip.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Build a distributable plugin zip with dependencies included.
4+
#
5+
# Usage:
6+
# ./bin/build-zip.sh
7+
#
8+
# Output:
9+
# dist/workos-for-wordpress-{version}.zip
10+
11+
set -euo pipefail
12+
13+
PLUGIN_SLUG="workos-for-wordpress"
14+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
15+
PLUGIN_DIR="$(dirname "$SCRIPT_DIR")"
16+
VERSION=$(grep -oP "Version:\s*\K[^\s]+" "$PLUGIN_DIR/$PLUGIN_SLUG.php")
17+
BUILD_DIR=$(mktemp -d)
18+
DEST="$BUILD_DIR/$PLUGIN_SLUG"
19+
DIST_DIR="$PLUGIN_DIR/dist"
20+
21+
echo "Building $PLUGIN_SLUG v$VERSION..."
22+
23+
# Copy plugin files (exclude dev/build artifacts).
24+
mkdir -p "$DEST"
25+
rsync -a \
26+
--exclude='.git' \
27+
--exclude='.github' \
28+
--exclude='node_modules' \
29+
--exclude='dist' \
30+
--exclude='bin' \
31+
--exclude='tests' \
32+
--exclude='.env' \
33+
--exclude='.DS_Store' \
34+
--exclude='*.log' \
35+
--exclude='composer.lock' \
36+
--exclude='phpunit.xml*' \
37+
--exclude='.phpcs.xml*' \
38+
--exclude='.editorconfig' \
39+
--exclude='.gitignore' \
40+
--exclude='.claude' \
41+
--exclude='CLAUDE.md' \
42+
"$PLUGIN_DIR/" "$DEST/"
43+
44+
# Install production dependencies only (no dev).
45+
cd "$DEST"
46+
composer install --no-dev --optimize-autoloader --no-interaction --quiet
47+
rm -f composer.lock
48+
49+
echo "Installed production dependencies."
50+
51+
# Create dist directory and zip.
52+
mkdir -p "$DIST_DIR"
53+
ZIP_FILE="$DIST_DIR/$PLUGIN_SLUG-$VERSION.zip"
54+
cd "$BUILD_DIR"
55+
zip -rq "$ZIP_FILE" "$PLUGIN_SLUG"
56+
57+
# Clean up.
58+
rm -rf "$BUILD_DIR"
59+
60+
echo "Done: $ZIP_FILE"
61+
echo "Size: $(du -h "$ZIP_FILE" | cut -f1)"

workos-for-wordpress.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: WorkOS for WordPress
44
* Plugin URI: https://github.com/AlwaysCuriousCo/workos-for-wordpress
55
* Description: Integrate WorkOS authentication and user management into WordPress.
6-
* Version: 1.0.0
6+
* Version: 0.9.0
77
* Author: Always Curious
88
* Author URI: https://alwayscurious.co
99
* License: GPL-3.0-or-later
@@ -15,7 +15,7 @@
1515

1616
defined('ABSPATH') || exit;
1717

18-
define('WORKOS_WP_VERSION', '1.0.0');
18+
define('WORKOS_WP_VERSION', '0.9.0');
1919
define('WORKOS_WP_PLUGIN_FILE', __FILE__);
2020
define('WORKOS_WP_PLUGIN_DIR', plugin_dir_path(__FILE__));
2121
define('WORKOS_WP_PLUGIN_URL', plugin_dir_url(__FILE__));

0 commit comments

Comments
 (0)