Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect whether version is prerelease #6

Merged
merged 1 commit into from
Dec 2, 2020
Merged

Conversation

MetRonnie
Copy link
Member

This can be used in the https://github.com/actions/create-release action

This can be used in the actions/create-release action
@MetRonnie MetRonnie self-assigned this Dec 1, 2020
@MetRonnie MetRonnie requested review from kinow and wxtim and removed request for oliver-sanders December 1, 2020 13:16
Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

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

Looks good to me. With the PRERELEASE defined we should be ready to use the create-release action. That'd be useful for the cylc-ui, where we release the packaged version via GitHub releases.

Thanks @MetRonnie !

@@ -21,3 +22,22 @@ runs:
exit 1
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
Copy link
Member

Choose a reason for hiding this comment

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

Don't remember if I had seen this way to set environment variables in GH actions. But good to learn/remember it 👍 https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable

Copy link
Member Author

Choose a reason for hiding this comment

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

They changed it last month or so due to a vulnerability in the old way of doing it

from packaging import version

ver = version.Version(os.environ['VERSION'])
is_pre = str(ver.is_prerelease).lower()
Copy link
Member

Choose a reason for hiding this comment

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

From the packaging docs

is_prereleaseA boolean value indicating whether this Version instance represents a prerelease and/or development release.

I believe it follows what's defined in PEP-440 for pre-releases:

X.YaN   # Alpha release
X.YbN   # Beta release
X.YrcN  # Release Candidate
X.Y     # Final release

So alpha, beta, and release candidates will be treated as pre-releases👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants