Skip to content

Commit 0174bd7

Browse files
author
Drew Yang
committed
fix: 🐛 improve testpypi logic
1 parent ab9d0b5 commit 0174bd7

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

.github/workflows/post_draft_release_published.yaml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ jobs:
3838
token: ${{ secrets.GITHUB_TOKEN }}
3939
# new release needs the updated version.py
4040
- name: Update version.py
41-
id: update_version
4241
run: |
4342
VERSION=$(echo "${{ github.event.release.name }}" | grep -oP '\d+\.\d+\.\d+')
4443
sed -i "s/^__version__ = .*/__version__ = \"$VERSION\"/" datajoint/version.py
@@ -68,31 +67,34 @@ jobs:
6867
echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
6968
echo "NEW_VERSION=${{github.event.release.resolved_version}}" >> $GITHUB_ENV
7069
- name: Publish package
70+
id: publish
7171
run: |
72-
# TODO - if test pypi or not
72+
RELEASE_NAME=${{ github.event.release.name }}
7373
export HOST_UID=$(id -u)
74-
if [ "$TESTPYPI" == "true" ]; then
74+
if [[ "$RELEASE_NAME" =~ ^Test ]]; then
7575
LATEST_PYPI=$(curl -s https://test.pypi.org/pypi/datajoint/json | jq -r '.info.version')
76+
echo "TEST_PYPI=true" >> $GITHUB_OUTPUT
7677
export TWINE_REPOSITORY="testpypi"
7778
export TWINE_USERNAME=${TWINE_TEST_USERNAME}
7879
export TWINE_PASSWORD=${TWINE_TEST_PASSWORD}
7980
else
8081
LATEST_PYPI=$(curl -s https://pypi.org/pypi/datajoint/json | jq -r '.info.version')
82+
echo "TEST_PYPI=false" >> $GITHUB_OUTPUT
8183
export TWINE_REPOSITORY="pypi"
8284
fi
8385
# Check if the new version is different from the latest on PyPI, avoid re-uploading error
8486
if [ "$NEW_VERSION" != "$LATEST_PYPI" ]; then
85-
docker compose run --build --quiet-pull \
86-
-e TWINE_USERNAME=${TWINE_USERNAME} \
87-
-e TWINE_PASSWORD=${TWINE_PASSWORD} \
88-
-e TWINE_REPOSITORY=${TWINE_REPOSITORY} \
89-
app sh -c "pip install twine && python -m twine upload dist/*"
87+
# docker compose run --build --quiet-pull \
88+
# -e TWINE_USERNAME=${TWINE_USERNAME} \
89+
# -e TWINE_PASSWORD=${TWINE_PASSWORD} \
90+
# -e TWINE_REPOSITORY=${TWINE_REPOSITORY} \
91+
# app sh -c "pip install twine && python -m twine upload dist/*"
92+
echo "Uploading to $TWINE_REPOSITORY"
9093
else
9194
echo "::warning::Latest version $LATEST_PYPI on $TWINE_REPOSITORY is the new version $NEW_VERSION"
9295
fi
9396
# Upload package as release assets
9497
- name: Upload pip wheel asset to release
95-
if: ${{ github.event.inputs.testpypi == 'false' }}
9698
uses: actions/upload-release-asset@v1
9799
env:
98100
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -102,7 +104,6 @@ jobs:
102104
asset_name: pip-datajoint-${{env.DJ_VERSION}}.whl
103105
asset_content_type: application/zip
104106
- name: Upload pip sdist asset to release
105-
if: ${{ github.event.inputs.testpypi == 'false' }}
106107
uses: actions/upload-release-asset@v1
107108
env:
108109
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -122,10 +123,8 @@ jobs:
122123
--base master \
123124
--head ${{ env.BRANCH_NAME }} \
124125
--reviewer dimitri-yatsenko,yambottle,ttngu207
125-
slack-notification:
126-
runs-on: ubuntu-latest
127-
steps:
128-
- name: Post a message in a channel
126+
- name: Post release notification to Slack
127+
if: ${{ steps.publish.outputs.TEST_PYPI == 'false' }}
129128
uses: slackapi/[email protected]
130129
with:
131130
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)