Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
f6a3e5e1
Unverified
Commit
f6a3e5e1
authored
5 months ago
by
Erik Johnston
Committed by
GitHub
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix release script to check GH token (#17803)
The current logic didn't work.
parent
05576f0b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/17803.misc
+1
-0
1 addition, 0 deletions
changelog.d/17803.misc
scripts-dev/release.py
+23
-13
23 additions, 13 deletions
scripts-dev/release.py
with
24 additions
and
13 deletions
changelog.d/17803.misc
0 → 100644
+
1
−
0
View file @
f6a3e5e1
Test github token before running release script steps.
This diff is collapsed.
Click to expand it.
scripts-dev/release.py
+
23
−
13
View file @
f6a3e5e1
...
...
@@ -40,7 +40,7 @@ import commonmark
import
git
from
click.exceptions
import
ClickException
from
git
import
GitCommandError
,
Repo
from
github
import
Github
from
github
import
BadCredentialsException
,
Github
from
packaging
import
version
...
...
@@ -323,10 +323,8 @@ def tag(gh_token: Optional[str]) -> None:
def
_tag
(
gh_token
:
Optional
[
str
])
->
None
:
"""
Tags the release and generates a draft GitHub release
"""
if
gh_token
:
# Test that the GH Token is valid before continuing.
gh
=
Github
(
gh_token
)
gh
.
get_user
()
# Test that the GH Token is valid before continuing.
check_valid_gh_token
(
gh_token
)
# Make sure we're in a git repo.
repo
=
get_repo_and_check_clean_checkout
()
...
...
@@ -469,10 +467,8 @@ def upload(gh_token: Optional[str]) -> None:
def
_upload
(
gh_token
:
Optional
[
str
])
->
None
:
"""
Upload release to pypi.
"""
if
gh_token
:
# Test that the GH Token is valid before continuing.
gh
=
Github
(
gh_token
)
gh
.
get_user
()
# Test that the GH Token is valid before continuing.
check_valid_gh_token
(
gh_token
)
current_version
=
get_package_version
()
tag_name
=
f
"
v
{
current_version
}
"
...
...
@@ -569,10 +565,8 @@ def wait_for_actions(gh_token: Optional[str]) -> None:
def
_wait_for_actions
(
gh_token
:
Optional
[
str
])
->
None
:
if
gh_token
:
# Test that the GH Token is valid before continuing.
gh
=
Github
(
gh_token
)
gh
.
get_user
()
# Test that the GH Token is valid before continuing.
check_valid_gh_token
(
gh_token
)
# Find out the version and tag name.
current_version
=
get_package_version
()
...
...
@@ -806,6 +800,22 @@ def get_repo_and_check_clean_checkout(
return
repo
def
check_valid_gh_token
(
gh_token
:
Optional
[
str
])
->
None
:
"""
Check that a github token is valid, if supplied
"""
if
not
gh_token
:
# No github token supplied, so nothing to do.
return
try
:
gh
=
Github
(
gh_token
)
# We need to lookup name to trigger a request.
_name
=
gh
.
get_user
().
name
except
BadCredentialsException
as
e
:
raise
click
.
ClickException
(
f
"
Github credentials are bad:
{
e
}
"
)
def
find_ref
(
repo
:
git
.
Repo
,
ref_name
:
str
)
->
Optional
[
git
.
HEAD
]:
"""
Find the branch/ref, looking first locally then in the remote.
"""
if
ref_name
in
repo
.
references
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment