Skip to content

Instantly share code, notes, and snippets.

@gWOLF3
Last active November 26, 2020 20:39
Show Gist options
  • Save gWOLF3/dbe7a81c9ed6ffa99dfadee5595be1f0 to your computer and use it in GitHub Desktop.
Save gWOLF3/dbe7a81c9ed6ffa99dfadee5595be1f0 to your computer and use it in GitHub Desktop.

Revisions

  1. gWOLF3 renamed this gist Nov 26, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. gWOLF3 created this gist Nov 26, 2020.
    28 changes: 28 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/bin/bash

    # script credit: github user @dodotree

    version=$1
    text=$2
    branch=$(git rev-parse --abbrev-ref HEAD)
    repo_full_name=$(git config --get remote.origin.url | sed 's/.*:\/\/github.com\///;s/.git$//')
    token=$(git config --global github.token)

    generate_post_data()
    {
    cat <<EOF
    {
    "tag_name": "$version",
    "target_commitish": "$branch",
    "name": "$version",
    "body": "$text",
    "draft": false,
    "prerelease": false
    }
    EOF
    }

    echo "Create release $version for repo: $repo_full_name branch: $branch"
    curl --data "$(generate_post_data)" "https://api.github.com/repos/$repo_full_name/releases?access_token=$token"