@@ -2,60 +2,55 @@ name: Release
22on :
33 workflow_dispatch :
44jobs :
5- build :
6- runs-on : ubuntu-latest
7- strategy :
8- matrix :
9- include :
10- - py_ver : ["3.9", "3.10", "3.11", "3.12", "3.13"]
11- env :
12- PY_VER : ${{matrix.py_ver}}
13- steps :
14- - uses : actions/checkout@v4
15- - uses : actions/setup-python@v5
16- with :
17- python-version : ${{matrix.py_ver}}
18- - name : Build pip artifacts
19- run : |
20- DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)
21- echo "DJ_VERSION=${DJ_VERSION}" >> $GITHUB_ENV
22- python3 -m pip install build
23- python3 -m build .
24- - name : Add pip artifacts
25- uses : actions/upload-artifact@v4
26- with :
27- name : pip-datajoint-${{env.DJ_VERSION}}
28- path : dist
29- retention-days : 1
30- publish-release :
31- if : |
32- github.event_name == 'push' &&
33- startsWith(github.ref, 'refs/tags')
34- needs : build
5+ build-release :
356 runs-on : ubuntu-latest
367 strategy :
378 matrix :
389 include :
3910 - py_ver : " 3.9"
40- distro : debian
41- image : djbase
4211 env :
4312 PY_VER : ${{matrix.py_ver}}
44- DISTRO : ${{matrix.distro}}
45- IMAGE : ${{matrix.image}}
4613 TWINE_USERNAME : ${{secrets.twine_username}}
4714 TWINE_PASSWORD : ${{secrets.twine_password}}
48- DOCKER_CLIENT_TIMEOUT : " 120"
49- COMPOSE_HTTP_TIMEOUT : " 120"
50- outputs :
51- release_upload_url : ${{steps.create_gh_release.outputs.upload_url}}
5215 steps :
5316 - uses : actions/checkout@v4
5417 - name : Set up Python ${{matrix.py_ver}}
5518 uses : actions/setup-python@v5
5619 with :
5720 python-version : ${{matrix.py_ver}}
58- - name : Determine package version
21+ # Merging build and release steps just for the simplicity,
22+ # since datajoint-python doesn't have platform specific dependencies or binaries,
23+ # and the build process is fairly fast, so removed upload/download artifacts
24+ - name : Build package
25+ run : |
26+ python -m pip install build
27+ python -m build .
28+ echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV
29+ echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
30+ - name : Publish package
31+ run : |
32+ export HOST_UID=$(id -u)
33+ 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/*"
36+ - name : Login to DockerHub
37+ uses : docker/login-action@v3
38+ with :
39+ username : ${{secrets.docker_username}}
40+ password : ${{secrets.docker_password}}
41+ - name : Publish image
42+ run : |
43+ IMAGE=$(docker images --filter "reference=datajoint/datajoint*" --format "{{.Repository}}")
44+ TAG=$(docker images --filter "reference=datajoint/datajoint*" --format "{{.Tag}}")
45+ docker push "${IMAGE}:${TAG}"
46+ docker tag "${IMAGE}:${TAG}" "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
47+ docker push "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
48+ [ "$PY_VER" == "3.9" ] && [ "$DISTRO" == "debian" ] \
49+ && docker tag "${IMAGE}:${TAG}" "${IMAGE}:latest" \
50+ && docker push "${IMAGE}:latest" \
51+ || echo "skipping 'latest' tag..."
52+ # Make sure all above release targets are done first, then make a GH release
53+ - name : Make release notes
5954 run : |
6055 DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)
6156 RELEASE_BODY=$(python -c \
7671 body : ${{env.RELEASE_BODY}}
7772 prerelease : false
7873 draft : false
79- - name : Fetch pip artifacts
80- uses : actions/download-artifact@v4
81- with :
82- name : pip-datajoint-${{env.DJ_VERSION}}
83- path : dist
84- - name : Determine pip artifact paths
85- run : |
86- echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV
87- echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
74+ # Upload package as release assets
8875 - name : Upload pip wheel asset to release
8976 uses : actions/upload-release-asset@v1
9077 env :
@@ -103,34 +90,9 @@ jobs:
10390 asset_path : ${{env.DJ_SDIST_PATH}}
10491 asset_name : pip-datajoint-${{env.DJ_VERSION}}.tar.gz
10592 asset_content_type : application/gzip
106- - name : Publish pip release
107- run : |
108- export HOST_UID=$(id -u)
109- docker compose run --build --quiet-pull \
110- -e TWINE_USERNAME=${TWINE_USERNAME} -e TWINE_PASSWORD=${TWINE_PASSWORD} app \
111- sh -c "pip install twine && python -m twine upload dist/*"
112- - name : Login to DockerHub
113- uses : docker/login-action@v3
114- with :
115- username : ${{secrets.docker_username}}
116- password : ${{secrets.docker_password}}
117- - name : Publish image
118- run : |
119- IMAGE=$(docker images --filter "reference=datajoint/datajoint*" --format "{{.Repository}}")
120- TAG=$(docker images --filter "reference=datajoint/datajoint*" --format "{{.Tag}}")
121- docker push "${IMAGE}:${TAG}"
122- docker tag "${IMAGE}:${TAG}" "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
123- docker push "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
124- [ "$PY_VER" == "3.9" ] && [ "$DISTRO" == "debian" ] \
125- && docker tag "${IMAGE}:${TAG}" "${IMAGE}:latest" \
126- && docker push "${IMAGE}:latest" \
127- || echo "skipping 'latest' tag..."
12893 # only release docs when a release is published
12994 call-publish-docs :
130- if : |
131- github.event_name == 'push' &&
132- startsWith(github.ref, 'refs/tags')
133- needs : publish-release
95+ needs : build-release
13496 runs-on : ubuntu-latest
13597 steps :
13698 - uses : ./.github/workflows/docs.yaml
0 commit comments