-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpluginpacker.sh
More file actions
executable file
·149 lines (128 loc) · 4.03 KB
/
Copy pathpluginpacker.sh
File metadata and controls
executable file
·149 lines (128 loc) · 4.03 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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env bash
set -euo pipefail
pluginDir="plugin"
projectFile="$pluginDir/BTCPayServer.Plugins.BareBitcoin.csproj"
fullName="BTCPayServer.Plugins.BareBitcoin"
repoUrl="https://github.com/schjonhaug/btcpayserver-plugin-barebitcoin"
pluginBuilderUrl="https://plugin-builder.btcpayserver.org/plugins/barebitcoin/create"
pluginPackerDir="../btcpayserver/BTCPayServer.PluginPacker"
pluginPackerOut="$pluginPackerDir/build-tools/PluginPacker"
usage() {
cat <<EOF
Usage: $0 <version> [--no-push] [--no-package]
Creates a reproducible Plugin Builder pre-release candidate:
1. validates master and a clean worktree
2. updates $projectFile
3. runs tests
4. commits "Release v<version>"
5. creates tag v<version>
6. pushes master and tag unless --no-push is passed
7. creates a local .btcpay package unless --no-package is passed
8. prints the Plugin Builder form values
Every Plugin Builder build starts as a pre-release. After validation, press
Release in the Plugin Builder UI to make that same build public.
EOF
}
version=""
pushRelease=true
packageLocal=true
while [ "$#" -gt 0 ]; do
case "$1" in
--no-push)
pushRelease=false
;;
--no-package)
packageLocal=false
;;
-h|--help)
usage
exit 0
;;
v*)
echo "Pass the version without a leading v, for example: 2.0.1" >&2
usage >&2
exit 1
;;
[0-9]*)
if [ -n "$version" ]; then
echo "Version was provided more than once." >&2
usage >&2
exit 1
fi
version="$1"
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
shift
done
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version must be SemVer without a leading v, for example: 2.0.1" >&2
usage >&2
exit 1
fi
tag="v$version"
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
echo "Release must be run from master." >&2
exit 1
fi
if [ -n "$(git status --porcelain)" ]; then
echo "Worktree must be clean before release." >&2
git status --short >&2
exit 1
fi
if git rev-parse "$tag" >/dev/null 2>&1; then
echo "Tag $tag already exists locally." >&2
exit 1
fi
currentVersion="$(sed -n 's:.*<Version>\(.*\)</Version>.*:\1:p' "$projectFile" | head -1)"
if [ -z "$currentVersion" ]; then
echo "Could not find <Version> in $projectFile." >&2
exit 1
fi
echo "Preparing release $tag from current version $currentVersion"
perl -0pi -e "s:<Version>[^<]+</Version>:<Version>$version</Version>:" "$projectFile"
dotnet test --project BTCPayServer.Plugins.Tests/BTCPayServer.Plugins.Tests.csproj -c Release --minimum-expected-tests 1
git add "$projectFile"
git commit -m "Release $tag"
git tag "$tag"
if [ "$pushRelease" = true ]; then
git push origin master
git push origin "$tag"
else
echo "Skipping push because --no-push was passed."
fi
if [ "$packageLocal" = true ]; then
rm -rf "$pluginPackerOut"
pushd "$pluginPackerDir"
mkdir -p build-tools/PluginPacker
dotnet build -c Release -o build-tools/PluginPacker
rm -rf build-tools/btcpayserver
popd
pushd "$pluginDir"
rm -rf tmp/publish tmp/publish-package tmp/out
dotnet publish -c Release -o "tmp/publish"
../../btcpayserver/BTCPayServer.PluginPacker/build-tools/PluginPacker/BTCPayServer.PluginPacker "tmp/publish" "$fullName" "tmp/publish-package"
mkdir -p tmp/out
cp tmp/publish-package/*/*/* tmp/out
rm -f tmp/out/SHA256SUMS.asc tmp/out/SHA256SUMS
popd
echo "Plugin file ready at: $pluginDir/tmp/out/"
else
echo "Skipping local .btcpay package because --no-package was passed."
fi
echo
echo "Plugin Builder build page: $pluginBuilderUrl"
echo
echo "Plugin Builder fields:"
echo " Git repository: $repoUrl"
echo " Git branch or tag: $tag"
echo " Directory to the plugin's project: $pluginDir"
echo " Dotnet build configuration: Release"
echo
echo "This Plugin Builder build will start as a pre-release."
echo "Install it on your own BTCPay instance with pre-release plugins enabled."
echo "After validation, press Release in Plugin Builder to make $tag public."