forked from open-policy-agent/opa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub-release.sh
executable file
·53 lines (44 loc) · 1.42 KB
/
github-release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
# Script to draft and edit OPA GitHub releases. Assumes execution environment is Github Action runner.
set -x
usage() {
echo "github-release.sh [--asset-dir=<path>] [--tag=<git tag>]"
echo " Default --asset-dir is $PWD and --tag $TAG_NAME "
}
TAG_NAME=${TAG_NAME}
ASSET_DIR=${PWD:-"./"}
for i in "$@"; do
case $i in
--asset-dir=*)
ASSET_DIR="${i#*=}"
shift
;;
--tag=*)
TAG_NAME="${i#*=}"
shift
;;
*)
usage
exit 1
;;
esac
done
# Collect a list of opa binaries (expect binaries in the form: opa_<platform>_<arch>[extension])
ASSETS=()
for asset in "${ASSET_DIR}"/opa_*_*; do
ASSETS+=("$asset")
done
# Gather the release notes from the CHANGELOG for the latest version
RELEASE_NOTES="release-notes.md"
# The hub CLI expects the first line to be the title
echo -e "${TAG_NAME}\n" > "${RELEASE_NOTES}"
# Fill in the description
./build/latest-release-notes.sh --output="${RELEASE_NOTES}"
# Update or create a release on github
if gh release view "${TAG_NAME}" --repo open-policy-agent/opa > /dev/null; then
# Occurs when the tag is created via GitHub UI w/ a release
gh release upload "${TAG_NAME}" "${ASSETS[@]}" --repo open-policy-agent/opa
else
# Create a draft release
gh release create "${TAG_NAME}" "${ASSETS[@]}" -F ${RELEASE_NOTES} --draft --title "${TAG_NAME}" --repo open-policy-agent/opa
fi