Follow-up fixes to snapshot deployment (#1768)

* scripts/deploy-snapshot: ensure GITHUB_WORKSPACE is set when script is run

* scripts/deploy-snapshot: prevent command output from breaking comparison

* scripts/deploy-snapshot: fix shellcheck nits

* gitignore: add outputs directory

* github: pass privileged token to deployment script
This commit is contained in:
Harsh Shandilya 2022-03-06 00:01:05 +05:30 committed by GitHub
parent 208e49e4d5
commit 47aecbca53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View file

@ -42,3 +42,5 @@ jobs:
- name: Deploy snapshot - name: Deploy snapshot
run: scripts/deploy-snapshot.sh run: scripts/deploy-snapshot.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

3
.gitignore vendored
View file

@ -153,3 +153,6 @@ fabric.properties
!/gradle/wrapper/gradle-wrapper.jar !/gradle/wrapper/gradle-wrapper.jar
# End of https://www.gitignore.io/api/androidstudio,gradle # End of https://www.gitignore.io/api/androidstudio,gradle
# Default output directory for APK and Bundle collection tasks
app/outputs

View file

@ -8,7 +8,7 @@ set -ex
LATEST_TAG="latest" LATEST_TAG="latest"
CURRENT_REV="$(git rev-parse --short HEAD)" CURRENT_REV="$(git rev-parse --short HEAD)"
ASSET_DIRECTORY="${GITHUB_WORKSPACE}/app/outputs" ASSET_DIRECTORY="${GITHUB_WORKSPACE:?}/app/outputs"
function overwrite_local_tag() { function overwrite_local_tag() {
git tag -f "${LATEST_TAG}" git tag -f "${LATEST_TAG}"
@ -19,7 +19,7 @@ function overwrite_remote_tag() {
} }
function has_release() { function has_release() {
gh release view "${LATEST_TAG}" gh release view "${LATEST_TAG}" &>/dev/null
echo "$?" echo "$?"
} }
@ -28,18 +28,18 @@ function delete_release() {
} }
function create_rev_file() { function create_rev_file() {
pushd "${ASSET_DIRECTORY}" pushd "${ASSET_DIRECTORY}" || return
echo "${CURRENT_REV}" | tee rev-hash.txt echo "${CURRENT_REV}" | tee rev-hash.txt
popd popd || return
} }
function create_release() { function create_release() {
local CHANGELOG_FILE local CHANGELOG_FILE
CHANGELOG_FILE="$(mktemp)" CHANGELOG_FILE="$(mktemp)"
echo "Latest release for APS from revision ${CURRENT_REV}" | tee "${CHANGELOG_FILE}" echo "Latest release for APS from revision ${CURRENT_REV}" | tee "${CHANGELOG_FILE}"
pushd "${ASSET_DIRECTORY}" pushd "${ASSET_DIRECTORY}" || return
gh release create --title "Latest snapshot build" -F "${CHANGELOG_FILE}" "${LATEST_TAG}" ./* gh release create --title "Latest snapshot build" -F "${CHANGELOG_FILE}" "${LATEST_TAG}" ./*
popd popd || return
} }
overwrite_local_tag overwrite_local_tag