From 97127afb541ae28ec53f46440bc082dfab465300 Mon Sep 17 00:00:00 2001 From: Jan Gosmann Date: Sat, 17 Feb 2024 15:35:03 +0100 Subject: [PATCH] Mark prereleases on Github --- .github/actions/check-prerelease/action.yml | 21 +++++++++++++++++++ .../check-prerelease/check_prerelease.py | 17 +++++++++++++++ .github/workflows/ci.yml | 7 +++++++ 3 files changed, 45 insertions(+) create mode 100644 .github/actions/check-prerelease/action.yml create mode 100755 .github/actions/check-prerelease/check_prerelease.py diff --git a/.github/actions/check-prerelease/action.yml b/.github/actions/check-prerelease/action.yml new file mode 100644 index 0000000..28beb1b --- /dev/null +++ b/.github/actions/check-prerelease/action.yml @@ -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 diff --git a/.github/actions/check-prerelease/check_prerelease.py b/.github/actions/check-prerelease/check_prerelease.py new file mode 100755 index 0000000..6ead58e --- /dev/null +++ b/.github/actions/check-prerelease/check_prerelease.py @@ -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") diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fd16e4..f9185f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }}