-
Notifications
You must be signed in to change notification settings - Fork 4
/
publish.sh
executable file
·69 lines (50 loc) · 1.6 KB
/
publish.sh
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
#!/bin/bash
set -e
if [[ $# -eq 0 ]]; then
cat <<-HELP
./publish.sh <version> <environment>
Publishes docker image and CircleCI Orb
<version> - SemVer identifier of the release
<environment> - "development" (default) or "production"
HELP
exit
fi
[[ -z "$1" ]] && { echo "No version specified" ; exit 1; }
version="$1"
[[ -z "$2" ]] && { echo "No environment specified, defaulting to development"; }
environment="${2:-development}"
if [ "$environment" == "production" ]; then
cat <<-VERSIONING
It looks like you're trying to publish to production!
Be sure that you have bumped the version in the following places:
- Dockerfile
- orb.yml
- README.md
VERSIONING
else
cat <<-VERSIONING
It looks like you're trying to publish to a development tag!
Make sure you've set your orb.yml file to point at the dev docker tag
- image: packtracker/report:$version-dev
Make sure you've also set the GitHub Action base image in `Dockerfile`
FROM packtracker/report:$version-dev
VERSIONING
fi
read -p "Ready to publish to $environment? " -n 1 -r
echo # (optional) move to a new line
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
if [ "$environment" == "production" ]; then
dockertag="packtracker/report:$version"
circlecitag="packtracker/report@$version"
else
dockertag="packtracker/report:$version-dev"
circlecitag="packtracker/report@dev:$version"
fi
echo "Publishing docker image: $dockertag"
docker build -f Dockerfile.base -t $dockertag .
docker push $dockertag
echo "Publishing circleci orb: $circlecitag"
circleci orb validate ./orb.yml
circleci orb publish ./orb.yml $circlecitag