-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH Actions: Add action to upload release to SVN repo (#27591)
The idea here is to couple the upload of the Gutenberg plugin to the WP.org plugin repo tightly to when a new release is published to GitHub, rather than running it from the local system of whoever's in charge of releasing that version. Moving parts of the release workflow from locally running scripts to GH actions should overall make the process more easily reproducible, and should free up time and resources required for the release process. The relevant job needs to be [approved](https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/reviewing-deployments#approving-or-rejecting-a-job) by a qualified reviewer (i.e. a member of the `gutenberg-core` team). This is to ensure that plugin releases cannot be published by anyone who has commit access to the GitHub repo.
- Loading branch information
Showing
3 changed files
with
64 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
on: | ||
release: | ||
types: [released] | ||
|
||
name: Upload Gutenberg plugin to WordPress.org plugin repo | ||
|
||
jobs: | ||
upload: | ||
name: Upload Gutenberg Plugin | ||
runs-on: ubuntu-latest | ||
environment: wp.org plugin | ||
if: github.event.release.assets[0] | ||
env: | ||
PLUGIN_REPO_URL: 'https://plugins.svn.wordpress.org/gutenberg' | ||
STABLE_TAG_REGEX: 'Stable tag: [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" | ||
|
||
- name: Get previous stable tag | ||
id: get_previous_stable_tag | ||
run: echo ::set-output name=stable_tag::$(grep "$STABLE_TAG_REGEX" ./trunk/readme.txt) | ||
|
||
- 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' | ||
STABLE_TAG: ${{ steps.get_previous_stable_tag.outputs.stable_tag }} | ||
run: sed -i "s/${STABLE_TAG_PLACEHOLDER}/${STABLE_TAG}/g" ./trunk/readme.txt | ||
|
||
- 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_REGEX}/Stable tag: ${VERSION}/g" ./readme.txt | ||
svn commit -m "Releasing version $VERSION" \ | ||
--no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.