woocommerce/.github/workflows/build-live-branch.yml

93 lines
3.8 KiB
YAML
Raw Normal View History

name: Build live branch when trunk updated
on:
push:
branches:
- trunk
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: {}
jobs:
build:
if: github.repository_owner == 'woocommerce' && github.actor != 'github-actions[bot]'
runs-on: ubuntu-20.04
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Get current version
id: version
uses: actions/github-script@v6.3.3
with:
script:
const { getVersion } = require( './.github/workflows/scripts/get-plugin-version' );
const version = await getVersion( 'woocommerce' );
core.setOutput( 'version', version );
- name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo
CI: caching tweaks in GitHub actions (#48865) * Tooling: cache pnp deps * Tooling: try fixing cache errors * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: added pre-build steps to solve concurrency issues * Tooling: limit workers * Tooling: revert to original build command * Tooling: playwright related tweaks * Tooling: minor tweaks. * Tooling: fix caching path. * Tooling: trigger php builds to test deps caching. * Tooling: trigger php builds to test deps caching. * Tooling: lock caching to monorepo setup, so it doesn't slow down build steps. * Tooling: lock Playwright cache to build, as build is pre-requisite for running tests. * Tooling: added caching build-folders. * Tooling: added caching build-folders. * Tooling: added caching build-folders. * Revert "Tooling: added caching build-folders." This reverts commit c57b9dff13452b2404278e69658500a88cef9951. * Tooling: added caching build-folders. * Tooling: cleanup sweep. * Tooling: cleanup sweep. * Tooling: added a changelog entry. * Tooling: cleanup. * Tooling: try speedup live branches build. * Tooling: try speedup live branches build. * Tooling: cleanup. * Tooling: try speedup live branches build. * Tooling: try speedup live branches build.
2024-06-28 13:50:32 +00:00
- name: Cache PNPM Dependencies
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
with:
node-version-file: .nvmrc
cache: pnpm
- name: Prepare plugin zips
id: prepare
env:
CURRENT_VERSION: ${{ steps.version.outputs.version }}
run: |
# Current version must compare greater than any previously used current version for this PR.
# Assume GH run IDs are monotonic.
VERSUFFIX="${GITHUB_RUN_ID}-g$(git rev-parse --short HEAD)"
CURRENT_VERSION="$CURRENT_VERSION-$VERSUFFIX"
sed -i -e 's/Version: .*$/Version: '"$CURRENT_VERSION"'/' "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce.php"
echo "$CURRENT_VERSION" > "$GITHUB_WORKSPACE/plugins/woocommerce/version.txt"
cd "$GITHUB_WORKSPACE/plugins/woocommerce"
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"
CI: caching tweaks in GitHub actions (#48865) * Tooling: cache pnp deps * Tooling: try fixing cache errors * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: try to parallelize js builds a bit * Tooling: added pre-build steps to solve concurrency issues * Tooling: limit workers * Tooling: revert to original build command * Tooling: playwright related tweaks * Tooling: minor tweaks. * Tooling: fix caching path. * Tooling: trigger php builds to test deps caching. * Tooling: trigger php builds to test deps caching. * Tooling: lock caching to monorepo setup, so it doesn't slow down build steps. * Tooling: lock Playwright cache to build, as build is pre-requisite for running tests. * Tooling: added caching build-folders. * Tooling: added caching build-folders. * Tooling: added caching build-folders. * Revert "Tooling: added caching build-folders." This reverts commit c57b9dff13452b2404278e69658500a88cef9951. * Tooling: added caching build-folders. * Tooling: cleanup sweep. * Tooling: cleanup sweep. * Tooling: added a changelog entry. * Tooling: cleanup. * Tooling: try speedup live branches build. * Tooling: try speedup live branches build. * Tooling: cleanup. * Tooling: try speedup live branches build. * Tooling: try speedup live branches build.
2024-06-28 13:50:32 +00:00
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"
# 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" )
echo "plugin-data=$PLUGIN_DATA" >> $GITHUB_OUTPUT
- name: Create plugins artifact
uses: actions/upload-artifact@v4
if: steps.prepare.outputs.plugin-data != '{}'
with:
name: plugins
path: zips
# Only need to retain for a day since the beta builder slurps it up to distribute.
retention-days: 1
- name: Inform Beta Download webhook
if: steps.prepare.outputs.plugin-data != '{}'
env:
SECRET: ${{ secrets.WOOBETA_SECRET }}
PLUGIN_DATA: ${{ steps.prepare.outputs.plugin-data }}
run: |
curl -v --fail -L \
--url "https://betadownload.jetpack.me/gh-action.php?run_id=$GITHUB_RUN_ID&commit=$GITHUB_SHA" \
--form-string "repo=$GITHUB_REPOSITORY" \
--form-string "branch=${GITHUB_REF#refs/heads/}" \
--form-string "plugins=$PLUGIN_DATA" \
--form-string "secret=$SECRET"