-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (78 loc) · 3.87 KB
/
upload-release-to-plugin-repo.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Update Changelog and upload Blockera plugin to WordPress.org plugin repo
on:
release:
types: [published]
jobs:
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]}.${VERSION_ARRAY[2]}"
echo "release_branch=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT
upload:
name: Publish as trunk (and tag)
runs-on: ubuntu-latest
environment: wp.org plugin
needs: [get-release-branch]
if: ${{ !github.event.release.prerelease && github.event.release.assets[0] }}
env:
PLUGIN_REPO_URL: 'https://plugins.svn.wordpress.org/blockera'
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: Install SVN
run: |
sudo apt-get update
sudo apt-get install -y subversion
- name: Check out Blockera 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 Blockera plugin asset into trunk folder
env:
PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }}
run: |
curl -L -o blockera.zip $PLUGIN_URL
unzip blockera.zip -d trunk
rm blockera.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: 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"
- name: Checkout code
uses: actions/checkout@v4
# - name: Update assets/readme
# uses: ./.github/update-assets
# with:
# svn-username: ${{ secrets.SVN_USERNAME }}
# svn-password: ${{ secrets.SVN_PASSWORD }}