diff --git a/.gitignore b/.gitignore index 6a725d88..5e956cad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .dapper +.github-release bin/ dist/ diff --git a/Makefile b/Makefile index 615ab7be..f7514949 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -TARGETS := $(shell ls scripts | grep -vE 'clean|help') +TARGETS := $(shell ls scripts | grep -vE 'clean|help|release') .dapper: @echo Downloading dapper @@ -7,6 +7,13 @@ TARGETS := $(shell ls scripts | grep -vE 'clean|help') @./.dapper.tmp -v @mv .dapper.tmp .dapper +.github-release: + @echo Downloading github-release + @curl -sL https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2 | tar xjO > .github-release.tmp + @@chmod +x .github-release.tmp + @./.github-release.tmp -v + @mv .github-release.tmp .github-release + $(TARGETS): .dapper ./.dapper $@ @@ -16,6 +23,9 @@ clean: help: @./scripts/help +release: .github-release + ./scripts/release + .DEFAULT_GOAL := ci -.PHONY: .dapper $(TARGETS) clean help +.PHONY: .dapper $(TARGETS) clean help release diff --git a/scripts/release b/scripts/release new file mode 100755 index 00000000..1d130997 --- /dev/null +++ b/scripts/release @@ -0,0 +1,26 @@ +#!/bin/bash +set -e + +GITHUB_USER="kassisol" +REPO_NAME="hbm" + +function upload_file() { + local directory=$1 + + for file in $(ls ${directory}/); do + ./.github-release upload --user ${GITHUB_USER} --repo ${REPO_NAME} --tag ${VERSION} --file ${directory}/${file} --name ${file} + done +} + +source $(dirname $0)/version + +VERSION_OK=`echo ${VERSION} | grep -E "^[0-9]+\.[0-9]+\.[0-9]+$" | wc -l` +if [ $VERSION_OK -eq 0 ]; then + echo "Cannot release the version ${VERSION}" + exit 100 +fi + +./.github-release release --user ${GITHUB_USER} --repo ${REPO_NAME} --tag ${VERSION} --pre-release --draft + +upload_file "bin" +upload_file "dist"