Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix 3.0.3 #458

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

Closed
wants to merge 11 commits into from
Closed
197 changes: 197 additions & 0 deletions 197 .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
---
name: release

# Taken from arjancodes/bragir/.github/workflows/test.yaml@main

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+a|alpha.?[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+b|beta.?[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+dev.?[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+rc.?[0-9]+"

env:
PACKAGE_NAME: "semver"
OWNER: "python-semver"

jobs:
details:
runs-on: ubuntu-latest
# needs: unit-test
outputs:
new_version: ${{ steps.release.outputs.new_version }}
suffix: ${{ steps.release.outputs.suffix }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: actions/checkout@v2

- name: Extract tag and Details
id: release
run: |
echo "::notice::Extracting tag and new version"
if [ "${{ github.ref_type }}" = "tag" ]; then
TAG_NAME=${GITHUB_REF#refs/tags/}
NEW_VERSION=$(echo $TAG_NAME | awk -F'-' '{print $1}')
SUFFIX=$(echo $TAG_NAME | grep -oP '[a-z]+[0-9]+' || echo "")
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT"
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
echo "Version is $NEW_VERSION"
echo "Suffix is $SUFFIX"
echo "Tag name is $TAG_NAME"
else
echo "::error,line=43::No tag found"
exit 1
fi

check_pypi:
needs: details
runs-on: ubuntu-latest
steps:
- name: Fetch information from PyPI
run: |
response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo '{"releases": {"0.0.0": []}}' )
# We need to find the latest release in the "releases" key:
latest_previous_version=$(echo $response | jq -r '
.releases
| keys
| map(
split(".")
| map(select(test("^[0-9]+$")) | tonumber)
| .[0:3]
)
| sort_by(.[0], .[1], .[2])
| last
| join(".")
' )
# This is actually not really needed; if the curl command fails,
# it creates an artifical "0.0.0" release which is an error.
#if [ -z "$latest_previous_version" ]; then
# echo "Package not found on PyPI."
# latest_previous_version="0.0.0"
#fi
if [[ $latest_previous_version = "0.0.0" ]]; then
echo "::error::semver release cannot be 0.0.0. Package not found on PyPI"
exit 10
fi
echo "::notice::Latest version on PyPI: $latest_previous_version"
echo "latest_previous_version=$latest_previous_version" >> $GITHUB_ENV

- name: Compare versions and exit if not newer
run: |
NEW_VERSION=${{ needs.details.outputs.new_version }}
PREV_VERSION=$latest_previous_version
if [ "$(printf '%s\n' "$PREV_VERSION" "$NEW_VERSION" | sort -rV | head -n 1)" != "$NEW_VERSION" ] || [ "$NEW_VERSION" == "$PREV_VERSION" ]; then
echo "::error::[ERROR] The new version $NEW_VERSION is NOT greater than the latest version $PREV_VERSION on PyPI."
exit 1
else
echo "::notice::The new version $NEW_VERSION is greater than the latest version $PREV_VERSION on PyPI."
fi

setup_and_build:
needs: [details, check_pypi]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Bump version
run: |
NEW_VERSION="${{ needs.details.outputs.new_version }}"
sed -i "s/version = \"[0-9]*\.[0-9]*\.[0-9]*\"/version = \"$NEW_VERSION\"/" $GITHUB_WORKSPACE/pyproject.toml

- name: Install dependencies
run: uv sync

- name: Build source and wheel distribution
run: |
uv build

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

pypi_publish:
name: Upload release to PyPI
needs: [setup_and_build, details]
runs-on: ubuntu-latest
environment:
name: release
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Publish to PyPI
run: |
# See Settings > Environments > release
# https://github.com/python-semver/python-semver/settings/environments/5171753885/
uv publish --index testpypi \
--username ${{ vars.UV_PUBLISH_USERNAME }} \
--token ${{ secrets.UV_PUBLISH_TOKEN }}

github_release:
name: Create GitHub Release
needs: [setup_and_build, details]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch full history to avoid issues with tags and branches

- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: dist
path: dist/

- name: Create GitHub Release
id: create_release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{ needs.details.outputs.tag_name }} dist/* --title ${{ needs.details.outputs.tag_name }} --generate-notes


# bump_version:
# needs: [details, github_release, pypi_publish]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v3
# with:
# fetch-depth: 0 # Fetch full history to avoid issues with tags and branches

# - name: Bump version
# run: |
# NEW_VERSION="${{ needs.details.outputs.new_version }}"
# sed -i "s/version = \"[0-9]*\.[0-9]*\.[0-9]*\"/version = \"$NEW_VERSION\"/" $GITHUB_WORKSPACE/pyproject.toml

# #- uses: stefanzweifel/git-auto-commit-action@v5
# # with:
# # commit_message: Bumping version to ${{ needs.details.outputs.new_version }}
# # branch: bump-version-${{ needs.details.outputs.new_version }}
# # file_pattern: "pyproject.toml"
# # skip_dirty_check: true
# # create_branch: true
14 changes: 13 additions & 1 deletion 14 MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
include *.rst
include *.txt
include tests/test_*.py
include tests/*.py
include Makefile
include *.md
include changelog.d/*
include CITATION.cff
include tox.ini

# The dot files:
include .coveragerc
include .editorconfig
include .gitignore
include .readthedocs.yaml


prune docs/_build
recursive-exclude .github *
Expand Down
8 changes: 7 additions & 1 deletion 8 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ classifiers = [
"Environment :: Web Environment",
"Intended Audience :: Developers",
"Development Status :: 5 - Production/Stable",
# "License :: OSI Approved :: BSD License",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
Expand Down Expand Up @@ -131,6 +131,12 @@ version = {attr = "semver.__about__.__version__"}
version_scheme = "post-release"
local_scheme = "dirty-tag"

# ------------
[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/semver/"
publish-url = "https://test.pypi.org/legacy/"


[tool.mypy]
# ignore_missing_imports = true
Expand Down
2 changes: 1 addition & 1 deletion 2 src/semver/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""

#: Semver version
__version__ = "3.0.3"
__version__ = "3.0.4"

#: Original semver author
__author__ = "Kostiantyn Rybnikov"
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.