diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-10-17 18:53:14 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-18 20:46:01 -0700 |
commit | 2f1997fb3ab1469979b37b883933bd412904ff60 (patch) | |
tree | a64a50e643ba7fb8362cc70364573c12653f2fc0 /.github/actions | |
parent | aff54e17e5bb0642df2417014cb541ff0900a114 (diff) | |
download | subsurface-2f1997fb3ab1469979b37b883933bd412904ff60.tar.gz |
GitHub Actions: support creation of releases based on tags
And fix parsing of ref.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to '.github/actions')
-rwxr-xr-x | .github/actions/release/upload | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/.github/actions/release/upload b/.github/actions/release/upload index 1832eba3f..b9eda923a 100755 --- a/.github/actions/release/upload +++ b/.github/actions/release/upload @@ -24,12 +24,17 @@ fi TAG="ci-release" echo $REF -if [[ $REF = /refs/heads/* ]] ; then - branch="-$(cat $REF | cut -d/ -f 3)" - echo "it's /refs/heads with an added $branch" - if [[ $REF != /refs/heads/master ]] ; then - TAG=$TAG+$branch +if [[ $REF = refs/heads/* ]] ; then + branch="$(echo $REF | cut -d/ -f 3)" + body="CI build of branch $branch. These binaries are for testing purposes. They are not signed and installations on Mac and Android will create warnings and errors without some extra work." + branch="-$branch" + echo "it's refs/heads with an added $branch" + if [[ $REF != refs/heads/master ]] ; then + TAG="${TAG}${branch}" fi +elif [[ $REF = refs/tags/* ]] ; then + TAG=$(echo $REF | cut -d/ -f 3) + body="Release build ($TAG)" fi # check if there is a tag of that name @@ -37,12 +42,13 @@ fi tag_url="https://api.github.com/repos/$GITHUB_REPO/git/refs/tags/$TAG" release_url="https://api.github.com/repos/$GITHUB_REPO/releases/tags/$TAG" +echo "get tag infos: curl -XGET --header \"Authorization: token xxxx\" \"${tag_url}\"" tag_infos=$(curl -XGET --header "Authorization: token ${GITHUB_TOKEN}" "${tag_url}") echo "information received for tag $TAG" echo $tag_infos existing_tag_sha=$(echo $tag_infos | jq --raw-output .object.sha) -if [[ "$existing_tag_sha" != "" ]] ; then +if [[ "$existing_tag_sha" != "null" ]] ; then echo "existing tag on SHA $existing_tag_sha" existing_release=$(curl -XGET --header "Authorization: token ${GITHUB_TOKEN}" "${release_url}") release_id=$(echo $existing_release | jq --raw-output .id ) @@ -53,13 +59,13 @@ if [[ "$existing_tag_sha" != "" ]] ; then echo "tag was on different SHA, delete it and the corresponding release (if it exists)" echo "deleting tag $TAG" curl -XDELETE --header "Authorization: token ${GITHUB_TOKEN}" "${tag_url}" - if [[ "$release_id" != "" ]] ; then + if [[ "$release_id" != "null" ]] ; then echo "Delete the release $release_id" delete_url="https://api.github.com/repos/$GITHUB_REPO/releases/$release_id" curl -XDELETE --header "Authorization: token ${GITHUB_TOKEN}" "${delete_url}" fi echo "create a new release and implicitly a new tag" - release=$(curl -H "Authorization: token ${GITHUB_TOKEN}" --data '{"tag_name": "'"$TAG"'","target_commitish": "'"$COMMIT"'","name": "'"$TAG"'","body": "testing tag creation","draft": false,"prerelease": true}' "https://api.github.com/repos/$GITHUB_REPO/releases") + release=$(curl -H "Authorization: token ${GITHUB_TOKEN}" --data '{"tag_name": "'"$TAG"'","target_commitish": "'"$COMMIT"'","name": "'"$TAG"'","body": "'"$body"'","draft": false,"prerelease": true}' "https://api.github.com/repos/$GITHUB_REPO/releases") echo "response to release creation" echo "$release" fi |