Move snapshot releases to GitHub (#1767)

This commit is contained in:
Harsh Shandilya 2022-03-05 23:05:20 +05:30
parent b8756a667c
commit 208e49e4d5
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
2 changed files with 50 additions and 14 deletions

View file

@ -11,6 +11,8 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3.0.0 uses: actions/checkout@v3.0.0
with:
fetch-depth: 0
- name: Set up JDK - name: Set up JDK
uses: actions/setup-java@v3.0.0 uses: actions/setup-java@v3.0.0
@ -40,9 +42,3 @@ jobs:
- name: Deploy snapshot - name: Deploy snapshot
run: scripts/deploy-snapshot.sh run: scripts/deploy-snapshot.sh
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SERVER_ADDRESS: ${{ secrets.SERVER_ADDRESS }}
SERVER_DESTINATION: ${{ secrets.SERVER_DESTINATION }}
SSH_PORT: ${{ secrets.SSH_PORT }}

View file

@ -1,4 +1,4 @@
#!/usr/bin/env sh #!/usr/bin/env bash
# #
# Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. # Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
# SPDX-License-Identifier: GPL-3.0-only # SPDX-License-Identifier: GPL-3.0-only
@ -6,10 +6,50 @@
set -ex set -ex
export SSHDIR="$HOME/.ssh" LATEST_TAG="latest"
mkdir -p "$SSHDIR" CURRENT_REV="$(git rev-parse --short HEAD)"
echo "$ACTIONS_DEPLOY_KEY" > "$SSHDIR/key" ASSET_DIRECTORY="${GITHUB_WORKSPACE}/app/outputs"
chmod 600 "$SSHDIR/key"
export SERVER_DEPLOY_STRING="$SSH_USERNAME@$SERVER_ADDRESS:$SERVER_DESTINATION" function overwrite_local_tag() {
cd "$GITHUB_WORKSPACE/app/outputs/" git tag -f "${LATEST_TAG}"
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" }
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