-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcreate_release.sh
27 lines (23 loc) · 936 Bytes
/
create_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
#!/bin/bash
set -ex
export VERSION=$1
export RELEASE_NAME=`basename $GITHUB_REPO`
# Get release url
export RELEASE_URL=$(curl -H "Authorization: token $SECRET_TOKEN" https://api.github.com/repos/$GITHUB_REPO/releases/tags/$VERSION | grep \"url\" | grep releases | sed -e 's/.*\(https.*\)\"\,/\1/' | sed -e 's/api/uploads/')
# Build TF modules that require source building
function create_zip_file() {
BUILD_DIR=/tmp/${RELEASE_NAME}
DESTINATION_DIR=${PWD}/dist
rm -rf ${DESTINATION_DIR}
mkdir -p ${BUILD_DIR} ${DESTINATION_DIR}
cp *tf ${BUILD_DIR}
cd ${BUILD_DIR}
zip -r9 ${RELEASE_NAME}.zip .
mv ${RELEASE_NAME}.zip ${DESTINATION_DIR}/.
cd $DESTINATION_DIR
rm -rf ${BUILD_DIR}
}
# Release package
create_zip_file
# Post the release
curl -X POST -H "Authorization: token $SECRET_TOKEN" --data-binary "@${RELEASE_NAME}.zip" -H "Content-type: application/octet-stream" $RELEASE_URL/assets?name=${RELEASE_NAME}.zip