2022-03-05 17:35:20 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-03-09 09:15:27 +00:00
|
|
|
#
|
|
|
|
# Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#
|
|
|
|
|
2020-07-03 05:03:17 +00:00
|
|
|
set -ex
|
2019-12-15 21:49:18 +00:00
|
|
|
|
2022-03-05 17:35:20 +00:00
|
|
|
LATEST_TAG="latest"
|
|
|
|
CURRENT_REV="$(git rev-parse --short HEAD)"
|
2022-03-05 18:31:05 +00:00
|
|
|
ASSET_DIRECTORY="${GITHUB_WORKSPACE:?}/app/outputs"
|
2022-03-05 17:35:20 +00:00
|
|
|
|
|
|
|
function overwrite_local_tag() {
|
|
|
|
git tag -f "${LATEST_TAG}"
|
|
|
|
}
|
|
|
|
|
|
|
|
function overwrite_remote_tag() {
|
|
|
|
git push -f origin "${LATEST_TAG}"
|
|
|
|
}
|
|
|
|
|
|
|
|
function has_release() {
|
2022-11-24 19:50:13 +00:00
|
|
|
gh release view "${LATEST_TAG}"
|
2022-03-05 17:35:20 +00:00
|
|
|
echo "$?"
|
|
|
|
}
|
|
|
|
|
|
|
|
function delete_release() {
|
|
|
|
gh release delete --yes "${LATEST_TAG}"
|
|
|
|
}
|
|
|
|
|
|
|
|
function create_rev_file() {
|
2022-11-24 19:50:13 +00:00
|
|
|
pushd "${ASSET_DIRECTORY}" || exit 1
|
2022-03-05 17:35:20 +00:00
|
|
|
echo "${CURRENT_REV}" | tee rev-hash.txt
|
2022-11-24 19:50:13 +00:00
|
|
|
popd || exit 1
|
2022-03-05 17:35:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function create_release() {
|
|
|
|
local CHANGELOG_FILE
|
|
|
|
CHANGELOG_FILE="$(mktemp)"
|
2022-10-29 08:20:42 +00:00
|
|
|
cp scripts/snapshot-changelog-template.txt "${CHANGELOG_FILE}"
|
|
|
|
sed -i "s/__SNAPSHOT_REV__/${CURRENT_REV}/" "${CHANGELOG_FILE}"
|
2022-11-24 19:50:13 +00:00
|
|
|
pushd "${ASSET_DIRECTORY}" || exit 1
|
2022-03-06 16:49:44 +00:00
|
|
|
gh release create --prerelease --title "Latest snapshot build" --notes-file "${CHANGELOG_FILE}" "${LATEST_TAG}" ./*
|
2022-11-24 19:50:13 +00:00
|
|
|
popd || exit 1
|
2022-03-05 17:35:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
overwrite_local_tag
|
|
|
|
|
|
|
|
create_rev_file
|
|
|
|
|
|
|
|
overwrite_remote_tag
|
|
|
|
|
2022-11-24 19:50:13 +00:00
|
|
|
if [[ "$(has_release)" -eq 0 ]]; then
|
|
|
|
delete_release
|
|
|
|
fi
|
|
|
|
|
2022-03-05 17:35:20 +00:00
|
|
|
create_release
|