-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathdeploy.sh
More file actions
59 lines (43 loc) · 1.49 KB
/
deploy.sh
File metadata and controls
59 lines (43 loc) · 1.49 KB
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
#!/usr/bin/env bash
# https://zerowp.com/?p=55
set -e
# Get the plugin slug from this git repository.
PLUGIN_SLUG="${PWD##*/}"
# Get the current release version
TAG="${GITHUB_REF#refs/tags/}"
echo "Deploying version $TAG of $PLUGIN_SLUG to WordPress.org..."
# Get the SVN data from wp.org in a folder named `svn`
svn co --depth immediates "https://plugins.svn.wordpress.org/$PLUGIN_SLUG" ./svn
svn update --set-depth infinity ./svn/trunk
svn update --set-depth infinity ./svn/assets
# Clean trunk directory (remove all files, keep directory)
rm -rf ./svn/trunk/*
# Copy files from `src` to `svn/trunk`
cp -R ./src/* ./svn/trunk
# Copy the images from `assets` to `svn/assets`
cp -R ./wp_org/assets/* ./svn/assets
# Switch to SVN directory
cd ./svn
# Add new files and remove deleted files
svn add --force trunk
svn add --force assets
# Remove files from SVN that no longer exist
svn status | grep '^!' | awk '{print $2}' | xargs -r svn rm
# Check if tag already exists
if svn ls "tags/$TAG" 2>/dev/null; then
echo "Tag $TAG already exists, updating..."
svn update --set-depth infinity "tags/$TAG"
rm -rf "tags/$TAG"/*
cp -R trunk/* "tags/$TAG"/
else
# Create the version tag in svn
svn cp trunk "tags/$TAG"
fi
# Prepare the tag for commit
svn add --force tags
# Commit files to wordpress.org.
svn ci --message "Release $TAG" \
--username "$SVN_USERNAME" \
--password "$SVN_PASSWORD" \
--non-interactive
echo "Successfully deployed version $TAG to WordPress.org"