Skip to content

Commit bf0f363

Browse files
author
Drew Yang
committed
fix: 🐛 improve testpypi flow
1 parent 1638764 commit bf0f363

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

.github/release_drafter.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ version-resolver:
1010
- 'documentation'
1111
- 'enhancement'
1212
- 'bug'
13-
name-template: 'Release $RESOLVED_VERSION'
13+
name-template: '$RESOLVED_VERSION'
1414
tag-template: 'v$RESOLVED_VERSION'
1515
categories:
1616
- title: '💥 Breaking Changes'

.github/workflows/draft_release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ jobs:
2626
with:
2727
config-name: release_drafter.yaml
2828
disable-autolabeler: true
29-
name: ${{ github.event.inputs.testpypi == 'true' && 'test' || github.event.release.name }}
29+
name: ${{ github.event.inputs.testpypi == 'true' && 'Test $RESOLVED_VERSION' || 'Release $RESOLVED_VERSION' }}
3030
env:
3131
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/post_draft_release_published.yaml

Lines changed: 14 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,35 @@ 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
71+
env:
72+
RELEASE_NAME: ${{ github.event.release.name }}
7173
run: |
72-
# TODO - if test pypi or not
7374
export HOST_UID=$(id -u)
74-
if [ "$TESTPYPI" == "true" ]; then
75+
if [[ "$RELEASE_NAME" =~ ^Test ]]; then
7576
LATEST_PYPI=$(curl -s https://test.pypi.org/pypi/datajoint/json | jq -r '.info.version')
77+
echo "TEST_PYPI=true" >> $GITHUB_ENV
7678
export TWINE_REPOSITORY="testpypi"
7779
export TWINE_USERNAME=${TWINE_TEST_USERNAME}
7880
export TWINE_PASSWORD=${TWINE_TEST_PASSWORD}
7981
else
8082
LATEST_PYPI=$(curl -s https://pypi.org/pypi/datajoint/json | jq -r '.info.version')
83+
echo "TEST_PYPI=false" >> $GITHUB_ENV
8184
export TWINE_REPOSITORY="pypi"
8285
fi
8386
# Check if the new version is different from the latest on PyPI, avoid re-uploading error
8487
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/*"
88+
# docker compose run --build --quiet-pull \
89+
# -e TWINE_USERNAME=${TWINE_USERNAME} \
90+
# -e TWINE_PASSWORD=${TWINE_PASSWORD} \
91+
# -e TWINE_REPOSITORY=${TWINE_REPOSITORY} \
92+
# app sh -c "pip install twine && python -m twine upload dist/*"
93+
echo "Uploading to $TWINE_REPOSITORY"
9094
else
9195
echo "::warning::Latest version $LATEST_PYPI on $TWINE_REPOSITORY is the new version $NEW_VERSION"
9296
fi
9397
# Upload package as release assets
9498
- name: Upload pip wheel asset to release
95-
if: ${{ github.event.inputs.testpypi == 'false' }}
9699
uses: actions/upload-release-asset@v1
97100
env:
98101
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -102,7 +105,6 @@ jobs:
102105
asset_name: pip-datajoint-${{env.DJ_VERSION}}.whl
103106
asset_content_type: application/zip
104107
- name: Upload pip sdist asset to release
105-
if: ${{ github.event.inputs.testpypi == 'false' }}
106108
uses: actions/upload-release-asset@v1
107109
env:
108110
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -122,10 +124,8 @@ jobs:
122124
--base master \
123125
--head ${{ env.BRANCH_NAME }} \
124126
--reviewer dimitri-yatsenko,yambottle,ttngu207
125-
slack-notification:
126-
runs-on: ubuntu-latest
127-
steps:
128-
- name: Post a message in a channel
127+
- name: Post release notification to Slack
128+
if: ${{ env.TEST_PYPI == 'false' }}
129129
uses: slackapi/[email protected]
130130
with:
131131
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)