Repository navigation
Expand file tree
/
Copy pathupload-release
More file actions
executable file
·98 lines (79 loc) · 2.45 KB
/
Copy pathupload-release
File metadata and controls
executable file
·98 lines (79 loc) · 2.45 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
#!/usr/bin/env bash
set -e
function print_usage() {
cat <<EOF
$(basename "$0") VERSION ARTIFACTS_DIR
This script uploads the artifacts and changelog entry for a release to a
permanent storage location where end users can download them.
Requires the \`aws\` CLI to be installed and configured to be able to use
DigitalOcean. Also requires access to the Alda releases DigitalOcean Space,
obviously.
EOF
}
release_version="$1"
artifacts_dir="$2"
if [[ -z "$release_version" ]] || [[ -z "$artifacts_dir" ]]; then
print_usage
exit 1
fi
if ! command -v aws > /dev/null; then
echo "This script requires the \`aws\` CLI."
exit 1
fi
spaces_endpoint="https://nyc3.digitaloceanspaces.com"
function spaces_s3() {
aws "--endpoint=$spaces_endpoint" s3 "$@"
}
releases_bucket="s3://alda-releases"
release_s3_url="$releases_bucket/$release_version"
# Verify that a release with this version number wasn't already uploaded.
if spaces_s3 ls "$release_s3_url" > /dev/null; then
echo "Release already uploaded: $release_s3_url"
exit 1
fi
echo "Generating version changelog..."
version_changelog="$(mktemp)"
"$(dirname "$0")/version-changelog" "$release_version" > "$version_changelog"
echo "Uploading $artifacts_dir to $release_s3_url..."
# Upload all of the (non-Windows) `alda` and `alda-player` executables, ensuring
# that they have the MIME type application/octet-stream. I noticed that if we
# don't specify the content type, they end up having the content type
# binary/octet-stream, which Firefox seems to think is a DEB file, for some
# reason.
spaces_s3 sync \
--acl public-read \
--exclude '*' \
--include '*/alda' \
--include '*/alda-player' \
--content-type application/octet-stream \
"$artifacts_dir" \
"$release_s3_url"
# Upload alda.wasm, making sure that the content type is correctly set to
# application/wasm.
spaces_s3 sync \
--acl public-read \
--exclude '*' \
--include '*/alda.wasm' \
--content-type application/wasm \
"$artifacts_dir" \
"$release_s3_url"
# Upload everything else, trusting that S3 is smart enough to infer the correct
# content type.
spaces_s3 sync \
--acl public-read \
--exclude '*/alda' \
--exclude '*/alda-player' \
--exclude '*/alda.wasm' \
"$artifacts_dir" \
"$release_s3_url"
# Add CHANGELOG.md
spaces_s3 cp \
--acl public-read \
"$version_changelog" \
"$release_s3_url/CHANGELOG.md"
# Add date.txt
date '+%Y-%m-%d' \
| spaces_s3 cp \
--acl public-read \
- \
"$release_s3_url/date.txt"