Skip to content

Commit

Permalink
Optimize SVN tag addition in GitHub workflow
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fullofcaffeine committed May 25, 2023
1 parent b6a2f82 commit 86f4168
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions .github/workflows/upload-release-to-plugin-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 86f4168

Please sign in to comment.