aboutsummaryrefslogtreecommitdiff
path: root/scripts/deploy-snapshot.sh
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-03-05 23:05:20 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2022-03-05 23:12:50 +0530
commit208e49e4d51891f2a3d16647ceb43eef9eebfce6 (patch)
tree08c090b72e4aa4d2f60f1a1cdd66a7889a64e372 /scripts/deploy-snapshot.sh
parentb8756a667c56f67d14b25286f2568f3eb3e8e9f3 (diff)
Move snapshot releases to GitHub (#1767)
Diffstat (limited to 'scripts/deploy-snapshot.sh')
-rwxr-xr-xscripts/deploy-snapshot.sh56
1 files changed, 48 insertions, 8 deletions
diff --git a/scripts/deploy-snapshot.sh b/scripts/deploy-snapshot.sh
index 0f10d9eb..5a8c846f 100755
--- a/scripts/deploy-snapshot.sh
+++ b/scripts/deploy-snapshot.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env sh
+#!/usr/bin/env bash
#
# Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
# SPDX-License-Identifier: GPL-3.0-only
@@ -6,10 +6,50 @@
set -ex
-export SSHDIR="$HOME/.ssh"
-mkdir -p "$SSHDIR"
-echo "$ACTIONS_DEPLOY_KEY" > "$SSHDIR/key"
-chmod 600 "$SSHDIR/key"
-export SERVER_DEPLOY_STRING="$SSH_USERNAME@$SERVER_ADDRESS:$SERVER_DESTINATION"
-cd "$GITHUB_WORKSPACE/app/outputs/"
-rsync -ahvcr --omit-dir-times --progress --delete --no-o --no-g -e "ssh -i $SSHDIR/key -o StrictHostKeyChecking=no -p $SSH_PORT" . "$SERVER_DEPLOY_STRING"
+LATEST_TAG="latest"
+CURRENT_REV="$(git rev-parse --short HEAD)"
+ASSET_DIRECTORY="${GITHUB_WORKSPACE}/app/outputs"
+
+function overwrite_local_tag() {
+ git tag -f "${LATEST_TAG}"
+}
+
+function overwrite_remote_tag() {
+ git push -f origin "${LATEST_TAG}"
+}
+
+function has_release() {
+ gh release view "${LATEST_TAG}"
+ echo "$?"
+}
+
+function delete_release() {
+ gh release delete --yes "${LATEST_TAG}"
+}
+
+function create_rev_file() {
+ pushd "${ASSET_DIRECTORY}"
+ echo "${CURRENT_REV}" | tee rev-hash.txt
+ popd
+}
+
+function create_release() {
+ local CHANGELOG_FILE
+ CHANGELOG_FILE="$(mktemp)"
+ echo "Latest release for APS from revision ${CURRENT_REV}" | tee "${CHANGELOG_FILE}"
+ pushd "${ASSET_DIRECTORY}"
+ gh release create --title "Latest snapshot build" -F "${CHANGELOG_FILE}" "${LATEST_TAG}" ./*
+ popd
+}
+
+overwrite_local_tag
+
+if [[ "$(has_release)" -eq 0 ]]; then
+ delete_release
+fi
+
+create_rev_file
+
+overwrite_remote_tag
+
+create_release