Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 37 additions & 7 deletions .github/workflows/release-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -57,13 +63,26 @@ 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: |
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"

Expand Down Expand Up @@ -113,14 +132,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
Expand Down