From 8cd123127c360a5035e2345960d913bbec74b280 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Fri, 3 Mar 2023 13:18:10 -0600 Subject: [PATCH 01/36] Allow point-releases for release branches that are not the latest anymore And other minor improvements --- .github/workflows/build-plugin-zip.yml | 45 +------- .../upload-release-to-plugin-repo.yml | 103 +++++++++++++++--- 2 files changed, 91 insertions(+), 57 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 9e30cc1c1cfc67..bac19ebcd2e469 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -56,7 +56,7 @@ jobs: github.event.inputs.version == 'rc' || github.event.inputs.version == 'stable' ) || ( - endsWith( github.ref, needs.compute-stable-branches.outputs.current_stable_branch ) && + github.ref != 'refs/heads/trunk' && github.event.inputs.version == 'stable' ) ) @@ -71,7 +71,7 @@ jobs: - name: Checkout code uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: - token: ${{ secrets.GUTENBERG_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Compute old and new version id: get_version @@ -298,44 +298,3 @@ jobs: asset_path: ./gutenberg.zip asset_name: gutenberg.zip asset_content_type: application/zip - - npm-publish: - name: Publish WordPress packages to npm - runs-on: ubuntu-latest - environment: WordPress packages - needs: [bump-version, build] - if: ${{ endsWith( needs.bump-version.outputs.new_version, '-rc.1' ) }} - steps: - - name: Checkout (for CLI) - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - with: - path: main - ref: trunk - - - name: Checkout (for publishing) - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - with: - path: publish - # Later, we switch this branch in the script that publishes packages. - ref: trunk - token: ${{ secrets.GUTENBERG_TOKEN }} - - - name: Configure git user name and email (for publishing) - run: | - cd publish - git config user.name "Gutenberg Repository Automation" - git config user.email gutenberg@wordpress.org - - - name: Setup Node.js - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 - with: - node-version-file: 'main/.nvmrc' - registry-url: 'https://registry.npmjs.org' - - - name: Publish packages to npm ("latest" dist-tag) - run: | - cd main - npm ci - ./bin/plugin/cli.js npm-latest --semver minor --ci --repository-path ../publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 5cb432ee837ee3..2d7bbbe91420bf 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -5,14 +5,32 @@ on: types: [published] jobs: + compute-latest-stable: + name: Get latest stable version + runs-on: ubuntu-latest + outputs: + latest_stable_tag: ${{ steps.get_latest_stable_tag.outputs.latest_stable_tag }} + + steps: + - uses: hmarr/debug-action@v2 + - name: Get latest stable ta + id: get_latest_stable_tag + run: | + curl \ + -H "Accept: application/vnd.github.v3+json" \ + -o latest.json \ + "https://api.github.com/repos/${{ github.repository }}/releases/latest" + LATEST_STABLE_TAG=$(jq --raw-output '.tag_name' latest.json) + echo "latest_stable_tag=${LATEST_STABLE_TAG}" >> $GITHUB_OUTPUT + get-release-branch: name: Get release branch name runs-on: ubuntu-latest - if: github.event.release.assets[0] outputs: release_branch: ${{ steps.get_release_branch.outputs.release_branch }} steps: + - uses: hmarr/debug-action@v2 - name: Compute release branch name id: get_release_branch env: @@ -25,7 +43,8 @@ jobs: update-changelog: name: Update Changelog on ${{ matrix.branch }} branch runs-on: ubuntu-latest - if: github.event.release.assets[0] + if: | + github.event.release.assets[0] needs: get-release-branch env: TAG: ${{ github.event.release.tag_name }} @@ -38,11 +57,12 @@ jobs: label: release steps: + - uses: hmarr/debug-action@v2 - name: Checkout code uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: ref: ${{ matrix.branch }} - token: ${{ secrets.GUTENBERG_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Update the Changelog to include the release notes run: | @@ -95,25 +115,24 @@ jobs: path: ./changelog.txt upload: - name: Upload Gutenberg Plugin + name: Publish as trunk (and tag) runs-on: ubuntu-latest environment: wp.org plugin - needs: update-changelog - if: ${{ !github.event.release.prerelease && github.event.release.assets[0] }} + needs: [compute-latest-stable, update-changelog] + if: | + endsWith( github.ref, needs.compute-latest-stable.outputs.latest_stable_tag ) && + !github.event.release.prerelease && github.event.release.assets[0] env: - PLUGIN_REPO_URL: 'https://plugins.svn.wordpress.org/gutenberg' + PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' SVN_USERNAME: ${{ secrets.svn_username }} SVN_PASSWORD: ${{ secrets.svn_password }} VERSION: ${{ github.event.release.name }} steps: + - uses: hmarr/debug-action@v2 - name: Check out Gutenberg trunk from WP.org plugin repo - run: svn checkout "$PLUGIN_REPO_URL/trunk" - - - name: Get previous stable version - id: get_previous_stable_version - run: echo "stable_version=$(awk -F ':\ ' '$1 == "Stable tag" {print $2}' ./trunk/readme.txt)" >> $GITHUB_OUTPUT + run: svn checkout "$PLUGIN_REPO_URL/trunk" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - name: Delete everything working-directory: ./trunk @@ -130,8 +149,8 @@ jobs: - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository env: STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' - STABLE_TAG: 'Stable tag: ${{ steps.get_previous_stable_version.outputs.stable_version }}' - run: sed -i "s/${STABLE_TAG_PLACEHOLDER}/${STABLE_TAG}/g" ./trunk/readme.txt + run: | + sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./trunk/readme.txt - name: Download Changelog Artifact uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 @@ -159,3 +178,59 @@ jobs: sed -i "s/Stable tag: ${STABLE_VERSION_REGEX}/Stable tag: ${VERSION}/g" ./readme.txt svn commit -m "Releasing version $VERSION" \ --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + + upload-branch: + name: Publish as branch (and tag) + runs-on: ubuntu-latest + environment: wp.org plugin + needs: [compute-latest-stable, update-changelog] + if: | + !endsWith( github.ref, needs.compute-latest-stable.outputs.latest_stable_tag ) && + !github.event.release.prerelease && github.event.release.assets[0] + env: + PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' + STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' + SVN_USERNAME: ${{ secrets.svn_username }} + SVN_PASSWORD: ${{ secrets.svn_password }} + VERSION: ${{ github.event.release.name }} + + steps: + - uses: hmarr/debug-action@v2 + + - name: Check out Gutenberg branches from WP.org plugin repo + run: svn checkout "$PLUGIN_REPO_URL/branches" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + + - name: Download and unzip Gutenberg plugin asset into trunk folder + env: + PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} + run: | + # do the magic here + curl -L -o gutenberg.zip $PLUGIN_URL + unzip gutenberg.zip -d branches/$VERSION + rm gutenberg.zip + + - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository + env: + STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' + run: | + sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./branches/$VERSION/readme.txt + + - name: Download Changelog Artifact + uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 + with: + name: changelog trunk + path: branches/$VERSION + + - name: Commit the content changes + working-directory: ./branches + run: | + svn st | grep '^?' | awk '{print $2}' | xargs -r svn add + svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm + svn commit -m "Committing version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + + - name: Create the SVN tag + working-directory: ./branches + run: | + svn copy "$PLUGIN_REPO_URL/branches/$VERSION" "$PLUGIN_REPO_URL/tags/$VERSION" -m "Tagging version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" From d685abb6644200214f7d646ddd995ef89553b572 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Tue, 14 Mar 2023 17:43:31 -0600 Subject: [PATCH 02/36] Revert debug changes Revert changes I made in order to test end-to-end from a test fork. --- .github/workflows/build-plugin-zip.yml | 43 ++++++++++++++++++- .../upload-release-to-plugin-repo.yml | 14 ++---- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index bac19ebcd2e469..e86123051b118e 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -71,7 +71,7 @@ jobs: - name: Checkout code uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GUTENBERG_TOKEN }} - name: Compute old and new version id: get_version @@ -298,3 +298,44 @@ jobs: asset_path: ./gutenberg.zip asset_name: gutenberg.zip asset_content_type: application/zip + + npm-publish: + name: Publish WordPress packages to npm + runs-on: ubuntu-latest + environment: WordPress packages + needs: [bump-version, build] + if: ${{ endsWith( needs.bump-version.outputs.new_version, '-rc.1' ) }} + steps: + - name: Checkout (for CLI) + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + path: main + ref: trunk + + - name: Checkout (for publishing) + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + path: publish + # Later, we switch this branch in the script that publishes packages. + ref: trunk + token: ${{ secrets.GUTENBERG_TOKEN }} + + - name: Configure git user name and email (for publishing) + run: | + cd publish + git config user.name "Gutenberg Repository Automation" + git config user.email gutenberg@wordpress.org + + - name: Setup Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 + with: + node-version-file: 'main/.nvmrc' + registry-url: 'https://registry.npmjs.org' + + - name: Publish packages to npm ("latest" dist-tag) + run: | + cd main + npm ci + ./bin/plugin/cli.js npm-latest --semver minor --ci --repository-path ../publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 2d7bbbe91420bf..aab86ae9062d92 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -12,8 +12,7 @@ jobs: latest_stable_tag: ${{ steps.get_latest_stable_tag.outputs.latest_stable_tag }} steps: - - uses: hmarr/debug-action@v2 - - name: Get latest stable ta + - name: Get latest stable tag id: get_latest_stable_tag run: | curl \ @@ -30,7 +29,6 @@ jobs: release_branch: ${{ steps.get_release_branch.outputs.release_branch }} steps: - - uses: hmarr/debug-action@v2 - name: Compute release branch name id: get_release_branch env: @@ -57,12 +55,11 @@ jobs: label: release steps: - - uses: hmarr/debug-action@v2 - name: Checkout code uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: ref: ${{ matrix.branch }} - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GUTENBERG_TOKEN }} - name: Update the Changelog to include the release notes run: | @@ -123,14 +120,13 @@ jobs: endsWith( github.ref, needs.compute-latest-stable.outputs.latest_stable_tag ) && !github.event.release.prerelease && github.event.release.assets[0] env: - PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' + PLUGIN_REPO_URL: 'https://plugins.svn.wordpress.org/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' SVN_USERNAME: ${{ secrets.svn_username }} SVN_PASSWORD: ${{ secrets.svn_password }} VERSION: ${{ github.event.release.name }} steps: - - uses: hmarr/debug-action@v2 - name: Check out Gutenberg trunk from WP.org plugin repo run: svn checkout "$PLUGIN_REPO_URL/trunk" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" @@ -188,15 +184,13 @@ jobs: !endsWith( github.ref, needs.compute-latest-stable.outputs.latest_stable_tag ) && !github.event.release.prerelease && github.event.release.assets[0] env: - PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' + PLUGIN_REPO_URL: 'https://plugins.svn.wordpress.org/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' SVN_USERNAME: ${{ secrets.svn_username }} SVN_PASSWORD: ${{ secrets.svn_password }} VERSION: ${{ github.event.release.name }} steps: - - uses: hmarr/debug-action@v2 - - name: Check out Gutenberg branches from WP.org plugin repo run: svn checkout "$PLUGIN_REPO_URL/branches" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" From 8b939f8e201527f39626a4a2db2d8aab7acb8ab9 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:45:48 -0600 Subject: [PATCH 03/36] Limit runs to `release/` branches Co-authored-by: Bernie Reiter --- .github/workflows/build-plugin-zip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index e86123051b118e..34d8669c64ca21 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -56,7 +56,7 @@ jobs: github.event.inputs.version == 'rc' || github.event.inputs.version == 'stable' ) || ( - github.ref != 'refs/heads/trunk' && + startsWith( github.ref, 'refs/heads/release/' ) && github.event.inputs.version == 'stable' ) ) From ff5c80fab007ca6a77ff5d82d3933cb60bd636ec Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:46:38 -0600 Subject: [PATCH 04/36] Fix changelog directory interpolation Co-authored-by: Bernie Reiter --- .github/workflows/upload-release-to-plugin-repo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index aab86ae9062d92..83dc70db955d5c 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -213,7 +213,7 @@ jobs: uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 with: name: changelog trunk - path: branches/$VERSION + path: branches/${{ github.event.release.name }} - name: Commit the content changes working-directory: ./branches From 489aa7010679b4832da8766f9349396e2907aac4 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Fri, 7 Apr 2023 11:09:05 -0600 Subject: [PATCH 05/36] Re-add debug changes for further testing --- .github/workflows/build-plugin-zip.yml | 4 ++-- .github/workflows/upload-release-to-plugin-repo.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 34d8669c64ca21..4f1b49f6fe90c1 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -71,7 +71,7 @@ jobs: - name: Checkout code uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: - token: ${{ secrets.GUTENBERG_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Compute old and new version id: get_version @@ -304,7 +304,7 @@ jobs: runs-on: ubuntu-latest environment: WordPress packages needs: [bump-version, build] - if: ${{ endsWith( needs.bump-version.outputs.new_version, '-rc.1' ) }} + if: ${{ false }} steps: - name: Checkout (for CLI) uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 83dc70db955d5c..2641d5e53d170b 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -59,7 +59,7 @@ jobs: uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: ref: ${{ matrix.branch }} - token: ${{ secrets.GUTENBERG_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Update the Changelog to include the release notes run: | @@ -120,7 +120,7 @@ jobs: endsWith( github.ref, needs.compute-latest-stable.outputs.latest_stable_tag ) && !github.event.release.prerelease && github.event.release.assets[0] env: - PLUGIN_REPO_URL: 'https://plugins.svn.wordpress.org/gutenberg' + PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' SVN_USERNAME: ${{ secrets.svn_username }} SVN_PASSWORD: ${{ secrets.svn_password }} @@ -184,7 +184,7 @@ jobs: !endsWith( github.ref, needs.compute-latest-stable.outputs.latest_stable_tag ) && !github.event.release.prerelease && github.event.release.assets[0] env: - PLUGIN_REPO_URL: 'https://plugins.svn.wordpress.org/gutenberg' + PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' SVN_USERNAME: ${{ secrets.svn_username }} SVN_PASSWORD: ${{ secrets.svn_password }} From 9dc4b3976e9873f13337069abf1f4543760df2ac Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Fri, 7 Apr 2023 13:12:03 -0600 Subject: [PATCH 06/36] Create only the tag when releasing an older point release, do not create a branch anymore --- .../upload-release-to-plugin-repo.yml | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 2641d5e53d170b..0cee2f9970f832 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -175,8 +175,8 @@ jobs: svn commit -m "Releasing version $VERSION" \ --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - upload-branch: - name: Publish as branch (and tag) + upload-tag: + name: Publish as tag runs-on: ubuntu-latest environment: wp.org plugin needs: [compute-latest-stable, update-changelog] @@ -191,8 +191,8 @@ jobs: VERSION: ${{ github.event.release.name }} steps: - - name: Check out Gutenberg branches from WP.org plugin repo - run: svn checkout "$PLUGIN_REPO_URL/branches" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + - name: Check out Gutenberg tags from WP.org plugin repo + run: svn checkout "$PLUGIN_REPO_URL/tags" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - name: Download and unzip Gutenberg plugin asset into trunk folder env: @@ -200,31 +200,25 @@ jobs: run: | # do the magic here curl -L -o gutenberg.zip $PLUGIN_URL - unzip gutenberg.zip -d branches/$VERSION + unzip gutenberg.zip -d tags/$VERSION rm gutenberg.zip - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository env: STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' run: | - sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./branches/$VERSION/readme.txt + sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./tags/$VERSION/readme.txt - name: Download Changelog Artifact uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 with: name: changelog trunk - path: branches/${{ github.event.release.name }} + path: tags/${{ github.event.release.name }} - name: Commit the content changes - working-directory: ./branches + working-directory: ./tags run: | svn st | grep '^?' | awk '{print $2}' | xargs -r svn add svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm svn commit -m "Committing version $VERSION" \ --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - - name: Create the SVN tag - working-directory: ./branches - run: | - svn copy "$PLUGIN_REPO_URL/branches/$VERSION" "$PLUGIN_REPO_URL/tags/$VERSION" -m "Tagging version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" From 7438230d91cb651158d0ca47210cbc5bdb64efe7 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Fri, 14 Apr 2023 19:23:21 -0600 Subject: [PATCH 07/36] Implement guard against accidental trunk release of older point releases This refactors the upload zip workflow and add some version arithmetic to make sure the right version is uploaded depending: - what is the current version set as latest -- this signals that a trunk release could be imminent, but is not enough to define it - what is the current version in the WP core repo (real latest released version) -- this is compared with the published version and if it's greater than this version + the version was set as latest in GH, then it is a trunk release - If the conditions above are false, then it's a tag release. See the source for more details. --- .../upload-release-to-plugin-repo.yml | 64 +++++++++++++------ 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 0cee2f9970f832..90969c4038e888 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -5,22 +5,50 @@ on: types: [published] jobs: - compute-latest-stable: - name: Get latest stable version + compute_should_update_trunk: runs-on: ubuntu-latest - outputs: - latest_stable_tag: ${{ steps.get_latest_stable_tag.outputs.latest_stable_tag }} - steps: - - name: Get latest stable tag - id: get_latest_stable_tag - run: | - curl \ - -H "Accept: application/vnd.github.v3+json" \ - -o latest.json \ - "https://api.github.com/repos/${{ github.repository }}/releases/latest" - LATEST_STABLE_TAG=$(jq --raw-output '.tag_name' latest.json) - echo "latest_stable_tag=${LATEST_STABLE_TAG}" >> $GITHUB_OUTPUT + - name: Compare version numbers + id: compute-should-update-trunk + uses: actions/github-script@v6 + with: + script: | + const fetch = require('node-fetch'); + const repo = process.env.GITHUB_REPOSITORY; + + async function fetchJson(url) { + const response = await fetch(url, { headers: { Accept: 'application/vnd.github.v3+json' } }); + return response.json(); + } + + /** + * Compares two version strings. + * + * @param {string} v1 - The first version string to compare, which may have an optional leading "v". + * @param {string} v2 - The second version string to compare, which may have an optional leading "v". + * @returns {number} - Returns 1 if v1 is greater than v2, -1 if v1 is less than v2, and 0 if v1 and v2 are equal. + */ + function compareVersions(v1, v2) { + const p1 = v1.replace(/^v/, '').split('.').map(Number), p2 = v2.replace(/^v/, '').split('.').map(Number); + return p1.reduce((acc, part, i) => acc === 0 ? (part > p2[i] ? 1 : (part < p2[i] ? -1 : 0)) : acc, 0); + } + + (async () => { + const [githubData, wpData] = await Promise.all([ + fetchJson(`https://api.github.com/repos/${repo}/releases/latest`), + fetchJson('https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request[slug]=gutenberg'), + ]); + + const latestVersionInGithub = githubData.tag_name + const latestVersionInCoreRepo = wpData.version; + const isLatestVersionInGithubMoreRecent = compareVersions(latestVersionInGithub, latestVersionInCoreRepo) === 1; + + // Only update trunk *if* the ref from the published plugin matches the latest + // version in GH (releases) *and* if this version is actually GREATER than the + // version published in the WP plugins repo. If not, then it will update the tag. + const shouldUpdateTrunk = githubRef === `refs/tags/${latestVersionInGithub}` && isLatestVersionInGithubMoreRecent; + core.setOutput('should_update_trunk', shouldUpdateTrunk); + })(); get-release-branch: name: Get release branch name @@ -115,9 +143,9 @@ jobs: name: Publish as trunk (and tag) runs-on: ubuntu-latest environment: wp.org plugin - needs: [compute-latest-stable, update-changelog] + needs: [compute_should_update_trunk, update-changelog] if: | - endsWith( github.ref, needs.compute-latest-stable.outputs.latest_stable_tag ) && + needs.compute_should_update_trunk.outputs.should_update_trunk == 'true' && !github.event.release.prerelease && github.event.release.assets[0] env: PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' @@ -179,9 +207,9 @@ jobs: name: Publish as tag runs-on: ubuntu-latest environment: wp.org plugin - needs: [compute-latest-stable, update-changelog] + needs: [compute_should_update_trunk, update-changelog] if: | - !endsWith( github.ref, needs.compute-latest-stable.outputs.latest_stable_tag ) && + needs.compute_should_update_trunk.outputs.should_update_trunk == 'false' && !github.event.release.prerelease && github.event.release.assets[0] env: PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' From 237fd16bc8ea5c9f8487fe010b154e63571109cf Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Fri, 14 Apr 2023 19:49:41 -0600 Subject: [PATCH 08/36] Attempt to fix "fetch" already defined error when running the script in the GH actions env --- .github/workflows/upload-release-to-plugin-repo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 90969c4038e888..0ecabcc192a4e6 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -13,11 +13,11 @@ jobs: uses: actions/github-script@v6 with: script: | - const fetch = require('node-fetch'); + const fetchData = require('node-fetch'); const repo = process.env.GITHUB_REPOSITORY; async function fetchJson(url) { - const response = await fetch(url, { headers: { Accept: 'application/vnd.github.v3+json' } }); + const response = await fetchData(url, { headers: { Accept: 'application/vnd.github.v3+json' } }); return response.json(); } From 89342532bec9210cc5e382abb4f6b89fcbe9d164 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Fri, 14 Apr 2023 20:14:02 -0600 Subject: [PATCH 09/36] Simplify by not using node-fetch, or it will require installing the npm --- .../workflows/upload-release-to-plugin-repo.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 0ecabcc192a4e6..6f19a4597fbe1a 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -13,12 +13,18 @@ jobs: uses: actions/github-script@v6 with: script: | - const fetchData = require('node-fetch'); + const https = require('https'); const repo = process.env.GITHUB_REPOSITORY; + const githubRef = context.ref; - async function fetchJson(url) { - const response = await fetchData(url, { headers: { Accept: 'application/vnd.github.v3+json' } }); - return response.json(); + function fetchJson(url) { + return new Promise((resolve, reject) => { + https.get(url, { headers: { Accept: 'application/json' } }, res => { + let data = ''; + res.on('data', chunk => data += chunk); + res.on('end', () => resolve(JSON.parse(data))); + }).on('error', reject); + }); } /** From 0b06966f04c5ae3ae7e70337c7db120414298f9c Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Fri, 14 Apr 2023 20:28:03 -0600 Subject: [PATCH 10/36] GH requires an user-agent --- .github/workflows/upload-release-to-plugin-repo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 6f19a4597fbe1a..4490594f97a62c 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -19,7 +19,7 @@ jobs: function fetchJson(url) { return new Promise((resolve, reject) => { - https.get(url, { headers: { Accept: 'application/json' } }, res => { + https.get(url, { headers: { Accept: 'application/json', 'User-Agent': 'Github Action Script' } }, res => { let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => resolve(JSON.parse(data))); From 2cb126078d421b9e64d3c066b7328195ed221937 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Tue, 18 Apr 2023 17:52:34 -0600 Subject: [PATCH 11/36] Improve var name and comments --- .github/workflows/upload-release-to-plugin-repo.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 4490594f97a62c..871627a821ea7e 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -47,12 +47,13 @@ jobs: const latestVersionInGithub = githubData.tag_name const latestVersionInCoreRepo = wpData.version; - const isLatestVersionInGithubMoreRecent = compareVersions(latestVersionInGithub, latestVersionInCoreRepo) === 1; + const isLatestVersionInGithubMoreRecentThanInCoreRepo = compareVersions(latestVersionInGithub, latestVersionInCoreRepo) === 1; // Only update trunk *if* the ref from the published plugin matches the latest - // version in GH (releases) *and* if this version is actually GREATER than the - // version published in the WP plugins repo. If not, then it will update the tag. - const shouldUpdateTrunk = githubRef === `refs/tags/${latestVersionInGithub}` && isLatestVersionInGithubMoreRecent; + // version in GH (releases) *and*, most importantly, if this version is actually + // GREATER than the version published in the WP plugins repo. If not, then it + // will upload it as a new tag. + const shouldUpdateTrunk = githubRef === `refs/tags/${latestVersionInGithub}` && isLatestVersionInGithubMoreRecentThanInCoreRepo; core.setOutput('should_update_trunk', shouldUpdateTrunk); })(); From 1b0713bf3020de14b69e6826973d6bc618c1185b Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Tue, 18 Apr 2023 18:35:36 -0600 Subject: [PATCH 12/36] Define func to set the output of the "compute-should-update-trunk" job and improve its name --- .../workflows/upload-release-to-plugin-repo.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 871627a821ea7e..0e23e3686af334 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -8,15 +8,26 @@ jobs: compute_should_update_trunk: runs-on: ubuntu-latest steps: - - name: Compare version numbers + - name: Decide if trunk or tag id: compute-should-update-trunk uses: actions/github-script@v6 with: script: | + const os = require("os"); + const fs = require("fs"); const https = require('https'); const repo = process.env.GITHUB_REPOSITORY; const githubRef = context.ref; + // Define a function to output the result of this action + // We don't use the one from "actions/core" because we + // don't want to install the npm package which would add + // to the workflow runtime. + function setOutput(key, val) { + const out = process.env["GITHUB_OUTPUT"]; + fs.appendFileSync(out, `${key}=${val}${os.EOL}`); + } + function fetchJson(url) { return new Promise((resolve, reject) => { https.get(url, { headers: { Accept: 'application/json', 'User-Agent': 'Github Action Script' } }, res => { @@ -54,7 +65,7 @@ jobs: // GREATER than the version published in the WP plugins repo. If not, then it // will upload it as a new tag. const shouldUpdateTrunk = githubRef === `refs/tags/${latestVersionInGithub}` && isLatestVersionInGithubMoreRecentThanInCoreRepo; - core.setOutput('should_update_trunk', shouldUpdateTrunk); + setOutput('should_update_trunk', shouldUpdateTrunk) })(); get-release-branch: From 7ac820ea683bbb6b75248e4f578304532394b58f Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Tue, 18 Apr 2023 19:05:41 -0600 Subject: [PATCH 13/36] The core object should already be available as part of the github-scripts package --- .../workflows/upload-release-to-plugin-repo.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 0e23e3686af334..5e72f75a104677 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -7,27 +7,18 @@ on: jobs: compute_should_update_trunk: runs-on: ubuntu-latest + outputs: + should_update_trunk: ${{ steps.compute-should-update-trunk.outputs.should_update_trunk }} steps: - name: Decide if trunk or tag id: compute-should-update-trunk uses: actions/github-script@v6 with: script: | - const os = require("os"); - const fs = require("fs"); const https = require('https'); const repo = process.env.GITHUB_REPOSITORY; const githubRef = context.ref; - // Define a function to output the result of this action - // We don't use the one from "actions/core" because we - // don't want to install the npm package which would add - // to the workflow runtime. - function setOutput(key, val) { - const out = process.env["GITHUB_OUTPUT"]; - fs.appendFileSync(out, `${key}=${val}${os.EOL}`); - } - function fetchJson(url) { return new Promise((resolve, reject) => { https.get(url, { headers: { Accept: 'application/json', 'User-Agent': 'Github Action Script' } }, res => { @@ -65,7 +56,7 @@ jobs: // GREATER than the version published in the WP plugins repo. If not, then it // will upload it as a new tag. const shouldUpdateTrunk = githubRef === `refs/tags/${latestVersionInGithub}` && isLatestVersionInGithubMoreRecentThanInCoreRepo; - setOutput('should_update_trunk', shouldUpdateTrunk) + core.setOutput('should_update_trunk', shouldUpdateTrunk) })(); get-release-branch: From b35880a57b16435f13044cd3301a8e79b5f1a2ae Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Wed, 19 Apr 2023 14:22:37 -0600 Subject: [PATCH 14/36] Rely only in the github ref from the published release and not the latest tag, restructure the workflow to make it easier to debug and simplify it by using shell commands/script instead of JS --- .../upload-release-to-plugin-repo.yml | 446 +++++++++--------- 1 file changed, 222 insertions(+), 224 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 5e72f75a104677..69b88b22d6176b 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -5,257 +5,255 @@ on: types: [published] jobs: - compute_should_update_trunk: + compute_latest_version_on_core: runs-on: ubuntu-latest - outputs: - should_update_trunk: ${{ steps.compute-should-update-trunk.outputs.should_update_trunk }} + steps: - - name: Decide if trunk or tag - id: compute-should-update-trunk - uses: actions/github-script@v6 - with: - script: | - const https = require('https'); - const repo = process.env.GITHUB_REPOSITORY; - const githubRef = context.ref; + - name: Fetch latest version in Core Repo + id: core_version + run: | + CORE_API_URL="https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request[slug]=gutenberg" + latest_version_in_core_repo=$(curl -s "$CORE_API_URL" | jq -r '.version') + echo "Latest Core Repo version: $latest_version_in_core_repo" + echo "version=$latest_version_in_core_repo" >> $GITHUB_OUTPUT - function fetchJson(url) { - return new Promise((resolve, reject) => { - https.get(url, { headers: { Accept: 'application/json', 'User-Agent': 'Github Action Script' } }, res => { - let data = ''; - res.on('data', chunk => data += chunk); - res.on('end', () => resolve(JSON.parse(data))); - }).on('error', reject); - }); - } + compute_should_update_trunk: + runs-on: ubuntu-latest + needs: [compute_latest_version_on_core] - /** - * Compares two version strings. - * - * @param {string} v1 - The first version string to compare, which may have an optional leading "v". - * @param {string} v2 - The second version string to compare, which may have an optional leading "v". - * @returns {number} - Returns 1 if v1 is greater than v2, -1 if v1 is less than v2, and 0 if v1 and v2 are equal. - */ - function compareVersions(v1, v2) { - const p1 = v1.replace(/^v/, '').split('.').map(Number), p2 = v2.replace(/^v/, '').split('.').map(Number); - return p1.reduce((acc, part, i) => acc === 0 ? (part > p2[i] ? 1 : (part < p2[i] ? -1 : 0)) : acc, 0); - } + steps: + - name: Decide if trunk or tag + id: comparison + env: + GITHUB_REF: ${{ github.ref }} + run: | + latestPublishedVersion=$(echo "$GITHUB_REF" | sed -E 's/refs\/tags\/(v?)([0-9.]+)/\2/') + latestVersionInCoreRepo="${{ needs.compute_latest_version_on_core.outputs.version }}" - (async () => { - const [githubData, wpData] = await Promise.all([ - fetchJson(`https://api.github.com/repos/${repo}/releases/latest`), - fetchJson('https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request[slug]=gutenberg'), - ]); + # Determines if the first version string is greater than the second version string. + # + # Params: + # $1 - The first version string to compare, which may have an optional leading "v". + # $2 - The second version string to compare, which may have an optional leading "v". + # + # Return values: + # 0 - The first version string is greater than the second version string. + # 1 - The first version string is less than or equal to the second version string. + is_first_version_greater_than_second() { + v1=${1#v} + v2=${2#v} + dpkg --compare-versions "$v1" gt "$v2" + return $? + } - const latestVersionInGithub = githubData.tag_name - const latestVersionInCoreRepo = wpData.version; - const isLatestVersionInGithubMoreRecentThanInCoreRepo = compareVersions(latestVersionInGithub, latestVersionInCoreRepo) === 1; + # Only update trunk *if* the published release's version in Github is GREATER + # than the version currently published in the WP plugins repo. If not, then it + # will upload it as a new tag. + shouldUpdateTrunk=false + if is_first_version_greater_than_second "$latestPublishedVersion" "$latestVersionInCoreRepo"; then + shouldUpdateTrunk=true + fi - // Only update trunk *if* the ref from the published plugin matches the latest - // version in GH (releases) *and*, most importantly, if this version is actually - // GREATER than the version published in the WP plugins repo. If not, then it - // will upload it as a new tag. - const shouldUpdateTrunk = githubRef === `refs/tags/${latestVersionInGithub}` && isLatestVersionInGithubMoreRecentThanInCoreRepo; - core.setOutput('should_update_trunk', shouldUpdateTrunk) - })(); + echo "Should update trunk: $shouldUpdateTrunk" + echo "should_update_trunk=$shouldUpdateTrunk" >> $GITHUB_OUTPUT - get-release-branch: - name: Get release branch name - runs-on: ubuntu-latest - outputs: - release_branch: ${{ steps.get_release_branch.outputs.release_branch }} + get-release-branch: + name: Get release branch name + runs-on: ubuntu-latest + outputs: + release_branch: ${{ steps.get_release_branch.outputs.release_branch }} - steps: - - name: Compute release branch name - id: get_release_branch - env: - TAG: ${{ github.event.release.tag_name }} - run: | - IFS='.' read -r -a VERSION_ARRAY <<< "${TAG#v}" - RELEASE_BRANCH="release/${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}" - echo "release_branch=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT + steps: + - name: Compute release branch name + id: get_release_branch + env: + TAG: ${{ github.event.release.tag_name }} + run: | + IFS='.' read -r -a VERSION_ARRAY <<< "${TAG#v}" + RELEASE_BRANCH="release/${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}" + echo "release_branch=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT - update-changelog: - name: Update Changelog on ${{ matrix.branch }} branch - runs-on: ubuntu-latest - if: | - github.event.release.assets[0] - needs: get-release-branch - env: - TAG: ${{ github.event.release.tag_name }} - strategy: - matrix: - include: - - branch: trunk - label: trunk - - branch: ${{ needs.get-release-branch.outputs.release_branch }} - label: release + update-changelog: + name: Update Changelog on ${{ matrix.branch }} branch + runs-on: ubuntu-latest + if: | + github.event.release.assets[0] + needs: get-release-branch + env: + TAG: ${{ github.event.release.tag_name }} + strategy: + matrix: + include: + - branch: trunk + label: trunk + - branch: ${{ needs.get-release-branch.outputs.release_branch }} + label: release - steps: - - name: Checkout code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - with: - ref: ${{ matrix.branch }} - token: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout code + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + ref: ${{ matrix.branch }} + token: ${{ secrets.GITHUB_TOKEN }} - - name: Update the Changelog to include the release notes - run: | - # First, determine where to insert the new Changelog entry. - SERIES="${RELEASE_BRANCH#release/}" - SERIES_REGEX="=\s${SERIES}\.[0-9]+\s=" - CUT_MARKS=$( grep -nP -m 1 "${SERIES_REGEX}" changelog.txt | cut -d: -f1 ) - if [[ -z "${CUT_MARKS}" ]]; then - CHANGELOG_REGEX="=\s[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?\s=" - RC_REGEX="=\s${TAG#v}(-rc\.[0-9]+)?\s=" - CUT_MARKS=$( awk "/${RC_REGEX}/ {print NR; next}; /${CHANGELOG_REGEX}/ {print NR; exit}" changelog.txt ) - fi - BEFORE=$( echo "$CUT_MARKS" | head -n 1 ) - AFTER=$( echo "$CUT_MARKS" | tail -n 1 ) - # Okay, we have all we need to build the new Changelog. - head -n $(( "${BEFORE}" - 1 )) changelog.txt > new_changelog.txt - printf '= %s =\n\n' "${TAG#v}" >> new_changelog.txt - # Need to use a heredoc in order to preserve special characters. - cat <<- "EOF" > release_notes.txt - ${{ github.event.release.body }} - EOF - # Normalize empty lines: Trim them from beginning and end of file... - awk 'NF {p=1} p' <<< "$(< release_notes.txt)" >> new_changelog.txt - # ...then add two empty lines at the end. - printf '\n\n' >> new_changelog.txt - tail -n +"${AFTER}" changelog.txt >> new_changelog.txt - mv new_changelog.txt changelog.txt + - name: Update the Changelog to include the release notes + run: | + # First, determine where to insert the new Changelog entry. + SERIES="${RELEASE_BRANCH#release/}" + SERIES_REGEX="=\s${SERIES}\.[0-9]+\s=" + CUT_MARKS=$( grep -nP -m 1 "${SERIES_REGEX}" changelog.txt | cut -d: -f1 ) + if [[ -z "${CUT_MARKS}" ]]; then + CHANGELOG_REGEX="=\s[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?\s=" + RC_REGEX="=\s${TAG#v}(-rc\.[0-9]+)?\s=" + CUT_MARKS=$( awk "/${RC_REGEX}/ {print NR; next}; /${CHANGELOG_REGEX}/ {print NR; exit}" changelog.txt ) + fi + BEFORE=$( echo "$CUT_MARKS" | head -n 1 ) + AFTER=$( echo "$CUT_MARKS" | tail -n 1 ) + # Okay, we have all we need to build the new Changelog. + head -n $(( "${BEFORE}" - 1 )) changelog.txt > new_changelog.txt + printf '= %s =\n\n' "${TAG#v}" >> new_changelog.txt + # Need to use a heredoc in order to preserve special characters. + cat <<- "EOF" > release_notes.txt + ${{ github.event.release.body }} + EOF + # Normalize empty lines: Trim them from beginning and end of file... + awk 'NF {p=1} p' <<< "$(< release_notes.txt)" >> new_changelog.txt + # ...then add two empty lines at the end. + printf '\n\n' >> new_changelog.txt + tail -n +"${AFTER}" changelog.txt >> new_changelog.txt + mv new_changelog.txt changelog.txt - - name: Configure git user name and email - run: | - git config user.name "Gutenberg Repository Automation" - git config user.email gutenberg@wordpress.org + - name: Configure git user name and email + run: | + git config user.name "Gutenberg Repository Automation" + git config user.email gutenberg@wordpress.org - - name: Commit the Changelog update - run: | - git add changelog.txt - # Remove files that are not meant to be committed - # ie. release_notes.txt created on the previous step. - git clean -fd - # Only attempt to commit changelog if it has been modified. - if ! git diff-index --quiet HEAD --; then - git commit -m "Update Changelog for ${TAG#v}" - git push --set-upstream origin "${{ matrix.branch }}" - fi + - name: Commit the Changelog update + run: | + git add changelog.txt + # Remove files that are not meant to be committed + # ie. release_notes.txt created on the previous step. + git clean -fd + # Only attempt to commit changelog if it has been modified. + if ! git diff-index --quiet HEAD --; then + git commit -m "Update Changelog for ${TAG#v}" + git push --set-upstream origin "${{ matrix.branch }}" + fi - - name: Upload Changelog artifact - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 - with: - name: changelog ${{ matrix.label }} - path: ./changelog.txt + - name: Upload Changelog artifact + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 + with: + name: changelog ${{ matrix.label }} + path: ./changelog.txt - upload: - name: Publish as trunk (and tag) - runs-on: ubuntu-latest - environment: wp.org plugin - needs: [compute_should_update_trunk, update-changelog] - if: | - needs.compute_should_update_trunk.outputs.should_update_trunk == 'true' && - !github.event.release.prerelease && github.event.release.assets[0] - env: - PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' - STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' - SVN_USERNAME: ${{ secrets.svn_username }} - SVN_PASSWORD: ${{ secrets.svn_password }} - VERSION: ${{ github.event.release.name }} + upload: + name: Publish as trunk (and tag) + runs-on: ubuntu-latest + environment: wp.org plugin + needs: [compute_should_update_trunk, update-changelog] + if: | + needs.compute_should_update_trunk.outputs.should_update_trunk == 'true' && + !github.event.release.prerelease && github.event.release.assets[0] + env: + PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' + STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' + SVN_USERNAME: ${{ secrets.svn_username }} + SVN_PASSWORD: ${{ secrets.svn_password }} + VERSION: ${{ github.event.release.name }} - steps: - - name: Check out Gutenberg trunk from WP.org plugin repo - run: svn checkout "$PLUGIN_REPO_URL/trunk" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + steps: + - name: Check out Gutenberg trunk from WP.org plugin repo + run: svn checkout "$PLUGIN_REPO_URL/trunk" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - name: Delete everything - working-directory: ./trunk - run: find . -maxdepth 1 -not -name ".svn" -not -name "." -not -name ".." -exec rm -rf {} + + - name: Delete everything + working-directory: ./trunk + run: find . -maxdepth 1 -not -name ".svn" -not -name "." -not -name ".." -exec rm -rf {} + - - name: Download and unzip Gutenberg plugin asset into trunk folder - env: - PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} - run: | - curl -L -o gutenberg.zip $PLUGIN_URL - unzip gutenberg.zip -d trunk - rm gutenberg.zip + - name: Download and unzip Gutenberg plugin asset into trunk folder + env: + PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} + run: | + curl -L -o gutenberg.zip $PLUGIN_URL + unzip gutenberg.zip -d trunk + rm gutenberg.zip - - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository - env: - STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' - run: | - sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./trunk/readme.txt + - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository + env: + STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' + run: | + sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./trunk/readme.txt - - name: Download Changelog Artifact - uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 - with: - name: changelog trunk - path: trunk + - name: Download Changelog Artifact + uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 + with: + name: changelog trunk + path: trunk - - name: Commit the content changes - working-directory: ./trunk - run: | - svn st | grep '^?' | awk '{print $2}' | xargs -r svn add - svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm - svn commit -m "Committing version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + - name: Commit the content changes + working-directory: ./trunk + run: | + svn st | grep '^?' | awk '{print $2}' | xargs -r svn add + svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm + svn commit -m "Committing version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - name: Create the SVN tag - working-directory: ./trunk - run: | - svn copy "$PLUGIN_REPO_URL/trunk" "$PLUGIN_REPO_URL/tags/$VERSION" -m "Tagging version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + - name: Create the SVN tag + working-directory: ./trunk + run: | + svn copy "$PLUGIN_REPO_URL/trunk" "$PLUGIN_REPO_URL/tags/$VERSION" -m "Tagging version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - name: Update the plugin's stable version - working-directory: ./trunk - run: | - sed -i "s/Stable tag: ${STABLE_VERSION_REGEX}/Stable tag: ${VERSION}/g" ./readme.txt - svn commit -m "Releasing version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + - name: Update the plugin's stable version + working-directory: ./trunk + run: | + sed -i "s/Stable tag: ${STABLE_VERSION_REGEX}/Stable tag: ${VERSION}/g" ./readme.txt + svn commit -m "Releasing version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - upload-tag: - name: Publish as tag - runs-on: ubuntu-latest - environment: wp.org plugin - needs: [compute_should_update_trunk, update-changelog] - if: | - needs.compute_should_update_trunk.outputs.should_update_trunk == 'false' && - !github.event.release.prerelease && github.event.release.assets[0] - env: - PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' - STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' - SVN_USERNAME: ${{ secrets.svn_username }} - SVN_PASSWORD: ${{ secrets.svn_password }} - VERSION: ${{ github.event.release.name }} + upload-tag: + name: Publish as tag + runs-on: ubuntu-latest + environment: wp.org plugin + needs: [compute_should_update_trunk, update-changelog] + if: | + needs.compute_should_update_trunk.outputs.should_update_trunk == 'false' && + !github.event.release.prerelease && github.event.release.assets[0] + env: + PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' + STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' + SVN_USERNAME: ${{ secrets.svn_username }} + SVN_PASSWORD: ${{ secrets.svn_password }} + VERSION: ${{ github.event.release.name }} - steps: - - name: Check out Gutenberg tags from WP.org plugin repo - run: svn checkout "$PLUGIN_REPO_URL/tags" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + steps: + - name: Check out Gutenberg tags from WP.org plugin repo + run: svn checkout "$PLUGIN_REPO_URL/tags" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - name: Download and unzip Gutenberg plugin asset into trunk folder - env: - PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} - run: | - # do the magic here - curl -L -o gutenberg.zip $PLUGIN_URL - unzip gutenberg.zip -d tags/$VERSION - rm gutenberg.zip + - name: Download and unzip Gutenberg plugin asset into trunk folder + env: + PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} + run: | + # do the magic here + curl -L -o gutenberg.zip $PLUGIN_URL + unzip gutenberg.zip -d tags/$VERSION + rm gutenberg.zip - - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository - env: - STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' - run: | - sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./tags/$VERSION/readme.txt + - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository + env: + STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' + run: | + sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./tags/$VERSION/readme.txt - - name: Download Changelog Artifact - uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 - with: - name: changelog trunk - path: tags/${{ github.event.release.name }} + - name: Download Changelog Artifact + uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 + with: + name: changelog trunk + path: tags/${{ github.event.release.name }} - - name: Commit the content changes - working-directory: ./tags - run: | - svn st | grep '^?' | awk '{print $2}' | xargs -r svn add - svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm - svn commit -m "Committing version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + - name: Commit the content changes + working-directory: ./tags + run: | + svn st | grep '^?' | awk '{print $2}' | xargs -r svn add + svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm + svn commit -m "Committing version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" From a81bc6886686ef778319f77ba9c925903e790b4a Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Wed, 19 Apr 2023 14:29:43 -0600 Subject: [PATCH 15/36] Simplify further by moving the fetch core repo job to a step inside compute_should_update_trunk --- .../workflows/upload-release-to-plugin-repo.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 69b88b22d6176b..8aa02a6052ebb8 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -5,30 +5,25 @@ on: types: [published] jobs: - compute_latest_version_on_core: + compute_should_update_trunk: runs-on: ubuntu-latest steps: - - name: Fetch latest version in Core Repo - id: core_version + - name: Fetch latest version in the WP core repo + id: latest_version_in_core_repo run: | CORE_API_URL="https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request[slug]=gutenberg" latest_version_in_core_repo=$(curl -s "$CORE_API_URL" | jq -r '.version') echo "Latest Core Repo version: $latest_version_in_core_repo" echo "version=$latest_version_in_core_repo" >> $GITHUB_OUTPUT - compute_should_update_trunk: - runs-on: ubuntu-latest - needs: [compute_latest_version_on_core] - - steps: - - name: Decide if trunk or tag + - name: Decide if it is a trunk or tag update id: comparison env: GITHUB_REF: ${{ github.ref }} run: | latestPublishedVersion=$(echo "$GITHUB_REF" | sed -E 's/refs\/tags\/(v?)([0-9.]+)/\2/') - latestVersionInCoreRepo="${{ needs.compute_latest_version_on_core.outputs.version }}" + latestVersionInCoreRepo="${{ stepss.latest_version_in_core_repo_.outputs.version }}" # Determines if the first version string is greater than the second version string. # From 60c465a61aa2be3bc3fdec130eb90db095531df0 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Wed, 19 Apr 2023 14:32:20 -0600 Subject: [PATCH 16/36] Fix/improve step/job ids --- .github/workflows/upload-release-to-plugin-repo.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 8aa02a6052ebb8..ff13a9364ec14b 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Fetch latest version in the WP core repo - id: latest_version_in_core_repo + id: compute_latest_version_in_core_repo run: | CORE_API_URL="https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request[slug]=gutenberg" latest_version_in_core_repo=$(curl -s "$CORE_API_URL" | jq -r '.version') @@ -18,12 +18,12 @@ jobs: echo "version=$latest_version_in_core_repo" >> $GITHUB_OUTPUT - name: Decide if it is a trunk or tag update - id: comparison + id: compute_should_update_trunk env: GITHUB_REF: ${{ github.ref }} run: | latestPublishedVersion=$(echo "$GITHUB_REF" | sed -E 's/refs\/tags\/(v?)([0-9.]+)/\2/') - latestVersionInCoreRepo="${{ stepss.latest_version_in_core_repo_.outputs.version }}" + latestVersionInCoreRepo="${{ stepss.compute_latest_version_in_core_repo.outputs.version }}" # Determines if the first version string is greater than the second version string. # From a370648b51839ff7faf5b783799bb32eef1c21bc Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Wed, 19 Apr 2023 16:06:27 -0600 Subject: [PATCH 17/36] Fix typo --- .github/workflows/upload-release-to-plugin-repo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index ff13a9364ec14b..a2051a2df6765b 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -23,7 +23,7 @@ jobs: GITHUB_REF: ${{ github.ref }} run: | latestPublishedVersion=$(echo "$GITHUB_REF" | sed -E 's/refs\/tags\/(v?)([0-9.]+)/\2/') - latestVersionInCoreRepo="${{ stepss.compute_latest_version_in_core_repo.outputs.version }}" + latestVersionInCoreRepo="${{ steps.compute_latest_version_in_core_repo.outputs.version }}" # Determines if the first version string is greater than the second version string. # From cd9bf15c7b59c50e5354ae40f8d32318379706da Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Wed, 19 Apr 2023 16:36:44 -0600 Subject: [PATCH 18/36] Formatting fixes Auto-format with the RedHat YAML extension in vscode. --- .../upload-release-to-plugin-repo.yml | 400 +++++++++--------- 1 file changed, 200 insertions(+), 200 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index a2051a2df6765b..f25a2b86246460 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -52,203 +52,203 @@ jobs: echo "Should update trunk: $shouldUpdateTrunk" echo "should_update_trunk=$shouldUpdateTrunk" >> $GITHUB_OUTPUT - get-release-branch: - name: Get release branch name - runs-on: ubuntu-latest - outputs: - release_branch: ${{ steps.get_release_branch.outputs.release_branch }} - - steps: - - name: Compute release branch name - id: get_release_branch - env: - TAG: ${{ github.event.release.tag_name }} - run: | - IFS='.' read -r -a VERSION_ARRAY <<< "${TAG#v}" - RELEASE_BRANCH="release/${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}" - echo "release_branch=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT - - update-changelog: - name: Update Changelog on ${{ matrix.branch }} branch - runs-on: ubuntu-latest - if: | - github.event.release.assets[0] - needs: get-release-branch - env: - TAG: ${{ github.event.release.tag_name }} - strategy: - matrix: - include: - - branch: trunk - label: trunk - - branch: ${{ needs.get-release-branch.outputs.release_branch }} - label: release - - steps: - - name: Checkout code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - with: - ref: ${{ matrix.branch }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Update the Changelog to include the release notes - run: | - # First, determine where to insert the new Changelog entry. - SERIES="${RELEASE_BRANCH#release/}" - SERIES_REGEX="=\s${SERIES}\.[0-9]+\s=" - CUT_MARKS=$( grep -nP -m 1 "${SERIES_REGEX}" changelog.txt | cut -d: -f1 ) - if [[ -z "${CUT_MARKS}" ]]; then - CHANGELOG_REGEX="=\s[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?\s=" - RC_REGEX="=\s${TAG#v}(-rc\.[0-9]+)?\s=" - CUT_MARKS=$( awk "/${RC_REGEX}/ {print NR; next}; /${CHANGELOG_REGEX}/ {print NR; exit}" changelog.txt ) - fi - BEFORE=$( echo "$CUT_MARKS" | head -n 1 ) - AFTER=$( echo "$CUT_MARKS" | tail -n 1 ) - # Okay, we have all we need to build the new Changelog. - head -n $(( "${BEFORE}" - 1 )) changelog.txt > new_changelog.txt - printf '= %s =\n\n' "${TAG#v}" >> new_changelog.txt - # Need to use a heredoc in order to preserve special characters. - cat <<- "EOF" > release_notes.txt - ${{ github.event.release.body }} - EOF - # Normalize empty lines: Trim them from beginning and end of file... - awk 'NF {p=1} p' <<< "$(< release_notes.txt)" >> new_changelog.txt - # ...then add two empty lines at the end. - printf '\n\n' >> new_changelog.txt - tail -n +"${AFTER}" changelog.txt >> new_changelog.txt - mv new_changelog.txt changelog.txt - - - name: Configure git user name and email - run: | - git config user.name "Gutenberg Repository Automation" - git config user.email gutenberg@wordpress.org - - - name: Commit the Changelog update - run: | - git add changelog.txt - # Remove files that are not meant to be committed - # ie. release_notes.txt created on the previous step. - git clean -fd - # Only attempt to commit changelog if it has been modified. - if ! git diff-index --quiet HEAD --; then - git commit -m "Update Changelog for ${TAG#v}" - git push --set-upstream origin "${{ matrix.branch }}" - fi - - - name: Upload Changelog artifact - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 - with: - name: changelog ${{ matrix.label }} - path: ./changelog.txt - - upload: - name: Publish as trunk (and tag) - runs-on: ubuntu-latest - environment: wp.org plugin - needs: [compute_should_update_trunk, update-changelog] - if: | - needs.compute_should_update_trunk.outputs.should_update_trunk == 'true' && - !github.event.release.prerelease && github.event.release.assets[0] - env: - PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' - STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' - SVN_USERNAME: ${{ secrets.svn_username }} - SVN_PASSWORD: ${{ secrets.svn_password }} - VERSION: ${{ github.event.release.name }} - - steps: - - name: Check out Gutenberg trunk from WP.org plugin repo - run: svn checkout "$PLUGIN_REPO_URL/trunk" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - - name: Delete everything - working-directory: ./trunk - run: find . -maxdepth 1 -not -name ".svn" -not -name "." -not -name ".." -exec rm -rf {} + - - - name: Download and unzip Gutenberg plugin asset into trunk folder - env: - PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} - run: | - curl -L -o gutenberg.zip $PLUGIN_URL - unzip gutenberg.zip -d trunk - rm gutenberg.zip - - - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository - env: - STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' - run: | - sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./trunk/readme.txt - - - name: Download Changelog Artifact - uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 - with: - name: changelog trunk - path: trunk - - - name: Commit the content changes - working-directory: ./trunk - run: | - svn st | grep '^?' | awk '{print $2}' | xargs -r svn add - svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm - svn commit -m "Committing version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - - name: Create the SVN tag - working-directory: ./trunk - run: | - svn copy "$PLUGIN_REPO_URL/trunk" "$PLUGIN_REPO_URL/tags/$VERSION" -m "Tagging version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - - name: Update the plugin's stable version - working-directory: ./trunk - run: | - sed -i "s/Stable tag: ${STABLE_VERSION_REGEX}/Stable tag: ${VERSION}/g" ./readme.txt - svn commit -m "Releasing version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - upload-tag: - name: Publish as tag - runs-on: ubuntu-latest - environment: wp.org plugin - needs: [compute_should_update_trunk, update-changelog] - if: | - needs.compute_should_update_trunk.outputs.should_update_trunk == 'false' && - !github.event.release.prerelease && github.event.release.assets[0] - env: - PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' - STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' - SVN_USERNAME: ${{ secrets.svn_username }} - SVN_PASSWORD: ${{ secrets.svn_password }} - VERSION: ${{ github.event.release.name }} - - steps: - - name: Check out Gutenberg tags from WP.org plugin repo - run: svn checkout "$PLUGIN_REPO_URL/tags" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - - name: Download and unzip Gutenberg plugin asset into trunk folder - env: - PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} - run: | - # do the magic here - curl -L -o gutenberg.zip $PLUGIN_URL - unzip gutenberg.zip -d tags/$VERSION - rm gutenberg.zip - - - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository - env: - STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' - run: | - sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./tags/$VERSION/readme.txt - - - name: Download Changelog Artifact - uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 - with: - name: changelog trunk - path: tags/${{ github.event.release.name }} - - - name: Commit the content changes - working-directory: ./tags - run: | - svn st | grep '^?' | awk '{print $2}' | xargs -r svn add - svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm - svn commit -m "Committing version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + get-release-branch: + name: Get release branch name + runs-on: ubuntu-latest + outputs: + release_branch: ${{ steps.get_release_branch.outputs.release_branch }} + + steps: + - name: Compute release branch name + id: get_release_branch + env: + TAG: ${{ github.event.release.tag_name }} + run: | + IFS='.' read -r -a VERSION_ARRAY <<< "${TAG#v}" + RELEASE_BRANCH="release/${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}" + echo "release_branch=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT + + update-changelog: + name: Update Changelog on ${{ matrix.branch }} branch + runs-on: ubuntu-latest + if: | + github.event.release.assets[0] + needs: get-release-branch + env: + TAG: ${{ github.event.release.tag_name }} + strategy: + matrix: + include: + - branch: trunk + label: trunk + - branch: ${{ needs.get-release-branch.outputs.release_branch }} + label: release + + steps: + - name: Checkout code + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + ref: ${{ matrix.branch }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Update the Changelog to include the release notes + run: | + # First, determine where to insert the new Changelog entry. + SERIES="${RELEASE_BRANCH#release/}" + SERIES_REGEX="=\s${SERIES}\.[0-9]+\s=" + CUT_MARKS=$( grep -nP -m 1 "${SERIES_REGEX}" changelog.txt | cut -d: -f1 ) + if [[ -z "${CUT_MARKS}" ]]; then + CHANGELOG_REGEX="=\s[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?\s=" + RC_REGEX="=\s${TAG#v}(-rc\.[0-9]+)?\s=" + CUT_MARKS=$( awk "/${RC_REGEX}/ {print NR; next}; /${CHANGELOG_REGEX}/ {print NR; exit}" changelog.txt ) + fi + BEFORE=$( echo "$CUT_MARKS" | head -n 1 ) + AFTER=$( echo "$CUT_MARKS" | tail -n 1 ) + # Okay, we have all we need to build the new Changelog. + head -n $(( "${BEFORE}" - 1 )) changelog.txt > new_changelog.txt + printf '= %s =\n\n' "${TAG#v}" >> new_changelog.txt + # Need to use a heredoc in order to preserve special characters. + cat <<- "EOF" > release_notes.txt + ${{ github.event.release.body }} + EOF + # Normalize empty lines: Trim them from beginning and end of file... + awk 'NF {p=1} p' <<< "$(< release_notes.txt)" >> new_changelog.txt + # ...then add two empty lines at the end. + printf '\n\n' >> new_changelog.txt + tail -n +"${AFTER}" changelog.txt >> new_changelog.txt + mv new_changelog.txt changelog.txt + + - name: Configure git user name and email + run: | + git config user.name "Gutenberg Repository Automation" + git config user.email gutenberg@wordpress.org + + - name: Commit the Changelog update + run: | + git add changelog.txt + # Remove files that are not meant to be committed + # ie. release_notes.txt created on the previous step. + git clean -fd + # Only attempt to commit changelog if it has been modified. + if ! git diff-index --quiet HEAD --; then + git commit -m "Update Changelog for ${TAG#v}" + git push --set-upstream origin "${{ matrix.branch }}" + fi + + - name: Upload Changelog artifact + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 + with: + name: changelog ${{ matrix.label }} + path: ./changelog.txt + + upload: + name: Publish as trunk (and tag) + runs-on: ubuntu-latest + environment: wp.org plugin + needs: [compute_should_update_trunk, update-changelog] + if: | + needs.compute_should_update_trunk.outputs.should_update_trunk == 'true' && + !github.event.release.prerelease && github.event.release.assets[0] + env: + PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' + STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' + SVN_USERNAME: ${{ secrets.svn_username }} + SVN_PASSWORD: ${{ secrets.svn_password }} + VERSION: ${{ github.event.release.name }} + + steps: + - name: Check out Gutenberg trunk from WP.org plugin repo + run: svn checkout "$PLUGIN_REPO_URL/trunk" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + + - name: Delete everything + working-directory: ./trunk + run: find . -maxdepth 1 -not -name ".svn" -not -name "." -not -name ".." -exec rm -rf {} + + + - name: Download and unzip Gutenberg plugin asset into trunk folder + env: + PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} + run: | + curl -L -o gutenberg.zip $PLUGIN_URL + unzip gutenberg.zip -d trunk + rm gutenberg.zip + + - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository + env: + STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' + run: | + sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./trunk/readme.txt + + - name: Download Changelog Artifact + uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 + with: + name: changelog trunk + path: trunk + + - name: Commit the content changes + working-directory: ./trunk + run: | + svn st | grep '^?' | awk '{print $2}' | xargs -r svn add + svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm + svn commit -m "Committing version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + + - name: Create the SVN tag + working-directory: ./trunk + run: | + svn copy "$PLUGIN_REPO_URL/trunk" "$PLUGIN_REPO_URL/tags/$VERSION" -m "Tagging version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + + - name: Update the plugin's stable version + working-directory: ./trunk + run: | + sed -i "s/Stable tag: ${STABLE_VERSION_REGEX}/Stable tag: ${VERSION}/g" ./readme.txt + svn commit -m "Releasing version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + + upload-tag: + name: Publish as tag + runs-on: ubuntu-latest + environment: wp.org plugin + needs: [compute_should_update_trunk, update-changelog] + if: | + needs.compute_should_update_trunk.outputs.should_update_trunk == 'false' && + !github.event.release.prerelease && github.event.release.assets[0] + env: + PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' + STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' + SVN_USERNAME: ${{ secrets.svn_username }} + SVN_PASSWORD: ${{ secrets.svn_password }} + VERSION: ${{ github.event.release.name }} + + steps: + - name: Check out Gutenberg tags from WP.org plugin repo + run: svn checkout "$PLUGIN_REPO_URL/tags" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + + - name: Download and unzip Gutenberg plugin asset into trunk folder + env: + PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} + run: | + # do the magic here + curl -L -o gutenberg.zip $PLUGIN_URL + unzip gutenberg.zip -d tags/$VERSION + rm gutenberg.zip + + - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository + env: + STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' + run: | + sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./tags/$VERSION/readme.txt + + - name: Download Changelog Artifact + uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 + with: + name: changelog trunk + path: tags/${{ github.event.release.name }} + + - name: Commit the content changes + working-directory: ./tags + run: | + svn st | grep '^?' | awk '{print $2}' | xargs -r svn add + svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm + svn commit -m "Committing version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" From e5e576486054e490bb6b75be63417346ca481ff3 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Wed, 19 Apr 2023 18:58:32 -0600 Subject: [PATCH 19/36] Add missing outputs and a couple of other fixes --- .github/workflows/upload-release-to-plugin-repo.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index f25a2b86246460..cfd55add69cbb2 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -5,8 +5,12 @@ on: types: [published] jobs: - compute_should_update_trunk: + compute-should-update-trunk: + name: Decide if trunk or tag runs-on: ubuntu-latest + outputs: + should_update_trunk: ${{ steps.compute_should_update_trunk.outputs.should_update_trunk }} + latest_version_in_core_repo: ${{ steps.compute_latest_version_in_core_repo.outputs.version }} steps: - name: Fetch latest version in the WP core repo @@ -145,7 +149,7 @@ jobs: name: Publish as trunk (and tag) runs-on: ubuntu-latest environment: wp.org plugin - needs: [compute_should_update_trunk, update-changelog] + needs: [compute-should-update-trunk, update-changelog] if: | needs.compute_should_update_trunk.outputs.should_update_trunk == 'true' && !github.event.release.prerelease && github.event.release.assets[0] @@ -209,7 +213,7 @@ jobs: name: Publish as tag runs-on: ubuntu-latest environment: wp.org plugin - needs: [compute_should_update_trunk, update-changelog] + needs: [compute-should-update-trunk, update-changelog] if: | needs.compute_should_update_trunk.outputs.should_update_trunk == 'false' && !github.event.release.prerelease && github.event.release.assets[0] From 4297be6f0f2128f446263a3e6ed7ac6501ce97b2 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Wed, 19 Apr 2023 19:22:12 -0600 Subject: [PATCH 20/36] A couple more fixes and a simplification of the compute_latest_version step --- .github/workflows/upload-release-to-plugin-repo.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index cfd55add69cbb2..5ce481e3e6accc 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -10,14 +10,12 @@ jobs: runs-on: ubuntu-latest outputs: should_update_trunk: ${{ steps.compute_should_update_trunk.outputs.should_update_trunk }} - latest_version_in_core_repo: ${{ steps.compute_latest_version_in_core_repo.outputs.version }} steps: - name: Fetch latest version in the WP core repo id: compute_latest_version_in_core_repo run: | - CORE_API_URL="https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request[slug]=gutenberg" - latest_version_in_core_repo=$(curl -s "$CORE_API_URL" | jq -r '.version') + latest_version_in_core_repo=$(curl -s 'https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request\[slug\]=gutenberg' | jq -r '.version') echo "Latest Core Repo version: $latest_version_in_core_repo" echo "version=$latest_version_in_core_repo" >> $GITHUB_OUTPUT @@ -151,7 +149,7 @@ jobs: environment: wp.org plugin needs: [compute-should-update-trunk, update-changelog] if: | - needs.compute_should_update_trunk.outputs.should_update_trunk == 'true' && + needs.compute-should-update-trunk.outputs.should_update_trunk == 'true' && !github.event.release.prerelease && github.event.release.assets[0] env: PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' @@ -215,7 +213,7 @@ jobs: environment: wp.org plugin needs: [compute-should-update-trunk, update-changelog] if: | - needs.compute_should_update_trunk.outputs.should_update_trunk == 'false' && + needs.compute-should-update-trunk.outputs.should_update_trunk == 'false' && !github.event.release.prerelease && github.event.release.assets[0] env: PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' From 014e2c6168c6945029ce7b1ac2ffbf3525004d4a Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Thu, 20 Apr 2023 18:19:57 -0600 Subject: [PATCH 21/36] Mock the build of the gutenberg.zip for debugging purposes, this commit should be reverted before merging! --- .github/workflows/build-plugin-zip.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 4f1b49f6fe90c1..a5802cf1dfc352 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -164,18 +164,25 @@ jobs: steps: - name: Checkout code + # The following is debug code, should be reverted before merging. See commit that added this for more info. + if: false uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: ref: ${{ needs.bump-version.outputs.release_branch || github.ref }} - name: Use desired version of Node.js + # The following is debug code, should be reverted before merging. See commit that added this for more info. + if: false uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: '.nvmrc' cache: npm - name: Build Gutenberg plugin ZIP file - run: ./bin/build-plugin-zip.sh + # The following is debug code, should be reverted before merging. See commit that added this for more info. + run: | + echo 'Stable tag: V.V.V' > readme.txt + zip -j gutenberg.zip readme.txt env: NO_CHECKS: 'true' @@ -186,7 +193,10 @@ jobs: path: ./gutenberg.zip - name: Build release notes draft - if: ${{ needs.bump-version.outputs.new_version }} + # Debug: if we want fast runs, then this should be disabled as this won't + # work if the real plugin isn't built (becuase npm install is needed to install + # some needed packages that the `other:changelog` task uses`). + if: false env: VERSION: ${{ needs.bump-version.outputs.new_version }} run: | @@ -202,7 +212,8 @@ jobs: fi - name: Upload release notes artifact - if: ${{ needs.bump-version.outputs.new_version }} + # The following is debug code, should be reverted before merging. See commit that added this for more info. + if: false uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 with: name: release-notes @@ -271,6 +282,8 @@ jobs: name: gutenberg-plugin - name: Download Release Notes Artifact + # The following is debug code, should be reverted before merging. See commit that added this for more info. + if: false uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 with: name: release-notes @@ -285,8 +298,9 @@ jobs: release_name: ${{ steps.get_release_version.outputs.version }} commitish: ${{ needs.bump-version.outputs.release_branch || github.ref }} draft: true - prerelease: ${{ contains(needs.bump-version.outputs.new_version, 'rc') }} - body_path: release-notes.txt + # The following is debug code, should be reverted before merging. See commit that added this for more info. + # prerelease: ${{ contains(needs.bump-version.outputs.new_version, 'rc') }} + # body_path: release-notes.txt - name: Upload Release Asset id: upload-release-asset From dda3c460c4a5c022ce18883f86fa94f115a9849b Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Thu, 20 Apr 2023 20:10:10 -0600 Subject: [PATCH 22/36] Fix a couple of step names --- .github/workflows/upload-release-to-plugin-repo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 5ce481e3e6accc..e3d68f0daf258a 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -226,7 +226,7 @@ jobs: - name: Check out Gutenberg tags from WP.org plugin repo run: svn checkout "$PLUGIN_REPO_URL/tags" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - name: Download and unzip Gutenberg plugin asset into trunk folder + - name: Download and unzip Gutenberg plugin asset into tags folder env: PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} run: | @@ -244,7 +244,7 @@ jobs: - name: Download Changelog Artifact uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 with: - name: changelog trunk + name: changelog for tags path: tags/${{ github.event.release.name }} - name: Commit the content changes From cade53dc583661aed8dd11ded0d8610e01351901 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Wed, 24 May 2023 17:29:14 -0600 Subject: [PATCH 23/36] Re-add prelease attribute, was accidentally commented out --- .github/workflows/build-plugin-zip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index a5802cf1dfc352..eedb88a43211b6 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -298,8 +298,8 @@ jobs: release_name: ${{ steps.get_release_version.outputs.version }} commitish: ${{ needs.bump-version.outputs.release_branch || github.ref }} draft: true + prerelease: ${{ contains(needs.bump-version.outputs.new_version, 'rc') }} # The following is debug code, should be reverted before merging. See commit that added this for more info. - # prerelease: ${{ contains(needs.bump-version.outputs.new_version, 'rc') }} # body_path: release-notes.txt - name: Upload Release Asset From fe8b33c6ad301a8ea1260f869268f0b0531680c4 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Wed, 24 May 2023 17:39:01 -0600 Subject: [PATCH 24/36] Debug commit, please revert: mock the version number in the version repo --- .github/workflows/upload-release-to-plugin-repo.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index e3d68f0daf258a..b20c59fa977276 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -17,7 +17,14 @@ jobs: run: | latest_version_in_core_repo=$(curl -s 'https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request\[slug\]=gutenberg' | jq -r '.version') echo "Latest Core Repo version: $latest_version_in_core_repo" - echo "version=$latest_version_in_core_repo" >> $GITHUB_OUTPUT + # @todo Revert by uncommenting this before merging + # echo "version=$latest_version_in_core_repo" >> $GITHUB_OUTPUT + + # Mocks the version that would come from the plugin repo, for testing purposes: + # If the version being released by this workflow is > than the last one published + # in the SVN repo, then it will be published as trunk and replace the last version + # on SVN. If it's <, then it will only be published as a tag. + echo "version=v15.9.0" >> $GITHUB_OUTPUT - name: Decide if it is a trunk or tag update id: compute_should_update_trunk From a37623b3097b3c446ee5cac5b16ad314e87f4fe8 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Wed, 24 May 2023 18:16:30 -0600 Subject: [PATCH 25/36] Fix changelog fetching when uploading the SVN tag --- .github/workflows/upload-release-to-plugin-repo.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index b20c59fa977276..949f837e3261b7 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -251,7 +251,13 @@ jobs: - name: Download Changelog Artifact uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 with: - name: changelog for tags + # The name might be confusing here as this job is about a SVN tag and not trunk, + # but in this case `trunk` refers to something else not in the context of SVN. + # it's because the changelog is uploaded using this name in the `update-changelog` + # job above. The changelog is generated and committed to the *git* `trunk` and + # `release/vX.Y.Z` branches, and then the generated text file is stored uising + # the download-artifact action with this name. + name: changelog trunk path: tags/${{ github.event.release.name }} - name: Commit the content changes From ac78cacb2115edcd6504b6132fc0cbfe76f34aef Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Thu, 25 May 2023 09:46:51 -0600 Subject: [PATCH 26/36] Mock SVN version to 16.1.0 --- .github/workflows/upload-release-to-plugin-repo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 949f837e3261b7..c1e86c94cfc813 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -24,7 +24,7 @@ jobs: # If the version being released by this workflow is > than the last one published # in the SVN repo, then it will be published as trunk and replace the last version # on SVN. If it's <, then it will only be published as a tag. - echo "version=v15.9.0" >> $GITHUB_OUTPUT + echo "version=v16.1.0" >> $GITHUB_OUTPUT - name: Decide if it is a trunk or tag update id: compute_should_update_trunk From da46abafed451ca861fa082787f8d18eed093914 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Thu, 25 May 2023 11:53:30 -0600 Subject: [PATCH 27/36] Make the svn commit command verbose in order to debug network timeout issues while testing --- .github/workflows/upload-release-to-plugin-repo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index c1e86c94cfc813..805cfb6eb72f3d 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -265,5 +265,5 @@ jobs: run: | svn st | grep '^?' | awk '{print $2}' | xargs -r svn add svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm - svn commit -m "Committing version $VERSION" \ + svn commit -v -m "Committing version $VERSION" \ --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" From b6a2f82d58b0b7cf528521d509f4e5b3d883769f Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Thu, 25 May 2023 12:05:27 -0600 Subject: [PATCH 28/36] Revert "Make the svn commit command verbose in order to debug network timeout issues while testing" This reverts commit da46abafed451ca861fa082787f8d18eed093914. --- .github/workflows/upload-release-to-plugin-repo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 805cfb6eb72f3d..c1e86c94cfc813 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -265,5 +265,5 @@ jobs: run: | svn st | grep '^?' | awk '{print $2}' | xargs -r svn add svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm - svn commit -v -m "Committing version $VERSION" \ + svn commit -m "Committing version $VERSION" \ --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" From 86f41681629c8ffe290615add3eb2b0daa1d8023 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Thu, 25 May 2023 12:59:57 -0600 Subject: [PATCH 29/36] Optimize SVN tag addition in GitHub workflow This commit significantly optimizes the process of adding a new tag to the SVN repository in our GitHub Workflow. Previously, our process involved checking out the entire tags directory from the SVN repository, which led to increased execution time and failure points when the tags directory was filled with numerous versions. We've resolved this issue by leveraging the svn import command, which allows us to directly add a new directory to the tags directory without checking out the existing directories first. This results in faster and more reliable workflow execution, particularly when dealing with repositories that have accumulated many tagged versions. The changes made include: Removing the step to checkout Gutenberg tags from the WP.org plugin repository. Adding a new step that uses the svn import command to directly add a new version directory to the SVN repository. This is achieved without the need to checkout all existing directories under tags/. Removing the step to checkout the new Gutenberg tag as it's not needed anymore. --- .../upload-release-to-plugin-repo.yml | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index c1e86c94cfc813..c6ca156a6f2844 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -230,40 +230,28 @@ jobs: VERSION: ${{ github.event.release.name }} steps: - - name: Check out Gutenberg tags from WP.org plugin repo - run: svn checkout "$PLUGIN_REPO_URL/tags" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - name: Download and unzip Gutenberg plugin asset into tags folder env: PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} run: | # do the magic here curl -L -o gutenberg.zip $PLUGIN_URL - unzip gutenberg.zip -d tags/$VERSION + unzip gutenberg.zip -d "$VERSION" rm gutenberg.zip - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository env: STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' run: | - sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./tags/$VERSION/readme.txt + sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" "$VERSION/readme.txt" - name: Download Changelog Artifact uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 with: - # The name might be confusing here as this job is about a SVN tag and not trunk, - # but in this case `trunk` refers to something else not in the context of SVN. - # it's because the changelog is uploaded using this name in the `update-changelog` - # job above. The changelog is generated and committed to the *git* `trunk` and - # `release/vX.Y.Z` branches, and then the generated text file is stored uising - # the download-artifact action with this name. name: changelog trunk - path: tags/${{ github.event.release.name }} + path: ${{ github.event.release.name }} - - name: Commit the content changes - working-directory: ./tags + - name: Add the new version directory and commit changes to the SVN repository run: | - svn st | grep '^?' | awk '{print $2}' | xargs -r svn add - svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm - svn commit -m "Committing version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + svn import "$VERSION" "$PLUGIN_REPO_URL/tags/$VERSION" -m "Committing version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" From eae536a6eeca7e7b7373361f451bdbfc58d45d10 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Thu, 25 May 2023 19:01:40 -0600 Subject: [PATCH 30/36] Enhance safety checks in workflow to skip upload jobs for RC builds This commit enhances the conditional checks within the 'upload' and 'upload-tag' jobs in our GitHub Actions workflows. Previously, the jobs were executed based solely on the 'prerelease' flag of the release. However, there could be situations where this flag is accidentally set to 'false' for a Release Candidate (RC). To avoid such mishaps, the conditions have been extended to check for the '-rc' suffix in the version string as well. This ensures that even if the 'prerelease' flag is incorrectly marked as 'false', the 'upload' and 'upload-tag' jobs are still skipped for RCs, thus preventing any unintended release of RC builds. --- .github/workflows/upload-release-to-plugin-repo.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index c6ca156a6f2844..6c3d92c6a81c17 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -156,8 +156,9 @@ jobs: environment: wp.org plugin needs: [compute-should-update-trunk, update-changelog] if: | - needs.compute-should-update-trunk.outputs.should_update_trunk == 'true' && - !github.event.release.prerelease && github.event.release.assets[0] + needs.compute-should-update-trunk.outputs.should_update_trunk == 'true' && + (!github.event.release.prerelease || !contains(github.event.release.name, '-rc')) && + github.event.release.assets[0] env: PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' @@ -220,8 +221,9 @@ jobs: environment: wp.org plugin needs: [compute-should-update-trunk, update-changelog] if: | - needs.compute-should-update-trunk.outputs.should_update_trunk == 'false' && - !github.event.release.prerelease && github.event.release.assets[0] + needs.compute-should-update-trunk.outputs.should_update_trunk == 'false' && + (!github.event.release.prerelease || !contains(github.event.release.name, '-rc')) && + github.event.release.assets[0] env: PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' From d64221186e015a4fc3392698c3c81faa963e2800 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Thu, 25 May 2023 19:17:43 -0600 Subject: [PATCH 31/36] Revert "Enhance safety checks in workflow to skip upload jobs for RC builds" This reverts commit eae536a6eeca7e7b7373361f451bdbfc58d45d10. --- .github/workflows/upload-release-to-plugin-repo.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 6c3d92c6a81c17..c6ca156a6f2844 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -156,9 +156,8 @@ jobs: environment: wp.org plugin needs: [compute-should-update-trunk, update-changelog] if: | - needs.compute-should-update-trunk.outputs.should_update_trunk == 'true' && - (!github.event.release.prerelease || !contains(github.event.release.name, '-rc')) && - github.event.release.assets[0] + needs.compute-should-update-trunk.outputs.should_update_trunk == 'true' && + !github.event.release.prerelease && github.event.release.assets[0] env: PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' @@ -221,9 +220,8 @@ jobs: environment: wp.org plugin needs: [compute-should-update-trunk, update-changelog] if: | - needs.compute-should-update-trunk.outputs.should_update_trunk == 'false' && - (!github.event.release.prerelease || !contains(github.event.release.name, '-rc')) && - github.event.release.assets[0] + needs.compute-should-update-trunk.outputs.should_update_trunk == 'false' && + !github.event.release.prerelease && github.event.release.assets[0] env: PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' From 472262ebc84c3dde6fd1d34b8e256ad315af0339 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Thu, 25 May 2023 19:29:28 -0600 Subject: [PATCH 32/36] Skip upload jobs if release is an RC by checking the ref for a rc suffix This makes sure we don't upload RCs as trunk or tag even if the deployer accidentally unchecks the "Set as prerelease" flag. --- .../workflows/upload-release-to-plugin-repo.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index c6ca156a6f2844..dee578e6415fe4 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -8,6 +8,14 @@ jobs: compute-should-update-trunk: name: Decide if trunk or tag runs-on: ubuntu-latest + # Skip this job if the release is a release candidate. This will in turn skip + # the upload jobs, which are only relevant for non-RC releases. + # We first check if the release is a prerelease, and then if the ref contains + # the string "rc". The latter is fallback in case the deployer accidentally + # unchecks the "This is a pre-release" checkbox in the release UI. + if: | + !github.event.release.prerelease && !contains(github.ref, 'rc') + outputs: should_update_trunk: ${{ steps.compute_should_update_trunk.outputs.should_update_trunk }} @@ -156,8 +164,7 @@ jobs: environment: wp.org plugin needs: [compute-should-update-trunk, update-changelog] if: | - needs.compute-should-update-trunk.outputs.should_update_trunk == 'true' && - !github.event.release.prerelease && github.event.release.assets[0] + needs.compute-should-update-trunk.outputs.should_update_trunk == 'true' && github.event.release.assets[0] env: PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' @@ -220,8 +227,7 @@ jobs: environment: wp.org plugin needs: [compute-should-update-trunk, update-changelog] if: | - needs.compute-should-update-trunk.outputs.should_update_trunk == 'false' && - !github.event.release.prerelease && github.event.release.assets[0] + needs.compute-should-update-trunk.outputs.should_update_trunk == 'false' && github.event.release.assets[0] env: PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' From fae69ef57f682ca6e85633f7f211adb5b8236e29 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Thu, 1 Jun 2023 12:03:41 -0600 Subject: [PATCH 33/36] Revert build plugin mocking logic Effectively reverts changes in 014e2c6. --- .github/workflows/build-plugin-zip.yml | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index eedb88a43211b6..2502eca279e638 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -164,25 +164,18 @@ jobs: steps: - name: Checkout code - # The following is debug code, should be reverted before merging. See commit that added this for more info. - if: false uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: ref: ${{ needs.bump-version.outputs.release_branch || github.ref }} - name: Use desired version of Node.js - # The following is debug code, should be reverted before merging. See commit that added this for more info. - if: false uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: '.nvmrc' cache: npm - name: Build Gutenberg plugin ZIP file - # The following is debug code, should be reverted before merging. See commit that added this for more info. - run: | - echo 'Stable tag: V.V.V' > readme.txt - zip -j gutenberg.zip readme.txt + run: ./bin/build-plugin-zip.sh env: NO_CHECKS: 'true' @@ -193,10 +186,6 @@ jobs: path: ./gutenberg.zip - name: Build release notes draft - # Debug: if we want fast runs, then this should be disabled as this won't - # work if the real plugin isn't built (becuase npm install is needed to install - # some needed packages that the `other:changelog` task uses`). - if: false env: VERSION: ${{ needs.bump-version.outputs.new_version }} run: | @@ -212,8 +201,6 @@ jobs: fi - name: Upload release notes artifact - # The following is debug code, should be reverted before merging. See commit that added this for more info. - if: false uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 with: name: release-notes @@ -282,8 +269,6 @@ jobs: name: gutenberg-plugin - name: Download Release Notes Artifact - # The following is debug code, should be reverted before merging. See commit that added this for more info. - if: false uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 with: name: release-notes @@ -299,8 +284,7 @@ jobs: commitish: ${{ needs.bump-version.outputs.release_branch || github.ref }} draft: true prerelease: ${{ contains(needs.bump-version.outputs.new_version, 'rc') }} - # The following is debug code, should be reverted before merging. See commit that added this for more info. - # body_path: release-notes.txt + body_path: release-notes.txt - name: Upload Release Asset id: upload-release-asset From 6206fc7577ab532607a5ba77e129943715490070 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Thu, 1 Jun 2023 12:10:17 -0600 Subject: [PATCH 34/36] Revert initial dev/debug changes Reverts changes from 489aa70. If further testing is needed, revert the changes here again. --- .github/workflows/build-plugin-zip.yml | 4 ++-- .github/workflows/upload-release-to-plugin-repo.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 2502eca279e638..01681ca9f4b2e0 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -71,7 +71,7 @@ jobs: - name: Checkout code uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GUTENBERG_TOKEN }} - name: Compute old and new version id: get_version @@ -302,7 +302,7 @@ jobs: runs-on: ubuntu-latest environment: WordPress packages needs: [bump-version, build] - if: ${{ false }} + if: ${{ endsWith( needs.bump-version.outputs.new_version, '-rc.1' ) }} steps: - name: Checkout (for CLI) uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index dee578e6415fe4..bcb412df596df5 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -106,7 +106,7 @@ jobs: uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: ref: ${{ matrix.branch }} - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GUTENBERG_TOKEN }} - name: Update the Changelog to include the release notes run: | @@ -166,7 +166,7 @@ jobs: if: | needs.compute-should-update-trunk.outputs.should_update_trunk == 'true' && github.event.release.assets[0] env: - PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' + PLUGIN_REPO_URL: 'https://plugins.svn.wordpress.org/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' SVN_USERNAME: ${{ secrets.svn_username }} SVN_PASSWORD: ${{ secrets.svn_password }} @@ -229,7 +229,7 @@ jobs: if: | needs.compute-should-update-trunk.outputs.should_update_trunk == 'false' && github.event.release.assets[0] env: - PLUGIN_REPO_URL: 'http://caffeine.ngrok.io/svn/gutenberg' + PLUGIN_REPO_URL: 'https://plugins.svn.wordpress.org/gutenberg' STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' SVN_USERNAME: ${{ secrets.svn_username }} SVN_PASSWORD: ${{ secrets.svn_password }} From b2bde7dd8dea01ad0163b4e01d82d51995248da3 Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Thu, 1 Jun 2023 12:13:03 -0600 Subject: [PATCH 35/36] Revert WP SVN repo version mock Revert changes from fe8b33c. --- .github/workflows/upload-release-to-plugin-repo.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index bcb412df596df5..f567308c41b4ea 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -25,14 +25,7 @@ jobs: run: | latest_version_in_core_repo=$(curl -s 'https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request\[slug\]=gutenberg' | jq -r '.version') echo "Latest Core Repo version: $latest_version_in_core_repo" - # @todo Revert by uncommenting this before merging - # echo "version=$latest_version_in_core_repo" >> $GITHUB_OUTPUT - - # Mocks the version that would come from the plugin repo, for testing purposes: - # If the version being released by this workflow is > than the last one published - # in the SVN repo, then it will be published as trunk and replace the last version - # on SVN. If it's <, then it will only be published as a tag. - echo "version=v16.1.0" >> $GITHUB_OUTPUT + echo "version=$latest_version_in_core_repo" >> $GITHUB_OUTPUT - name: Decide if it is a trunk or tag update id: compute_should_update_trunk From 73a5fc4f300de4a6691006586649916b8b0a6b3e Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Wed, 5 Jul 2023 11:06:30 -0600 Subject: [PATCH 36/36] Add back if conditions that were accidentally removed Removed in https://github.com/WordPress/gutenberg/pull/49082/commits/014e2c6168c6945029ce7b1ac2ffbf3525004d4a. I accidentally removed it instead of commenting out, so I forgot to reactivate it. The problem was that due to the amount of changes later, I couldn't just revert this commit. --- .github/workflows/build-plugin-zip.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 01681ca9f4b2e0..34d8669c64ca21 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -186,6 +186,7 @@ jobs: path: ./gutenberg.zip - name: Build release notes draft + if: ${{ needs.bump-version.outputs.new_version }} env: VERSION: ${{ needs.bump-version.outputs.new_version }} run: | @@ -201,6 +202,7 @@ jobs: fi - name: Upload release notes artifact + if: ${{ needs.bump-version.outputs.new_version }} uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 with: name: release-notes