From b5ee8ba8275059cf92e3c74b2690f33d2a5bb60c Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 24 Apr 2025 17:28:25 +0200 Subject: [PATCH 1/2] build: add feature to upload historic Python releases Sometime the upload failed to PyPi to permission issues or network issues. Thus add a feature to upload historic releases to PyPi. Signed-off-by: Daniel Wagner --- .github/workflows/release-python.yml | 35 +++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 9a1114f0a..d12cae45d 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -27,6 +27,12 @@ jobs: run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" + - name: Check out specified tag + if: ${{ github.event.inputs.tag != '' }} + run: | + git fetch --tags + git checkout ${{ github.event.inputs.tag }} + - name: Build sdist run: | pipx run build --sdist @@ -57,6 +63,12 @@ jobs: run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" + - name: Check out specified tag + if: ${{ github.event.inputs.tag != '' }} + run: | + git fetch --tags + git checkout ${{ github.event.inputs.tag }} + - name: Compute dev version from git id: version run: | @@ -113,14 +125,25 @@ jobs: environment: pypi permissions: id-token: write - if: startsWith(github.ref, 'refs/tags/v') && github.repository == 'linux-nvme/libnvme' + if: (startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch') && github.repository == 'linux-nvme/libnvme' steps: - - name: Check if it is a release tag - id: check-tag + - name: Determine match status + id: match run: | - if [[ ${{ github.event.ref }} =~ ^refs/tags/v([0-9]+\.[0-9]+)(\.[0-9]+)?(-rc[0-9]+)?$ ]]; then - echo ::set-output name=match::true - fi + VERSION="" + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + VERSION="${{ github.event.inputs.tag }}" + elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then + VERSION="${GITHUB_REF##refs/tags/}" + fi + + if [[ "$VERSION" =~ ^v([0-9]+\.[0-9]+)(\.[0-9]+)?(-rc[0-9]+)?$ ]]; then + echo "Tag version validated: $VERSION" + echo "match=true" >> $GITHUB_OUTPUT + else + echo "Invalid or missing tag: $VERSION" + echo "match=false" >> $GITHUB_OUTPUT + fi - name: Download artifiact uses: actions/download-artifact@v4 From 0930a598e1d62b72e0ed14c33aabb755aed16e9d Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 24 Apr 2025 17:45:59 +0200 Subject: [PATCH 2/2] build: don't append dev0 for tag builds src/meson.build:51:10: ERROR: library keyword argument "version" Invalid Shared library version "1.12.dev0". Must be of the form X.Y.Z where all three are numbers. Y and Z are optional. Signed-off-by: Daniel Wagner --- .github/workflows/release-python.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index d12cae45d..97d60ee09 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -75,7 +75,14 @@ jobs: TAG=$(git describe --tags --abbrev=0) REV=$(git rev-list "$TAG"..HEAD --count) BASE_VERSION="${TAG#v}" - VERSION="${BASE_VERSION}.dev${REV}" + + # Check if REV is 0, and don't append '.dev' if so + if [ "$REV" -eq 0 ]; then + VERSION="${BASE_VERSION}" + else + VERSION="${BASE_VERSION}.dev${REV}" + fi + echo "dev_version=$VERSION" >> $GITHUB_OUTPUT echo "Computed dev version: $VERSION"