Skip to content

Commit

Permalink
automated build and github release
Browse files Browse the repository at this point in the history
  • Loading branch information
adieuadieu committed Oct 21, 2017
1 parent cfbddd7 commit cb1ac30
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ RELEASE_TEMPLATE='{
"tag_name": "%s",
"name": "%s",
"prerelease": %s,
"draft": %s,
"body": %s
"draft": %s
}'

RELEASE_BODY=""

create_draft_release() {
# shellcheck disable=SC2034
local ouput
Expand All @@ -66,9 +67,6 @@ create_draft_release() {
then
RELEASE_ID=$(echo "$output" | jq -re '.id')
UPLOAD_URL_TEMPLATE=$(echo "$output" | jq -re '.upload_url')
else
echo "problem creating draft."
echo "$output"
fi
}

Expand All @@ -81,7 +79,20 @@ upload_release_asset() {
--header "Authorization: token $GITHUB_TOKEN" \
--header 'Content-Type: application/zip' \
--data-binary "@$1" \
"${UPLOAD_URL_TEMPLATE%\{*}?name=$2" \
"${UPLOAD_URL_TEMPLATE%\{*}?name=$2&label=$1" \
> /dev/null
}

update_release_body() {
# shellcheck disable=SC2059
curl \
--silent \
--fail \
--request PATCH \
--header "Authorization: token $GITHUB_TOKEN" \
--header 'Content-Type: application/json' \
--data "{\"body\":\"$RELEASE_BODY\"}" \
"https://api.github.com/repos/$GITHUB_ORG/$GITHUB_REPO/releases/$1" \
> /dev/null
}

Expand All @@ -98,7 +109,6 @@ publish_release() {
> /dev/null
}


echo "Creating draft release $TAG"
create_draft_release

Expand All @@ -107,25 +117,28 @@ cd packages/lambda/builds

for BUILD in */Dockerfile; do
BUILD_NAME="${BUILD%%/*}"
(
cd "$BUILD_NAME"

cd "$BUILD_NAME" || exit

VERSION=$(./latest.sh)
ZIPFILE=build/headless-$BUILD_NAME-$VERSION-amazonlinux-2017-03.zip
ZIPFILE=headless-$BUILD_NAME-$VERSION-amazonlinux-2017-03.zip

cd build/

if [ ! -f "$ZIPFILE" ]; then
echo "$BUILD_NAME version $VERSION has not been built. Building ..."
../../scripts/build-binaries.sh "$BUILD_NAME"
../../../scripts/build-binaries.sh "$BUILD_NAME"
fi

echo "Uploading $ZIPFILE"
echo "Uploading $ZIPFILE to GitHub"

upload_release_asset "$ZIPFILE" "headless-$BUILD_NAME-amazonlinux-2017-03.zip"

)
RELEASE_BODY="$RELEASE_BODY$BUILD_NAME $VERSION for amazonlinux:2017.03\n"
done

update_release_body "$RELEASE_ID"

# printf "Publishing release %s ... " "$TAG"
# echo "Publishing release $TAG ... "
# publish_release "$RELEASE_ID"
# echo 'done'

0 comments on commit cb1ac30

Please sign in to comment.