8000 Merge branch 'master' into contribusion.md · ttngu207/datajoint-python@fe6e638 · GitHub
[go: up one dir, main page]

Skip to content

Commit fe6e638

Browse files
Merge branch 'master' into contribusion.md
2 parents a76a9cb + ed6f5a9 commit fe6e638

File tree

10 files changed

+292
-134
lines changed

10 files changed

+292
-134
lines changed

.github/pr_labeler.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# https://github.com/actions/labeler
2+
breaking:
3+
- head-branch: ['breaking', 'BREAKING']
4+
bug:
5+
- head-branch: ['fix', 'FIX', 'bug', 'BUG']
6+
feature:
7+
- head-branch: ['feat', 'FEAT']
8+
documentation:
9+
- changed-files:
10+
- any-glob-to-any-file:
11+
- docs/**
12+
- images/**
13+
- README.md
14+
- CHANGELOG.md
15+
- CONTRIBUTING.md
16+
enhancement:
17+
- head-branch: ['enhance', 'improve', 'IMPR', 'DJEP']
18+
- changed-files:
19+
- any-glob-to-any-file:
20+
- '**'
21+
- '!docs/**'
22+
- '!images/**'
23+
- '!README.md'
24+
- '!CHANGELOG.md'
25+
- '!CONTRIBUTING.md'

.github/release_drafter.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version-resolver:
2+
major:
3+
labels:
4+
- 'breaking'
5+
minor:
6+
labels:
7+
- 'feature'
8+
patch:
9+
labels:
10+
- 'documentation'
11+
- 'enhancement'
12+
- 'bug'
13+
name-template: '$RESOLVED_VERSION'
14+
tag-template: 'v$RESOLVED_VERSION'
15+
categories:
16+
- title: '💥 Breaking Changes'
17+
labels:
18+
- 'breaking'
19+
- title: '🚀 Features'
20+
labels:
21+
- 'feature'
22+
- title: '⚡️ Enhancements'
23+
labels:
24+
- 'enhancement'
25+
- title: '🐛 Bug Fixes'
26+
labels:
27+
- 'bug'
28+
- title: '📝 Documentation'
29+
label: 'documentation'
30+
change-template: '- $TITLE(#$NUMBER)@$AUTHOR'
31+
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
32+
template: |
33+
$CHANGES
34+
35+
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION

.github/workflows/docs.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
name: Manual docs release
1+
name: Docs release
22
on:
3+
# manually trigger
34
workflow_dispatch:
5+
# been called by other workflows
46
workflow_call:
7+
58
jobs:
69
publish-docs:
710
runs-on: ubuntu-latest

.github/workflows/draft_release.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Manual Draft Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
testpypi:
6+
description: 'Release to TestPyPI then skip following'
7+
default: 'false'
8+
type: choice
9+
options:
10+
- 'true'
11+
- 'false'
12+
jobs:
13+
build-release:
14+
permissions:
15+
# write permission is required to create a github release
16+
contents: write
17+
# write permission is required for autolabeler
18+
# otherwise, read permission is required at least
19+
pull-requests: read
20+
runs-on: ubuntu-latest
21+
steps:
22+
# Drafts your next Release notes as Pull Requests are merged into "master"
23+
- name: Draft release notes
24+
id: create_gh_release
25+
uses: release-drafter/release-drafter@v6
26+
with:
27+
config-name: release_drafter.yaml
28+
disable-autolabeler: true
29+
name: ${{ github.event.inputs.testpypi == 'true' && 'Test $RESOLVED_VERSION' || 'Release $RESOLVED_VERSION' }}
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/label_prs.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# https://github.com/actions/labeler
2+
name: "Pull Request Labeler"
3+
on:
4+
- pull_request_target
5+
6+
jobs:
7+
labeler:
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/labeler@v5
14+
with:
15+
repo-token: ${{ secrets.GITHUB_TOKEN }}
16+
configuration-path: .github/pr_labeler.yaml
17+
sync-labels: true
18+
dot: true

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test
1+
name: Lint
22
on:
33
push:
44
branches:
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: Post Draft Release Published
2+
3+
on:
4+
# Once draft release is released, trigger the docs release
5+
release:
6+
types:
7+
## pre-release and stable release
8+
#- published
9+
## stable release only
10+
- released
11+
run-name: Post ${{ github.event.release.name }}
12+
13+
jobs:
14+
call-publish-docs:
15+
uses: ./.github/workflows/docs.yaml
16+
pypi-release:
17+
permissions:
18+
# write permission is required to update version.py
19+
contents: write
20+
pull-requests: write
21+
# Use the oldest supported version to build, just in case there are issues
22+
# for our case, this doesn't matter that much, since the build is for 3.x
23+
strategy:
24+
matrix:
25+
include:
26+
- py_ver: "3.9"
27+
runs-on: ubuntu-latest
28+
env:
29+
PY_VER: ${{matrix.py_ver}}
30+
TWINE_USERNAME: ${{secrets.twine_username}}
31+
TWINE_PASSWORD: ${{secrets.twine_password}}
32+
TWINE_TEST_USERNAME: ${{secrets.twine_test_username}}
33+
TWINE_TEST_PASSWORD: ${{secrets.twine_test_password}}
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
with:
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
# new release needs the updated version.py
40+
- name: Update version.py
41+
run: |
42+
VERSION=$(echo "${{ github.event.release.name }}" | grep -oP '\d+\.\d+\.\d+')
43+
sed -i "s/^__version__ = .*/__version__ = \"$VERSION\"/" datajoint/version.py
44+
cat datajoint/version.py
45+
# Commit the changes
46+
BRANCH_NAME="update-version-$VERSION"
47+
git switch -c $BRANCH_NAME
48+
git config --global user.name "github-actions"
49+
git config --global user.email "github-actions@github.com"
50+
git add datajoint/version.py
51+
git commit -m "Update version.py to $VERSION"
52+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
53+
- name: Update README.md badge
54+
run: |
55+
# commits since the last release
56+
NEW_HREF="https://github.com/datajoint/datajoint-python/compare/${{ github.event.release.tag_name }}...master"
57+
NEW_SRC="https://img.shields.io/github/commits-since/datajoint/datajoint-python/${{ github.event.release.tag_name }}?color=red"
58+
# Update href in the <a> tag
59+
sed -i 's|\(<a id="commit-since-release-link"[^>]*href="\)[^"]*\(".*\)|\1'"$NEW_HREF"'\2|' README.md
60+
# Update src in the <img> tag
61+
sed -i 's|\(<img id="commit-since-release-img"[^>]*src="\)[^"]*\(".*\)|\1'"$NEW_SRC"'\2|' README.md
62+
git add README.md
63+
git commit -m "Update README.md badge to ${{ github.event.release.tag_name }}"
64+
- name: Set up Python ${{matrix.py_ver}}
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: ${{matrix.py_ver}}
68+
# Merging build and release steps just for the simplicity,
69+
# since datajoint-python doesn't have platform specific dependencies or binaries,
70+
# and the build process is fairly fast, so removed upload/download artifacts
71+
- name: Build package
72+
id: build
73+
run: |
74+
python -m pip install build
75+
python -m build .
76+
echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV
77+
echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
78+
echo "NEW_VERSION=${{github.event.release.resolved_version}}" >> $GITHUB_ENV
79+
- name: Publish package
80+
id: publish
81+
env:
82+
RELEASE_NAME: ${{ github.event.release.name }}
83+
run: |
84+
export HOST_UID=$(id -u)
85+
if [[ "$RELEASE_NAME" =~ ^Test ]]; then
86+
LATEST_PYPI=$(curl -s https://test.pypi.org/pypi/datajoint/json | jq -r '.info.version')
87+
echo "TEST_PYPI=true" >> $GITHUB_ENV
88+
export TWINE_REPOSITORY="testpypi"
89+
export TWINE_USERNAME=${TWINE_TEST_USERNAME}
90+
export TWINE_PASSWORD=${TWINE_TEST_PASSWORD}
91+
else
92+
LATEST_PYPI=$(curl -s https://pypi.org/pypi/datajoint/json | jq -r '.info.version')
93+
echo "TEST_PYPI=false" >> $GITHUB_ENV
94+
export TWINE_REPOSITORY="pypi"
95+
fi
96+
# Check if the new version is different from the latest on PyPI, avoid re-uploading error
97+
if [ "$NEW_VERSION" != "$LATEST_PYPI" ]; then
98+
docker compose run --build --quiet-pull \
99+
-e TWINE_USERNAME=${TWINE_USERNAME} \
100+
-e TWINE_PASSWORD=${TWINE_PASSWORD} \
101+
-e TWINE_REPOSITORY=${TWINE_REPOSITORY} \
102+
app sh -c "pip install twine && python -m twine upload dist/*"
103+
else
104+
echo "::warning::Latest version $LATEST_PYPI on $TWINE_REPOSITORY is the new version $NEW_VERSION"
105+
fi
106+
# Upload package as release assets
107+
- name: Upload pip wheel asset to release
108+
uses: actions/upload-release-asset@v1
109+
env:
110+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
111+
with:
112+
upload_url: ${{github.event.release.upload_url}}
113+
asset_path: ${{env.DJ_WHEEL_PATH}}
114+
asset_name: pip-datajoint-${{ github.event.release.tag_name }}.whl
115+
asset_content_type: application/zip
116+
- name: Upload pip sdist asset to release
117+
uses: actions/upload-release-asset@v1
118+
env:
119+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
120+
with:
121+
upload_url: ${{github.event.release.upload_url}}
122+
asset_path: ${{env.DJ_SDIST_PATH}}
123+
asset_name: pip-datajoint-${{ github.event.release.tag_name }}.tar.gz
124+
asset_content_type: application/gzip
125+
- name: Create Pull Request
126+
env:
127+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
run: |
129+
git push origin ${{ env.BRANCH_NAME }}
130+
gh pr create \
131+
--title "[github-actions]Update version.py to ${{ github.event.release.name }}" \
132+
--body "This PR updates \`version.py\` to match the latest release: ${{ github.event.release.name }}" \
133+
--base master \
134+
--head ${{ env.BRANCH_NAME }} \
135+
--reviewer dimitri-yatsenko,yambottle,ttngu207
136+
- name: Post release notification to Slack
137+
if: ${{ env.TEST_PYPI == 'false' }}
138+
uses: slackapi/slack-github-action@v2.0.0
139+
with:
140+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
141+
webhook-type: incoming-webhook
142+
payload: |
143+
{
144+
"text": "*New Release Published!* :tada: \n*Repository:* ${{ github.repository }}\n*Version:* ${{ github.event.release.tag_name }}\n*URL:* ${{ github.event.release.html_url }}",
145+
"blocks": [
146+
{
147+
"type": "section",
148+
"text": {
149+
"type": "mrkdwn",
150+
"text": "*New Release Published!* :tada:\n*Repository:* ${{ github.repository }}\n*Version:* ${{ github.event.release.tag_name }}\n*URL:* <${{ github.event.release.html_url }}|View Release>"
151+
}
152+
}
153+
]
154+
}

0 commit comments

Comments
 (0)
0