Skip to content

Release

Release #11

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
testpypi:
description: 'Release to TestPyPI then skip following'
default: 'false'
type: choice
options:
- 'true'
- 'false'
jobs:
build-release:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: read
runs-on: ubuntu-latest
# Use the oldest supported version to build, just in case there are issues
# for our case, this doesn't matter that much, since the build is for 3.x
strategy:
matrix:
include:
- py_ver: "3.9"
env:
PY_VER: ${{matrix.py_ver}}
TWINE_USERNAME: ${{secrets.twine_username}}
TWINE_PASSWORD: ${{secrets.twine_password}}
TWINE_TEST_USERNAME: ${{secrets.twine_test_username}}
TWINE_TEST_PASSWORD: ${{secrets.twine_test_password}}
TESTPYPI: ${{ github.event.inputs.testpypi }}
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- name: Draft release notes
id: create_gh_release
uses: release-drafter/release-drafter@v6
with:
config-name: release_drafter.yaml
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- name: Set up Python ${{matrix.py_ver}}
uses: actions/setup-python@v5
with:
python-version: ${{matrix.py_ver}}
# Merging build and release steps just for the simplicity,
# since datajoint-python doesn't have platform specific dependencies or binaries,
# and the build process is fairly fast, so removed upload/download artifacts
- name: Build package
id: build
run: |
python -m pip install build
python -m build .
echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV
echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
echo "NEW_VERSION=${{steps.create_gh_release.outputs.resolved_version}}" >> $GITHUB_ENV
# - name: Publish package
# run: |
# export HOST_UID=$(id -u)
# if [ "$TESTPYPI" == "true" ]; then
# LATEST_PYPI=$(curl -s https://test.pypi.org/pypi/datajoint/json | jq -r '.info.version')
# export TWINE_REPOSITORY="testpypi"
# export TWINE_USERNAME=${TWINE_TEST_USERNAME}
# export TWINE_PASSWORD=${TWINE_TEST_PASSWORD}
# else
# LATEST_PYPI=$(curl -s https://pypi.org/pypi/datajoint/json | jq -r '.info.version')
# export TWINE_REPOSITORY="pypi"
# fi
# # Check if the new version is different from the latest on PyPI, avoid re-uploading error
# if [ "$NEW_VERSION" != "$LATEST_PYPI" ]; then
# docker compose run --build --quiet-pull \
# -e TWINE_USERNAME=${TWINE_USERNAME} \
# -e TWINE_PASSWORD=${TWINE_PASSWORD} \
# -e TWINE_REPOSITORY=${TWINE_REPOSITORY} \
# app sh -c "pip install twine && python -m twine upload dist/*"
# else
# echo "::warning::Latest version $LATEST_PYPI on $TWINE_REPOSITORY is the new version $NEW_VERSION"
# fi
# Upload package as release assets
- name: Upload pip wheel asset to release
if: ${{ github.event.inputs.testpypi == 'false' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_gh_release.outputs.upload_url}}
asset_path: ${{env.DJ_WHEEL_PATH}}
asset_name: pip-datajoint-${{env.DJ_VERSION}}.whl
asset_content_type: application/zip
- name: Upload pip sdist asset to release
if: ${{ github.event.inputs.testpypi == 'false' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_gh_release.outputs.upload_url}}
asset_path: ${{env.DJ_SDIST_PATH}}
asset_name: pip-datajoint-${{env.DJ_VERSION}}.tar.gz
asset_content_type: application/gzip