summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-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