Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

[WIP] Add script to create release on github #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions ossrelease/github_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from github import Github
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this from PyGithub? Let's document that as a requirement/dependency somewhere.

That import should probably be moved to a separate # Import 3rd party libs line too, just to keep things organized. I know that is picky, but might as well start off that way :)

import argparse

# import ossrelease modules
import conf

def parse_args():
'''
Parse the CLI options.
'''
# Define parser and set up basic options
parser = argparse.ArgumentParser(description='Create a release on github.')
parser.add_argument('--salt-ver', help='Specify salt version to create release')

return parser.parse_args()

def main():
args = parse_args()
opts = conf.get_conf()

repo = Github(opts['GITHUB_TOKEN']).get_repo('saltstack/salt')

# create release
# todo: make sure the tag we are about to create a release for already exists
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is a first pass, but I'd like to see this kind of validation happen before this script is merged in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k i'll add the [WIP] for now until i can get to this again. might be a while.

msg = "WARNING: The tarball generated by GitHub will not have the correct version information when using a version not ending in .0 . Please use the tarball generated by SaltStack instead. See issue #41847 for more information."
repo.create_git_release(args.salt_ver, args.salt_ver, msg)
release = repo.get_release(id=args.salt_ver)

# todo: download pypi file
ver = args.salt_ver.split('v')[-1]
release.upload_asset('/tmp/salt-{0}.tar.gz'.format(ver))

# todo: add verification the release was created

if __name__ == '__main__':
main()