-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathnotify-registry.sh
More file actions
executable file
·57 lines (46 loc) · 1.46 KB
/
notify-registry.sh
File metadata and controls
executable file
·57 lines (46 loc) · 1.46 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
#!/usr/bin/env bash
set -euo pipefail
IMAGE_NAME=${IMAGE_NAME:-transloadit-ruby-sdk-dev}
err() {
echo "notify-registry: $*" >&2
}
if ! command -v docker >/dev/null 2>&1; then
err "Docker is required to publish the gem."
exit 1
fi
if [[ -z "${GEM_HOST_API_KEY:-}" ]]; then
err "GEM_HOST_API_KEY environment variable is not set. Generate a RubyGems API key with push permissions and export it before running this script."
exit 1
fi
if ! docker image inspect "$IMAGE_NAME" >/dev/null 2>&1; then
err "Docker image '$IMAGE_NAME' not found. Building it now..."
docker build -t "$IMAGE_NAME" -f Dockerfile .
fi
version=$(
docker run --rm \
-v "$PWD":/workspace \
-w /workspace \
"$IMAGE_NAME" \
ruby -Ilib -e 'require "transloadit/version"; puts Transloadit::VERSION'
)
gem_file="transloadit-${version}.gem"
err "Building ${gem_file}..."
docker run --rm \
--user "$(id -u):$(id -g)" \
-e HOME=/workspace \
-v "$PWD":/workspace \
-w /workspace \
"$IMAGE_NAME" \
bash -lc "set -euo pipefail; rm -f ${gem_file}; gem build transloadit.gemspec >/dev/null"
err "Pushing ${gem_file} to RubyGems..."
docker run --rm \
--user "$(id -u):$(id -g)" \
-e HOME=/workspace \
-e GEM_HOST_API_KEY="$GEM_HOST_API_KEY" \
-v "$PWD":/workspace \
-w /workspace \
"$IMAGE_NAME" \
bash -lc "set -euo pipefail; gem push ${gem_file}"
err "Removing local ${gem_file}..."
rm -f "${gem_file}"
echo "notify-registry: Successfully pushed ${gem_file} to RubyGems."