-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[Github-Actions-Workflows][Plugin-Release] Allow shipping a point-release for an older stable release #49082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 35 commits
8cd1231
d685abb
8b939f8
ff5c80f
489aa70
9dc4b39
7438230
237fd16
8934253
0b06966
2cb1260
1b0713b
7ac820e
b35880a
a81bc68
60c465a
a370648
cd9bf15
e5e5764
4297be6
014e2c6
dda3c46
cade53d
fe8b33c
a37623b
ac78cac
da46aba
b6a2f82
86f4168
eae536a
d642211
472262e
fae69ef
6206fc7
b2bde7d
73a5fc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,10 +5,66 @@ on: | |
| types: [published] | ||
|
|
||
| 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 }} | ||
|
|
||
| steps: | ||
| - name: Fetch latest version in the WP core repo | ||
| id: compute_latest_version_in_core_repo | ||
| 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 | ||
|
|
||
| - name: Decide if it is a trunk or tag update | ||
| id: compute_should_update_trunk | ||
| env: | ||
| GITHUB_REF: ${{ github.ref }} | ||
| run: | | ||
| latestPublishedVersion=$(echo "$GITHUB_REF" | sed -E 's/refs\/tags\/(v?)([0-9.]+)/\2/') | ||
fullofcaffeine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| latestVersionInCoreRepo="${{ steps.compute_latest_version_in_core_repo.outputs.version }}" | ||
|
|
||
| # 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 $? | ||
| } | ||
|
Comment on lines
+38
to
+52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely not for this PR, but in a follow-up, can we maybe replace this with the (and cleanup: (
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good point. I'll take note of that for a follow-up 👍🏻 |
||
|
|
||
| # 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 | ||
|
|
||
| echo "Should update trunk: $shouldUpdateTrunk" | ||
| echo "should_update_trunk=$shouldUpdateTrunk" >> $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 }} | ||
|
|
||
|
|
@@ -25,7 +81,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 }} | ||
|
|
@@ -95,11 +152,12 @@ jobs: | |
| path: ./changelog.txt | ||
|
|
||
| upload: | ||
| name: Upload Gutenberg Plugin | ||
| name: Publish as trunk (and tag) | ||
fullofcaffeine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| runs-on: ubuntu-latest | ||
| environment: wp.org plugin | ||
| needs: update-changelog | ||
| if: ${{ !github.event.release.prerelease && github.event.release.assets[0] }} | ||
| needs: [compute-should-update-trunk, update-changelog] | ||
| if: | | ||
| needs.compute-should-update-trunk.outputs.should_update_trunk == 'true' && github.event.release.assets[0] | ||
| env: | ||
| PLUGIN_REPO_URL: 'https://plugins.svn.wordpress.org/gutenberg' | ||
| STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' | ||
|
|
@@ -109,11 +167,7 @@ jobs: | |
|
|
||
| steps: | ||
| - 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 +184,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 +213,44 @@ 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-tag: | ||
fullofcaffeine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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.assets[0] | ||
| env: | ||
| 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: | ||
| - 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 "$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" "$VERSION/readme.txt" | ||
|
|
||
| - name: Download Changelog Artifact | ||
| uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 | ||
| with: | ||
| name: changelog trunk | ||
| path: ${{ github.event.release.name }} | ||
|
|
||
| - name: Add the new version directory and commit changes to the SVN repository | ||
| run: | | ||
| svn import "$VERSION" "$PLUGIN_REPO_URL/tags/$VERSION" -m "Committing version $VERSION" \ | ||
| --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" | ||
Uh oh!
There was an error while loading. Please reload this page.