From 50891b8e9ed0da48d43b9a5c09e420b5fc24dc54 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Tue, 29 Nov 2022 20:06:31 +0530 Subject: [PATCH 1/5] Update release instructions. --- CONTRIBUTING.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 24472906..6d7a60fd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,15 +29,16 @@ The develop branch is the development branch which means it contains the next ve ## Release instructions 1. Branch: Starting from `develop`, cut a release branch named `release/X.Y.Z` for your changes. -1. Version bump: Bump the version number in `autoshare-for-twitter.php`, `readme.txt`, `package-lock.json`, `package.json`, and `composer.json`(`autoloader-suffix` config option) if it does not already reflect the version being released. In `autoshare-for-twitter.php` update both the plugin "Version:" property and the plugin `AUTOSHARE_FOR_TWITTER_VERSION` constant. -1. Changelog: Add/update the changelog in `CHANGELOG.md` and `readme.txt`. -1. Props: update `CREDITS.md` file with any new contributors, confirm maintainers are accurate. -1. New files: Check to be sure any new files/paths that are unnecessary in the production version are included in `.distignore`. -1. Readme updates: Make any other readme changes as necessary. `README.md` is geared toward GitHub and `readme.txt` contains WordPress.org-specific content. The two are slightly different. -1. Merge: Make a non-fast-forward merge from your release branch to `develop` (or merge the pull request), then do the same for `develop` into `trunk` (`git checkout trunk && git merge --no-ff develop`). `trunk` contains the stable development version. -1. Push: Push your `trunk` branch to GitHub (e.g. `git push origin trunk`). -1. Release: Create a [new release](https://github.com/10up/autoshare-for-twitter/releases/new), naming the tag and the release with the new version number, and targeting the `trunk` branch. Paste the changelog from `CHANGELOG.md` into the body of the release and include a link to the [closed issues on the milestone](https://github.com/10up/autoshare-for-twitter/milestone/#?closed=1). -1. SVN: Wait for the [GitHub Action](https://github.com/10up/autoshare-for-twitter/actions/workflows/deploy-to-wpdotorg.yml) to finish deploying to the WordPress.org repository. If all goes well, users with SVN commit access for that plugin will receive an emailed diff of changes. -1. Check WordPress.org: Ensure that the changes are live on https://wordpress.org/plugins/autoshare-for-twitter/. This may take a few minutes. -1. Close the milestone: Edit the [milestone](https://github.com/10up/autoshare-for-twitter/milestone/#) with release date (in the `Due date (optional)` field) and link to GitHub release (in the `Description` field), then close the milestone. -1. Punt incomplete items: If any open issues or PRs which were milestoned for `X.Y.Z` do not make it into the release, update their milestone to `X+1.0.0`, `X.Y+1.0`, `X.Y.Z+1`, or `Future Release` +2. Version bump: Bump the version number in `autoshare-for-twitter.php`, `readme.txt`, `package-lock.json`, `package.json`, and `composer.json`(`autoloader-suffix` config option) if it does not already reflect the version being released. In `autoshare-for-twitter.php` update both the plugin "Version:" property and the plugin `AUTOSHARE_FOR_TWITTER_VERSION` constant. +3. Changelog: Add/update the changelog in `CHANGELOG.md` and `readme.txt`. +4. Props: update `CREDITS.md` file with any new contributors, confirm maintainers are accurate. +5. New files: Check to be sure any new files/paths that are unnecessary in the production version are included in `.distignore`. +6. Readme updates: Make any other readme changes as necessary. `README.md` is geared toward GitHub and `readme.txt` contains WordPress.org-specific content. The two are slightly different. +7. Merge: Make a non-fast-forward merge from your release branch to `develop` (or merge the pull request), then do the same for `develop` into `trunk` (`git checkout trunk && git merge --no-ff develop`). `trunk` contains the stable development version. +8. Push: Push your `trunk` branch to GitHub (e.g. `git push origin trunk`). +9. Test the pre-release ZIP locally by downloading it from the **Build release zip** action artifact to ensure the plugin doesn't break after release. +10. Release: Create a [new release](https://github.com/10up/autoshare-for-twitter/releases/new), naming the tag and the release with the new version number, and targeting the `trunk` branch. Paste the changelog from `CHANGELOG.md` into the body of the release and include a link to the [closed issues on the milestone](https://github.com/10up/autoshare-for-twitter/milestone/#?closed=1). +11. SVN: Wait for the [GitHub Action](https://github.com/10up/autoshare-for-twitter/actions/workflows/deploy-to-wpdotorg.yml) to finish deploying to the WordPress.org repository. If all goes well, users with SVN commit access for that plugin will receive an emailed diff of changes. +12. Check WordPress.org: Ensure that the changes are live on https://wordpress.org/plugins/autoshare-for-twitter/. This may take a few minutes. +13. Close the milestone: Edit the [milestone](https://github.com/10up/autoshare-for-twitter/milestone/#) with release date (in the `Due date (optional)` field) and link to GitHub release (in the `Description` field), then close the milestone. +14. Punt incomplete items: If any open issues or PRs which were milestoned for `X.Y.Z` do not make it into the release, update their milestone to `X+1.0.0`, `X.Y+1.0`, `X.Y.Z+1`, or `Future Release` From 78a060cbd32e63004d89324d68a49dee55249ed3 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Tue, 29 Nov 2022 20:07:01 +0530 Subject: [PATCH 2/5] Added build-zip.sh to generate zip --- bin/build-zip.sh | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 bin/build-zip.sh diff --git a/bin/build-zip.sh b/bin/build-zip.sh new file mode 100644 index 00000000..a45b4402 --- /dev/null +++ b/bin/build-zip.sh @@ -0,0 +1,89 @@ +#!/bin/sh + +# Note that this does not use pipefail +# because if the grep later doesn't match any deleted files, +# which is likely the majority case, +# it does not exit with a 0, and we only care about the final exit. +set -eo + +# Allow some ENV variables to be customized +if [[ -z "$SLUG" ]]; then + SLUG=${GITHUB_REPOSITORY#*/} +fi +echo "ℹ︎ SLUG is $SLUG" + +if [[ -z "$BUILD_DIR" ]] || [[ $BUILD_DIR == "./" ]]; then + BUILD_DIR=false +elif [[ $BUILD_DIR == ./* ]]; then + BUILD_DIR=${BUILD_DIR:2} +fi + +if [[ "$BUILD_DIR" != false ]]; then + if [[ $BUILD_DIR != /* ]]; then + BUILD_DIR="${GITHUB_WORKSPACE%/}/${BUILD_DIR%/}" + fi + echo "ℹ︎ BUILD_DIR is $BUILD_DIR" +fi + +SVN_URL="https://plugins.svn.wordpress.org/${SLUG}/" +SVN_DIR="${HOME}/svn-${SLUG}" + +# Checkout just trunk for efficiency +# Tagging will be handled on the SVN level +echo "➤ Checking out .org repository..." +svn checkout --depth immediates "$SVN_URL" "$SVN_DIR" +cd "$SVN_DIR" +svn update --set-depth infinity trunk + +if [[ "$BUILD_DIR" = false ]]; then + echo "➤ Copying files..." + if [[ -e "$GITHUB_WORKSPACE/.distignore" ]]; then + echo "ℹ︎ Using .distignore" + # Copy from current branch to /trunk, excluding dotorg assets + # The --delete flag will delete anything in destination that no longer exists in source + rsync -rc --exclude-from="$GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded + else + echo "ℹ︎ Using .gitattributes" + + cd "$GITHUB_WORKSPACE" + + # "Export" a cleaned copy to a temp directory + TMP_DIR="${HOME}/archivetmp" + mkdir "$TMP_DIR" + + git config --global user.email "10upbot+github@10up.com" + git config --global user.name "10upbot on GitHub" + + # If there's no .gitattributes file, write a default one into place + if [[ ! -e "$GITHUB_WORKSPACE/.gitattributes" ]]; then + cat > "$GITHUB_WORKSPACE/.gitattributes" <<-EOL + /.gitattributes export-ignore + /.gitignore export-ignore + /.github export-ignore + EOL + + # Ensure we are in the $GITHUB_WORKSPACE directory, just in case + # The .gitattributes file has to be committed to be used + # Just don't push it to the origin repo :) + git add .gitattributes && git commit -m "Add .gitattributes file" + fi + + # This will exclude everything in the .gitattributes file with the export-ignore flag + git archive HEAD | tar x --directory="$TMP_DIR" + + cd "$SVN_DIR" + + # Copy from clean copy to /trunk, excluding dotorg assets + # The --delete flag will delete anything in destination that no longer exists in source + rsync -rc "$TMP_DIR/" trunk/ --delete --delete-excluded + fi +else + echo "ℹ︎ Copying files from build directory..." + rsync -rc "$BUILD_DIR/" trunk/ --delete --delete-excluded +fi + +echo "➤ Generating zip file..." +cd "$SVN_DIR/trunk" || exit +zip -r "${GITHUB_WORKSPACE}/${SLUG}.zip" . +echo "zip-path=${GITHUB_WORKSPACE}/${SLUG}.zip" >> "${GITHUB_OUTPUT}" +echo "✓ Zip file generated!" \ No newline at end of file From de670cc14faee8ad6b1e9e3d4c122adb07c3aa13 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Tue, 29 Nov 2022 20:08:36 +0530 Subject: [PATCH 3/5] Added "Build release zip" GitHub Action. --- .github/workflows/build-release-zip.yml | 67 +++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/build-release-zip.yml diff --git a/.github/workflows/build-release-zip.yml b/.github/workflows/build-release-zip.yml new file mode 100644 index 00000000..5c9c4385 --- /dev/null +++ b/.github/workflows/build-release-zip.yml @@ -0,0 +1,67 @@ +name: Build release zip + +on: + workflow_dispatch: + push: + branches: + - trunk + +jobs: + build: + name: Build release zip + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Cache vendor + id: cache-composer + uses: actions/cache@v3 + env: + cache-name: cache-vendor + with: + path: | + vendor + ~/.composer/cache + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }} + + - name: Cache node_modules + id: cache-node-modules + uses: actions/cache@v3 + env: + cache-name: cache-node-modules + with: + path: node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + + - name: Setup node version and npm cache + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'npm' + + - name: Install Node dependencies + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: npm install + + - name: Install Composer dependencies + if: steps.cache-vendor.outputs.cache-hit != 'true' + run: composer install --no-dev + + - name: Build plugin + run: | + npm run build + npm run build:externals + + - name: Generate ZIP file + run: bash bin/build-zip.sh + + - name: Unzip the file (prevents double zip problem) + run: unzip ${{ github.event.repository.name }}.zip -d zipfile + + - name: Upload the ZIP file as an artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ github.event.repository.name }} + path: zipfile + retention-days: 5 From 9256e7b7695ba24b3d67d4b2cd25911376ce7a7b Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Wed, 30 Nov 2022 12:00:36 +0530 Subject: [PATCH 4/5] Fix build-externals command. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 809ebfb8..985073d9 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "watch": "webpack -w --devtool eval-cheap-module-source-map --output-pathinfo --mode development --config webpack.gutenberg.config.js", "build": "webpack --optimization-minimize --mode production --config webpack.gutenberg.config.js", - "build:externals": "webpack src/js/externals/api-fetch.js -o dist/api-fetch.js -p --module-bind js=babel-loader", + "build:externals": "webpack ./src/js/externals/api-fetch.js --output-path dist/ --output-filename api-fetch.js --mode production", "env": "wp-env", "env:start": "wp-env start", "env:stop": "wp-env stop", From 9839a40e2e6c887f86e3dddd7a0aec71235b55a3 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Thu, 1 Dec 2022 14:02:01 -0700 Subject: [PATCH 5/5] Update the build release action to use our now public build release action. Remove file that's no longer needed --- .github/workflows/build-release-zip.yml | 12 +--- bin/build-zip.sh | 89 ------------------------- 2 files changed, 1 insertion(+), 100 deletions(-) delete mode 100644 bin/build-zip.sh diff --git a/.github/workflows/build-release-zip.yml b/.github/workflows/build-release-zip.yml index 5c9c4385..fb12f47c 100644 --- a/.github/workflows/build-release-zip.yml +++ b/.github/workflows/build-release-zip.yml @@ -54,14 +54,4 @@ jobs: npm run build:externals - name: Generate ZIP file - run: bash bin/build-zip.sh - - - name: Unzip the file (prevents double zip problem) - run: unzip ${{ github.event.repository.name }}.zip -d zipfile - - - name: Upload the ZIP file as an artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ github.event.repository.name }} - path: zipfile - retention-days: 5 + uses: 10up/action-wordpress-plugin-build-zip@stable diff --git a/bin/build-zip.sh b/bin/build-zip.sh deleted file mode 100644 index a45b4402..00000000 --- a/bin/build-zip.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh - -# Note that this does not use pipefail -# because if the grep later doesn't match any deleted files, -# which is likely the majority case, -# it does not exit with a 0, and we only care about the final exit. -set -eo - -# Allow some ENV variables to be customized -if [[ -z "$SLUG" ]]; then - SLUG=${GITHUB_REPOSITORY#*/} -fi -echo "ℹ︎ SLUG is $SLUG" - -if [[ -z "$BUILD_DIR" ]] || [[ $BUILD_DIR == "./" ]]; then - BUILD_DIR=false -elif [[ $BUILD_DIR == ./* ]]; then - BUILD_DIR=${BUILD_DIR:2} -fi - -if [[ "$BUILD_DIR" != false ]]; then - if [[ $BUILD_DIR != /* ]]; then - BUILD_DIR="${GITHUB_WORKSPACE%/}/${BUILD_DIR%/}" - fi - echo "ℹ︎ BUILD_DIR is $BUILD_DIR" -fi - -SVN_URL="https://plugins.svn.wordpress.org/${SLUG}/" -SVN_DIR="${HOME}/svn-${SLUG}" - -# Checkout just trunk for efficiency -# Tagging will be handled on the SVN level -echo "➤ Checking out .org repository..." -svn checkout --depth immediates "$SVN_URL" "$SVN_DIR" -cd "$SVN_DIR" -svn update --set-depth infinity trunk - -if [[ "$BUILD_DIR" = false ]]; then - echo "➤ Copying files..." - if [[ -e "$GITHUB_WORKSPACE/.distignore" ]]; then - echo "ℹ︎ Using .distignore" - # Copy from current branch to /trunk, excluding dotorg assets - # The --delete flag will delete anything in destination that no longer exists in source - rsync -rc --exclude-from="$GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded - else - echo "ℹ︎ Using .gitattributes" - - cd "$GITHUB_WORKSPACE" - - # "Export" a cleaned copy to a temp directory - TMP_DIR="${HOME}/archivetmp" - mkdir "$TMP_DIR" - - git config --global user.email "10upbot+github@10up.com" - git config --global user.name "10upbot on GitHub" - - # If there's no .gitattributes file, write a default one into place - if [[ ! -e "$GITHUB_WORKSPACE/.gitattributes" ]]; then - cat > "$GITHUB_WORKSPACE/.gitattributes" <<-EOL - /.gitattributes export-ignore - /.gitignore export-ignore - /.github export-ignore - EOL - - # Ensure we are in the $GITHUB_WORKSPACE directory, just in case - # The .gitattributes file has to be committed to be used - # Just don't push it to the origin repo :) - git add .gitattributes && git commit -m "Add .gitattributes file" - fi - - # This will exclude everything in the .gitattributes file with the export-ignore flag - git archive HEAD | tar x --directory="$TMP_DIR" - - cd "$SVN_DIR" - - # Copy from clean copy to /trunk, excluding dotorg assets - # The --delete flag will delete anything in destination that no longer exists in source - rsync -rc "$TMP_DIR/" trunk/ --delete --delete-excluded - fi -else - echo "ℹ︎ Copying files from build directory..." - rsync -rc "$BUILD_DIR/" trunk/ --delete --delete-excluded -fi - -echo "➤ Generating zip file..." -cd "$SVN_DIR/trunk" || exit -zip -r "${GITHUB_WORKSPACE}/${SLUG}.zip" . -echo "zip-path=${GITHUB_WORKSPACE}/${SLUG}.zip" >> "${GITHUB_OUTPUT}" -echo "✓ Zip file generated!" \ No newline at end of file