2024-05-09 05:30:35 +00:00
|
|
|
name: Build Live Branch
|
2022-11-15 19:58:27 +00:00
|
|
|
on:
|
2022-12-05 17:28:02 +00:00
|
|
|
pull_request:
|
2023-01-12 01:09:36 +00:00
|
|
|
paths-ignore:
|
2024-03-26 08:35:22 +00:00
|
|
|
- 'docs/**'
|
|
|
|
- 'packages/php/**'
|
|
|
|
- 'tools/**'
|
2023-01-12 01:09:36 +00:00
|
|
|
- '**/changelog/**'
|
2024-03-26 08:35:22 +00:00
|
|
|
- '**/tests/**'
|
|
|
|
- '**/*.md'
|
2024-07-26 09:41:10 +00:00
|
|
|
- '.github/**'
|
|
|
|
- '!.github/workflows/pr-build-live-branch.yml'
|
2022-11-15 19:58:27 +00:00
|
|
|
|
|
|
|
concurrency:
|
2022-12-05 17:28:02 +00:00
|
|
|
# Cancel concurrent jobs on pull_request but not push, by including the run_id in the concurrency group for the latter.
|
|
|
|
group: build-${{ github.event_name == 'push' && github.run_id || 'pr' }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
2022-11-15 19:58:27 +00:00
|
|
|
|
2023-01-02 17:28:11 +00:00
|
|
|
permissions: {}
|
|
|
|
|
2022-11-15 19:58:27 +00:00
|
|
|
jobs:
|
2022-12-05 17:28:02 +00:00
|
|
|
build:
|
2023-03-09 23:10:33 +00:00
|
|
|
if: github.repository_owner == 'woocommerce' && github.event.pull_request.user.login != 'github-actions[bot]'
|
2022-12-05 17:28:02 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2023-01-02 17:28:11 +00:00
|
|
|
permissions:
|
2024-05-09 05:30:35 +00:00
|
|
|
contents: write
|
|
|
|
pull-requests: write
|
|
|
|
repository-projects: write
|
|
|
|
id-token: write
|
2022-12-05 17:28:02 +00:00
|
|
|
steps:
|
2024-06-11 16:48:00 +00:00
|
|
|
- uses: actions/checkout@v4
|
2022-11-15 19:58:27 +00:00
|
|
|
|
2022-12-05 17:28:02 +00:00
|
|
|
- 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
|
2024-06-28 13:50:32 +00:00
|
|
|
with:
|
2024-07-10 12:39:49 +00:00
|
|
|
pull-package-deps: '@woocommerce/plugin-woocommerce'
|
2024-06-28 13:50:32 +00:00
|
|
|
|
2022-12-05 17:28:02 +00:00
|
|
|
- name: Prepare plugin zips
|
|
|
|
id: prepare
|
|
|
|
env:
|
|
|
|
CURRENT_VERSION: ${{ steps.version.outputs.version }}
|
|
|
|
run: |
|
|
|
|
|
2024-05-09 05:30:35 +00:00
|
|
|
# Current version must compare greater than any previously used current version for this PR.
|
2022-12-05 17:28:02 +00:00
|
|
|
# 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"
|
2024-05-09 05:30:35 +00:00
|
|
|
mkdir -p "$GITHUB_WORKSPACE/unzips/woocommerce"
|
2024-07-04 08:12:52 +00:00
|
|
|
mv "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce.zip" "$GITHUB_WORKSPACE/zips/woocommerce.zip"
|
2022-12-05 17:28:02 +00:00
|
|
|
cd "$GITHUB_WORKSPACE/zips"
|
2024-06-28 13:50:32 +00:00
|
|
|
unzip -qq woocommerce.zip
|
2024-05-09 05:30:35 +00:00
|
|
|
cp -r woocommerce "$GITHUB_WORKSPACE/unzips/woocommerce/woocommerce"
|
2022-12-05 17:28:02 +00:00
|
|
|
rm woocommerce.zip
|
|
|
|
mv woocommerce woocommerce-dev
|
2024-07-04 08:12:52 +00:00
|
|
|
zip -q -r -9 "woocommerce-dev.zip" "woocommerce-dev/"
|
2022-12-05 17:28:02 +00:00
|
|
|
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
|
2024-06-11 16:48:00 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2022-12-05 17:28:02 +00:00
|
|
|
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
|
|
|
|
|
2024-05-09 05:30:35 +00:00
|
|
|
- name: Create playground artifact
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
if: steps.prepare.outputs.plugin-data != '{}'
|
|
|
|
with:
|
|
|
|
name: plugins-${{ github.run_id }}
|
|
|
|
path: unzips/woocommerce
|
|
|
|
retention-days: 30
|
|
|
|
|
2024-06-11 16:48:00 +00:00
|
|
|
- name: Inform Beta Download webhook if this is an internal PR
|
|
|
|
if: steps.prepare.outputs.plugin-data != '{}' && ! github.event.pull_request.head.repo.fork
|
2022-12-05 17:28:02 +00:00
|
|
|
env:
|
|
|
|
SECRET: ${{ secrets.WOOBETA_SECRET }}
|
|
|
|
PLUGIN_DATA: ${{ steps.prepare.outputs.plugin-data }}
|
|
|
|
PR: ${{ github.event.number }}
|
|
|
|
run: |
|
|
|
|
curl -v --fail -L \
|
|
|
|
--url "https://betadownload.jetpack.me/gh-action.php?run_id=$GITHUB_RUN_ID&pr=$PR&commit=$GITHUB_SHA" \
|
|
|
|
--form-string "repo=$GITHUB_REPOSITORY" \
|
|
|
|
--form-string "branch=${GITHUB_REF#refs/heads/}" \
|
|
|
|
--form-string "plugins=$PLUGIN_DATA" \
|
|
|
|
--form-string "secret=$SECRET"
|
2024-05-09 05:30:35 +00:00
|
|
|
|
|
|
|
- name: Comment on PR with WordPress Playground details
|
|
|
|
uses: actions/github-script@v7
|
|
|
|
if: steps.prepare.outputs.plugin-data != '{}'
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const { run } = require('./.github/workflows/scripts/generate-playground-blueprint');
|
|
|
|
run({ github, context, core });
|