Skip to content

Instantly share code, notes, and snippets.

@sparverius
Created August 25, 2019 06:04
Show Gist options
  • Save sparverius/4e68a5c37013b2864e38e907d45e2178 to your computer and use it in GitHub Desktop.
Save sparverius/4e68a5c37013b2864e38e907d45e2178 to your computer and use it in GitHub Desktop.
#!/bin/bash
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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment