forked from Scrybbling-together/remarks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·67 lines (52 loc) · 1.8 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·67 lines (52 loc) · 1.8 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
#!/bin/bash
LOG="release.log"
echo "" > $LOG
#if [ -n "$(git status --porcelain)" ]; then
# echo "Error: Working tree is dirty. Please commit or stash your changes."
# exit 1
#fi
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" != "main" ]; then
echo "Error: Current branch is not 'main'. Please switch to the main branch."
exit 1
fi
gum format -- "# Building and releasing **the remarks-server docker container**"
gum spin --spinner dot --title "Building container" --show-output -- nix build .#dockerServer &>> $LOG
SOURCE_IMAGE=$(docker load < result | awk '{ print $3}')
COMMIT=$(git rev-parse main)
gum spin --spinner dot --title "Loading container into docker" --show-output -- docker load < result
echo "$GUM_SPIN_SHOW_OUTPUT" >> $LOG
COMMIT_TAG="laauurraaa/remarks-server:$COMMIT"
LATEST_TAG="laauurraaa/remarks-server:latest"
gum format <<EOF
## Built tags
**$COMMIT_TAG**
**$LATEST_TAG**
EOF
docker tag "$SOURCE_IMAGE" "$COMMIT_TAG" &>> $LOG
docker tag "$SOURCE_IMAGE" "$LATEST_TAG" &>> $LOG
gum format -- "## Pushing to docker hub!"
gum spin --spinner dot --title "Pushing commit tag to docker hub" --show-output -- docker push -q "$COMMIT_TAG"
PUSH_COMMIT_EXIT_CODE=$?
echo "$GUM_SPIN_SHOW_OUTPUT" >> $LOG
gum spin --spinner dot --title "Pushing latest tag to docker hub" --show-output -- docker push -q "$LATEST_TAG"
PUSH_LATEST_EXIT_CODE=$?
echo "$GUM_SPIN_SHOW_OUTPUT" >> $LOG
if [ $PUSH_COMMIT_EXIT_CODE -eq 0 ]; then
gum format <<EOF
Commit tag container **successfully pushed**: \`$COMMIT_TAG\`
EOF
else
gum format <<EOF
Commit tag container **failed to push**
EOF
fi
if [ $PUSH_LATEST_EXIT_CODE -eq 0 ]; then
gum format <<EOF
Latest tag container **successfully pushed**: \`$LATEST_TAG\`
EOF
else
gum format <<EOF
Latest tag container **failed to push**
EOF
fi