Skip to content

Commit dbc23c7

Browse files
authored
Merge pull request #1586 from Sage-Bionetworks/schematic-246
[schematic-246]: Ensure unique version number when releasing to test pypi
2 parents caac2f7 + a58edb5 commit dbc23c7

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

.github/workflows/publish.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,36 @@ jobs:
1616
- uses: actions/setup-python@v5
1717
with:
1818
python-version: ${{ env.PYTHON_VERSION }}
19+
20+
- name: set-release-env
21+
shell: bash
22+
run: |
23+
RELEASE_TAG="${{ github.event.release.tag_name }}"
24+
if [[ $RELEASE_TAG =~ ^v?([[:digit:]\.]+)(-rc)? ]]; then
25+
VERSION="${BASH_REMATCH[1]}"
26+
if [[ "${{ github.event.release.prerelease}}" == "true" ]]; then
27+
if [[ -z "${BASH_REMATCH[2]}" ]]; then
28+
echo "A test release tag should end with \"-rc\""
29+
exit 1
30+
fi
31+
32+
# for staging builds we append the build number so we have
33+
# distinct version numbers between prod and test pypi.
34+
VERSION="$VERSION.$GITHUB_RUN_NUMBER"
35+
fi
36+
37+
else
38+
echo "Unable to parse deployment version from $RELEASE_TAG"
39+
exit 1
40+
fi
41+
42+
echo "VERSION=$VERSION" >> $GITHUB_ENV
43+
44+
- id: update-version-number-in-toml
45+
if: ${{ github.event.release.prerelease == true }}
46+
run: |
47+
sed -i '/^\[tool.poetry\]/,/^\[/{s/version = ".*"/version = "'"$VERSION"'"/}' pyproject.toml
48+
1949
- id: build-package
2050
run: |
2151
python3 -m pip install --upgrade pip
@@ -25,7 +55,6 @@ jobs:
2555
python3 -m pip install .
2656
python3 -m build
2757
28-
VERSION=${{ github.event.release.tag_name }}
2958
SDIST_PACKAGE_NAME="schematicpy-${VERSION}.tar.gz"
3059
BDIST_PACKAGE_NAME="schematicpy-${VERSION}-py3-none-any.whl"
3160
RELEASE_URL_PREFIX="https://uploads.github.com/repos/${{ github.event.repository.full_name }}/releases/${{ github.event.release.id }}/assets?name="
@@ -40,14 +69,14 @@ jobs:
4069
uses: actions/upload-artifact@v4
4170
with:
4271
name: ${{ steps.build-package.outputs.sdist-package-name }}
43-
path: dist/
72+
path: dist/${{ steps.build-package.outputs.sdist-package-name }}
4473
if-no-files-found: error
4574

4675
- name: upload-bdist-artifact
4776
uses: actions/upload-artifact@v4
4877
with:
4978
name: ${{ steps.build-package.outputs.bdist-package-name }}
50-
path: dist/
79+
path: dist/${{ steps.build-package.outputs.bdist-package-name }}
5180
if-no-files-found: error
5281

5382
publish:

0 commit comments

Comments
 (0)