-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrelease-fred
executable file
·181 lines (154 loc) · 5.67 KB
/
release-fred
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
# variables used by this script
# these variables are probably different for everybody
# so create $HOME/.freenetrc and override those with your desired values.
# Load configuration and utility functions.
source freenet-scripts-common || exit
# What to build / release. Possible values: "build", "testing", "snapshot"
target=""
# Whether to exit before releasing.
dryRun="false"
while :
do
case $1 in
--help | - | -\?)
cat <<EOF
$0 [--dry-run] TARGET
Builds and releases a version of Fred.
Prompts for confirmation before releasing.
Configuration file is at $configPath by default.
TARGET:
build If present packages the highest-numbered build tag.
Builds documentation.
testing If present packages the highest-numbered testing build tag.
Builds documentation.
snapshot If present packages the current HEAD.
Outputs into a pre/ subdirectory of the release directory.
Skips building documentation.
--dry-run If present, builds packages and skips releasing.
EOF
exit 0
;;
--config)
CONFIG="$2"
shift 2
;;
--dry-run)
dryRun="true"
shift
;;
--) # End of all options
shift
break
;;
-*)
echo "Unknown option: $1"
exit 1
;;
*) # No more options; stop parsing.
break
;;
esac
done
# Target should be set.
if [[ -z "$1" ]]; then
echo "Please specify a target. Options are build, testing, and snapshot."
exit 13
fi
target="$1"
makeBuildDir
git clone "$fredDir" "$buildDir" || exit 2
cd "$fredDir"
# Function in freenet-scripts-common - sets $gitVersion, $buildNumber, and $commitID.
getBuildInfo $target
# If releasing a stable build checkout the latest build tag.
if [[ x"$target" = x"build" || x"$target" = x"testing" ]]; then
# Recognized; gitVersion is already set by getBuildInfo.
echo -n
elif [[ "$target" = "snapshot" ]]; then
gitVersion=$(git describe --always)
commitID=$(git rev-parse HEAD)
releaseDir="$releaseDir/pre"
else
echo "Unrecognized target \"$target\"."
exit 14
fi
echo "Building $target."
cd "$buildDir"
git checkout "$gitVersion" || exit 12
# Build script uses environment variables.
export jarsignerStoreLocation="$jarsignerStoreLocation"
export jarsignerStorePassword="$jarsignerStorePassword"
export jarsignerAlias="$jarsignerAlias"
export jarsignerCodeSigningKeyPassword="$jarsignerCodeSigningKeyPassword"
if [[ x"$target" = x"build" || x"$target" = x"testing" ]]; then
jarName="freenet-$gitVersion.jar"
elif [[ x"$target" = x"snapshot" ]]; then
jarName="freenet-$gitVersion-snapshot.jar"
else
echo "Internal error: Unrecognized target \"$target\"."
exit 15
fi
# Build without JavaDocs; CI builds and uploads them.
# ./gradlew --offline jar || exit
./gradlew jar || exit
archiveName="freenet-$gitVersion-source.tar.bz2"
# move file in position
mv build/libs/freenet.jar "$jarName" || exit 10
# create source archive
git archive --format=tar HEAD --prefix="freenet-$gitVersion/" | bzip2 -v9 > "$archiveName" || exit 11
# Generate checksums and signatures for the jar and source archive.
# TODO: Binary sha512sum instead of sha1sum. Note that this will require changes to the installer and update scripts, we probably want to keep the .sha1's as well as .sha512/.sha256.
sha1sum "$jarName" > "$jarName.sha1"
sha1sum "$archiveName" > "$archiveName.sha1"
if [ -n "$signingUser" ]; then
echo "Switching to signing user \"$signingUser\""
signDir=$(mktemp -d)
cp "$buildDir/$jarName" "$buildDir/$archiveName" "$signDir" || exit 18
# signingUser is a top level user, so it has its own group, right?
chgrp "$signingUser" "$signDir" || exit 19
chmod g+rwx "$signDir" || exit 20
chmod g+r "$signDir"/* || exit 21
su - "$signingUser" -c "gpg --sign --detach-sign -o \"$signDir/$jarName.sig\" \"$signDir/$jarName\"; gpg --sign --detach-sign -o \"$signDir/$archiveName.sig\" \"$signDir/$archiveName\"" || exit 22
cp "$signDir/$jarName.sig" "$signDir/$archiveName.sig" "$buildDir" || exit 23
rm -Rf "$signDir"
else
gpg --sign --detach-sign -o "$buildDir/$jarName.sig" "$buildDir/$jarName" || exit 17
gpg --sign --detach-sign -o "$buildDir/$archiveName.sig" "$buildDir/$archiveName" || exit 17
fi
# make sure release directory exists
mkdir -p "$releaseDir"
# Copy files, checksums, and signatures to local release directory
cp "$jarName"* "$releaseDir"
cp "$archiveName"* "$releaseDir"
rm "$releaseDir/freenet.jar"
pushd "$releaseDir"
ln -s "$jarName" "freenet.jar"
popd
# Localization comparison for build.
if [[ "$target" = "build" ]]; then
compareL10n $buildNumber || exit 33
fi
echo "Built $gitVersion as a $target release."
echo "Commit ID is $commitID"
if [[ "$dryRun" = "true" ]]; then
echo "Dry run - exiting without performing release."
exit 0
else
require "Perform $target release?"
fi
echo "Performing $target release."
# TODO: Upload to project mvn repository
# Upload snapshot binary, source, and signatures to Freenet.
if [[ "$target" = "snapshot" ]]; then
echo "Inserting snapshot into Freenet."
# fcpput detects MIME types incorrectly as of version 0.2.5, so specify them
# explicitly.
put "$releaseDir/$jarName" "application/x-java-archive"
put "$releaseDir/$jarName.sig" "application/pgp-signature"
put "$releaseDir/$archiveName" "application/x-bzip"
put "$releaseDir/$archiveName.sig" "application/pgp-signature"
else
echo "Not inserting build into Freenet. insert-update does that as part of release-build."
fi
echo "$target release complete."