Skip to content

Commit b5ee8ba

Browse files
committed
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 <[email protected]>
1 parent 97f4883 commit b5ee8ba

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

.github/workflows/release-python.yml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ jobs:
2727
run: |
2828
git config --global --add safe.directory "$GITHUB_WORKSPACE"
2929
30+
- name: Check out specified tag
31+
if: ${{ github.event.inputs.tag != '' }}
32+
run: |
33+
git fetch --tags
34+
git checkout ${{ github.event.inputs.tag }}
35+
3036
- name: Build sdist
3137
run: |
3238
pipx run build --sdist
@@ -57,6 +63,12 @@ jobs:
5763
run: |
5864
git config --global --add safe.directory "$GITHUB_WORKSPACE"
5965
66+
- name: Check out specified tag
67+
if: ${{ github.event.inputs.tag != '' }}
68+
run: |
69+
git fetch --tags
70+
git checkout ${{ github.event.inputs.tag }}
71+
6072
- name: Compute dev version from git
6173
id: version
6274
run: |
@@ -113,14 +125,25 @@ jobs:
113125
environment: pypi
114126
permissions:
115127
id-token: write
116-
if: startsWith(github.ref, 'refs/tags/v') && github.repository == 'linux-nvme/libnvme'
128+
if: (startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch') && github.repository == 'linux-nvme/libnvme'
117129
steps:
118-
- name: Check if it is a release tag
119-
id: check-tag
130+
- name: Determine match status
131+
id: match
120132
run: |
121-
if [[ ${{ github.event.ref }} =~ ^refs/tags/v([0-9]+\.[0-9]+)(\.[0-9]+)?(-rc[0-9]+)?$ ]]; then
122-
echo ::set-output name=match::true
123-
fi
133+
VERSION=""
134+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
135+
VERSION="${{ github.event.inputs.tag }}"
136+
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
137+
VERSION="${GITHUB_REF##refs/tags/}"
138+
fi
139+
140+
if [[ "$VERSION" =~ ^v([0-9]+\.[0-9]+)(\.[0-9]+)?(-rc[0-9]+)?$ ]]; then
141+
echo "Tag version validated: $VERSION"
142+
echo "match=true" >> $GITHUB_OUTPUT
143+
else
144+
echo "Invalid or missing tag: $VERSION"
145+
echo "match=false" >> $GITHUB_OUTPUT
146+
fi
124147
125148
- name: Download artifiact
126149
uses: actions/download-artifact@v4

0 commit comments

Comments
 (0)