11name : Release
22on :
33 workflow_dispatch :
4+ inputs :
5+ testpypi :
6+ description : ' Release to TestPyPI then skip the rest'
7+ default : ' false'
8+ type : choice
9+ options :
10+ - ' true'
11+ - ' false'
412jobs :
513 build-release :
614 runs-on : ubuntu-latest
1220 PY_VER : ${{matrix.py_ver}}
1321 TWINE_USERNAME : ${{secrets.twine_username}}
1422 TWINE_PASSWORD : ${{secrets.twine_password}}
23+ TESTPYPI : ${{ github.event.inputs.testpypi }}
1524 steps :
1625 - uses : actions/checkout@v4
1726 - name : Set up Python ${{matrix.py_ver}}
@@ -30,15 +39,20 @@ jobs:
3039 - name : Publish package
3140 run : |
3241 export HOST_UID=$(id -u)
42+ [ "$TESTPYPI" == "true" ] && export TWINE_REPOSITORY="testpypi" || export TWINE_REPOSITORY="pypi"
3343 docker compose run --build --quiet-pull \
34- -e TWINE_USERNAME=${TWINE_USERNAME} -e TWINE_PASSWORD=${TWINE_PASSWORD} app \
35- sh -c "pip install twine && python -m twine upload dist/*"
44+ -e TWINE_USERNAME=${TWINE_USERNAME} \
45+ -e TWINE_PASSWORD=${TWINE_PASSWORD} \
46+ -e TWINE_REPOSITORY=${TWINE_REPOSITORY} \
47+ app sh -c "pip install twine && python -m twine upload dist/*"
3648 - name : Login to DockerHub
49+ if : ${{ github.event.inputs.testpypi == 'false' }}
3750 uses : docker/login-action@v3
3851 with :
3952 username : ${{secrets.docker_username}}
4053 password : ${{secrets.docker_password}}
4154 - name : Publish image
55+ if : ${{ github.event.inputs.testpypi == 'false' }}
4256 run : |
4357 IMAGE=$(docker images --filter "reference=datajoint/datajoint*" --format "{{.Repository}}")
4458 TAG=$(docker images --filter "reference=datajoint/datajoint*" --format "{{.Tag}}")
5165 || echo "skipping 'latest' tag..."
5266 # Make sure all above release targets are done first, then make a GH release
5367 - name : Make release notes
68+ if : ${{ github.event.inputs.testpypi == 'false' }}
5469 run : |
5570 DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)
5671 RELEASE_BODY=$(python -c \
6176 echo "$RELEASE_BODY" >> $GITHUB_ENV
6277 echo "EOF" >> $GITHUB_ENV
6378 - name : Create GH release
79+ if : ${{ github.event.inputs.testpypi == 'false' }}
6480 id : create_gh_release
6581 uses : actions/create-release@v1
6682 env :
7389 draft : false
7490 # Upload package as release assets
7591 - name : Upload pip wheel asset to release
92+ if : ${{ github.event.inputs.testpypi == 'false' }}
7693 uses : actions/upload-release-asset@v1
7794 env :
7895 GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
8299 asset_name : pip-datajoint-${{env.DJ_VERSION}}.whl
83100 asset_content_type : application/zip
84101 - name : Upload pip sdist asset to release
102+ if : ${{ github.event.inputs.testpypi == 'false' }}
85103 uses : actions/upload-release-asset@v1
86104 env :
87105 GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
92110 asset_content_type : application/gzip
93111 # only release docs when a release is published
94112 call-publish-docs :
113+ if : ${{ github.event.inputs.testpypi == 'false' }}
95114 needs : build-release
96115 runs-on : ubuntu-latest
97116 steps :
0 commit comments