Compare commits
2 Commits
47006cd78f
...
e5c953b33d
Author | SHA1 | Date |
---|---|---|
dmitry.kirdyashkin | e5c953b33d | |
dmitry.kirdyashkin | cdd39a9e21 |
72
lib
72
lib
|
@ -1,72 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
function create-archive(){
|
|
||||||
mkdir release
|
|
||||||
envsubst < module.json.template > ./module.json
|
|
||||||
cp ./module.json ./src/module.json
|
|
||||||
zip -r -9 ./release/module.zip ./src/*
|
|
||||||
}
|
|
||||||
|
|
||||||
function create-commit(){
|
|
||||||
git add .
|
|
||||||
git commit -m 'update'
|
|
||||||
git push origin $DRONE_BRANCH
|
|
||||||
}
|
|
||||||
|
|
||||||
function create-release(){
|
|
||||||
# if [[ -z "${TAG}" ]]; then
|
|
||||||
# echo "TAG key is not set"
|
|
||||||
# exit
|
|
||||||
# fi
|
|
||||||
|
|
||||||
if [[ $1 == 'latest' ]]; then
|
|
||||||
echo "Deleting old latest release"
|
|
||||||
RELEASE_LIST=$(curl -X GET -Url https://gitea.kdiva.ru/api/v1/repos/modules/sc-items/releases)
|
|
||||||
LATEST_RELEASE_ID=$(jq -r '.[] | select(.tag_name=="latest") | .id' <<< $RELEASE_LIST)
|
|
||||||
delete-release $LATEST_RELEASE_ID
|
|
||||||
delete-tag
|
|
||||||
RELEASE_TAG="$1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
source ./vars
|
|
||||||
RESPONSE=$(curl \
|
|
||||||
-X 'POST' \
|
|
||||||
-Url "https://gitea.kdiva.ru/api/v1/repos/${DRONE_REPO}/releases" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-H 'Authorization: Bearer 10e4af53e553aacb905766512e36487492d61a66' \
|
|
||||||
-d '{
|
|
||||||
"draft": false,
|
|
||||||
"name": "'"release $RELEASE_TAG"'",
|
|
||||||
"prerelease": false,
|
|
||||||
"tag_name": "'"$RELEASE_TAG"'",
|
|
||||||
"target_commitish": "'"$COMMIT_SHA"'"
|
|
||||||
}')
|
|
||||||
}
|
|
||||||
|
|
||||||
function upload-attachments(){
|
|
||||||
RELEASE_ID=$(jq -r '.id' <<< $RESPONSE)
|
|
||||||
echo "RELEASE_ID is ${RELEASE_ID}"
|
|
||||||
curl \
|
|
||||||
-vv \
|
|
||||||
-X 'POST' \
|
|
||||||
-Url "https://gitea.kdiva.ru/api/v1/repos/${DRONE_REPO}/releases/${RELEASE_ID}/assets" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Content-Type: multipart/form-data' \
|
|
||||||
-H 'Authorization: Bearer 10e4af53e553aacb905766512e36487492d61a66' \
|
|
||||||
-F "attachment=@$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete-release(){
|
|
||||||
curl \
|
|
||||||
-X 'DELETE' \
|
|
||||||
-Url "https://gitea.kdiva.ru/api/v1/repos/${DRONE_REPO}/releases/${1}" \
|
|
||||||
-H 'Authorization: Bearer 10e4af53e553aacb905766512e36487492d61a66'
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete-tag(){
|
|
||||||
curl \
|
|
||||||
-X 'DELETE' \
|
|
||||||
-Url "https://gitea.kdiva.ru/api/v1/repos/${DRONE_REPO}/tags/latest" \
|
|
||||||
-H 'Authorization: Bearer 10e4af53e553aacb905766512e36487492d61a66'
|
|
||||||
}
|
|
Loading…
Reference in New Issue