Skip to content

Commit

Permalink
Mark prereleases on Github
Browse files Browse the repository at this point in the history
  • Loading branch information
jgosmann committed Feb 17, 2024
1 parent faf00e8 commit 97127af
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/actions/check-prerelease/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Checks whether a version is a prerelease
description: Checks whether a version is prerelease according to PEP440.
inputs:
version:
description: Version number to check.
required: true
outputs:
prerelease:
description: Whether the version number is a prerelease.
value: ${{ steps.check-prerelease.outputs.PRERELEASE }}
runs:
using: composite
steps:
- name: Install packaging
run: pip install packaging
shell: bash

- name: Check if prerelease
id: check-prerelease
run: ./.github/actions/check-prerelease/check_prerelease.py ${{ inputs.version }} >> "$GITHUB_OUTPUT"
shell: bash
17 changes: 17 additions & 0 deletions .github/actions/check-prerelease/check_prerelease.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3

import argparse

from packaging.version import parse as parse_version

if __name__ == "__main__":
arg_parser = argparse.ArgumentParser(
description="Check whether a version is a prerelease according to PEP440."
)
arg_parser.add_argument("version")
args = arg_parser.parse_args()

if parse_version(args.version).is_prerelease:
print("PRERELEASE=true")
else:
print("PRERELEASE=false")
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,18 @@ jobs:
with:
args: --standalone --wrap none -f rst -t gfm --output=release-body.md release-body.rst

- name: Check if prerelease
id: check-prerelease
uses: ./.github/actions/check-prerelease
with:
version: ${{ steps.version.outputs.version }}

- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
body_path: release-body.md
tag_name: v${{ steps.version.outputs.version }}
prerelease: ${{ steps.check-prerelease.outputs.prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down

0 comments on commit 97127af

Please sign in to comment.