forked from datajoint/datajoint-python
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (102 loc) · 4.24 KB
/
release.yaml
File metadata and controls
102 lines (102 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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