Skip to content

Commit

Permalink
[dev] Monorepo: live branches build jobs tweaks (woocommerce#54308)
Browse files Browse the repository at this point in the history
  • Loading branch information
kalessil authored Jan 10, 2025
1 parent 6146dad commit 49f1f20
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 20 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/build-live-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ on:
push:
branches:
- trunk
paths-ignore:
- 'docs/**'
- 'packages/php/**'
- 'tools/**'
- '**/changelog/**'
- '**/tests/**'
- '**/*.md'
- '.husky/**'
- '.github/**'
- '!.github/workflows/build-live-branch.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -49,16 +59,10 @@ jobs:
echo "$CURRENT_VERSION" > "$GITHUB_WORKSPACE/plugins/woocommerce/version.txt"
cd "$GITHUB_WORKSPACE/plugins/woocommerce"
bash bin/build-zip.sh
PLUGIN_SLUG='woocommerce-dev' bash bin/build-zip.sh
mkdir "$GITHUB_WORKSPACE/zips"
mv "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce.zip" "$GITHUB_WORKSPACE/zips/woocommerce.zip"
cd "$GITHUB_WORKSPACE/zips"
unzip -qq woocommerce.zip
rm woocommerce.zip
mv woocommerce woocommerce-dev
zip -q -r -9 "woocommerce-dev.zip" "woocommerce-dev/"
rm -fR "$GITHUB_WORKSPACE/zips/woocommerce-dev"
mv "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce-dev.zip" "$GITHUB_WORKSPACE/zips/woocommerce-dev.zip"
# Plugin data is passed as a JSON object.
PLUGIN_DATA="{}"
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/pr-assess-bundle-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Compressed Size

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
paths:
- '**.jsx?'
- '**.tsx?'
Expand Down Expand Up @@ -35,7 +40,7 @@ env:
jobs:
build:
name: Check Asset Sizes
if: github.event.pull_request.draft == false
if: github.event.pull_request.draft == false && github.event.pull_request.user.login != 'github-actions[bot]'
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/pr-build-live-branch.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Build Live Branch
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
paths-ignore:
- 'docs/**'
- 'packages/php/**'
Expand All @@ -24,7 +29,7 @@ permissions: {}

jobs:
build:
if: github.repository_owner == 'woocommerce' && github.event.pull_request.user.login != 'github-actions[bot]'
if: github.repository_owner == 'woocommerce' && github.event.pull_request.draft == false && github.event.pull_request.user.login != 'github-actions[bot]'
runs-on: ubuntu-20.04
permissions:
contents: write
Expand Down Expand Up @@ -64,18 +69,16 @@ jobs:
echo "$CURRENT_VERSION" > "$GITHUB_WORKSPACE/plugins/woocommerce/version.txt"
cd "$GITHUB_WORKSPACE/plugins/woocommerce"
bash bin/build-zip.sh
PLUGIN_SLUG='woocommerce-dev' bash bin/build-zip.sh
mkdir "$GITHUB_WORKSPACE/zips"
mv "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce-dev.zip" "$GITHUB_WORKSPACE/zips/woocommerce-dev.zip"
mkdir -p "$GITHUB_WORKSPACE/unzips/woocommerce"
mv "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce.zip" "$GITHUB_WORKSPACE/zips/woocommerce.zip"
cd "$GITHUB_WORKSPACE/zips"
unzip -qq woocommerce.zip
cp -r woocommerce "$GITHUB_WORKSPACE/unzips/woocommerce/woocommerce"
rm woocommerce.zip
mv woocommerce woocommerce-dev
zip -q -r -9 "woocommerce-dev.zip" "woocommerce-dev/"
rm -fR "$GITHUB_WORKSPACE/zips/woocommerce-dev"
unzip -qq woocommerce-dev.zip
mv "$GITHUB_WORKSPACE/zips/woocommerce-dev" "$GITHUB_WORKSPACE/unzips/woocommerce/woocommerce"
# Plugin data is passed as a JSON object.
PLUGIN_DATA="{}"
PLUGIN_DATA=$( jq -c --arg slug "woocommerce" --arg ver "$CURRENT_VERSION" '.[ $slug ] = { version: $ver }' <<<"$PLUGIN_DATA" )
Expand Down
8 changes: 6 additions & 2 deletions plugins/woocommerce/bin/build-zip.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/sh

PLUGIN_SLUG="woocommerce"
# Possible slugs: woocommerce-dev (live branches) and woocommerce (plugin build)
if [ -z "$PLUGIN_SLUG" ]; then
PLUGIN_SLUG="woocommerce"
fi

PROJECT_PATH=$(pwd)
BUILD_PATH="${PROJECT_PATH}/build"
DEST_PATH="$BUILD_PATH/$PLUGIN_SLUG"
Expand All @@ -17,7 +21,7 @@ echo "Installing PHP and JS dependencies..."
pnpm install --frozen-lockfile

echo "Running JS Build..."
if [ -z "${NODE_ENV}" ]; then
if [ -z "$NODE_ENV" ]; then
export NODE_ENV=production
fi
pnpm --filter='@woocommerce/plugin-woocommerce' build || exit "$?"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

CI: live-branches jobs tweaks.

0 comments on commit 49f1f20

Please sign in to comment.