From f1491c6a6a9ef65afd0548418382d583223c5792 Mon Sep 17 00:00:00 2001 From: "Chris K.Y. FUNG" <8746768+chriskyfung@users.noreply.github.com> Date: Sun, 28 Apr 2024 13:58:12 +0800 Subject: [PATCH] Create GitHub Actions workflow to build zip (#2) Introduce CI/CD workflow for on-demand ZIP build using GitHub Actions. This update implements a GitHub Action to automate the creation of a ZIP file for our WordPress plugin when it was run manually on GitHub, GitHub CLI, or the REST API. The ZIP is available for download immediately, facilitating rapid testing and deployment. - Copied the bash commands from `tools/build_release.sh` as the build plugin action --- .github/workflows/build-zip.yml | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/build-zip.yml diff --git a/.github/workflows/build-zip.yml b/.github/workflows/build-zip.yml new file mode 100644 index 00000000..2c0c0a91 --- /dev/null +++ b/.github/workflows/build-zip.yml @@ -0,0 +1,54 @@ +name: Build release zip + +on: + workflow_dispatch + +jobs: + build: + name: Build release zip + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build plugin # modify this step as needed + run: | + # run script from project root + EXEC_DIR=$(pwd) + + TMP_DIR="$EXEC_DIR/plugintmp" + rm -Rf "$TMP_DIR" + mkdir -p "$TMP_DIR" + + rm -Rf "$TMP_DIR/wp2static" + mkdir "$TMP_DIR/wp2static" + + # clear dev dependencies + rm -Rf "$EXEC_DIR/vendor/*" + # load prod deps and optimize loader + composer install --quiet --no-dev --optimize-autoloader + + # cp all required sources to build dir + cp -r "$EXEC_DIR"/src "$TMP_DIR"/wp2static/ + cp -r "$EXEC_DIR"/vendor "$TMP_DIR"/wp2static/ + cp -r "$EXEC_DIR"/views "$TMP_DIR"/wp2static/ + cp -r "$EXEC_DIR"/css "$TMP_DIR"/wp2static/ + cp -r "$EXEC_DIR"/js "$TMP_DIR"/wp2static/ + cp -r "$EXEC_DIR"/*.php "$TMP_DIR"/wp2static/ + + cd "$TMP_DIR" || exit + + # tidy permissions + find . -type d -exec chmod 755 {} \; + find . -type f -exec chmod 644 {} \; + shell: bash + + - name: Upload the archive as an artifact + id: upload-plugin-artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.repository.name }} + path: plugintmp/wp2static + +