Skip to content

Commit e7c10f8

Browse files
author
Drew Yang
committed
feat: ✨ release flow is ready
1 parent b7a202f commit e7c10f8

File tree

5 files changed

+81
-50
lines changed

5 files changed

+81
-50
lines changed

.github/pr_labeler.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# https://github.com/actions/labeler
2+
breaking:
3+
- head-branch: ['breaking', 'BREAKING']
24
bug:
35
- head-branch: ['fix', 'FIX', 'bug', 'BUG']
4-
enhancement:
5-
- head-branch: ['feat', 'FEAT', 'enhance', 'improve', 'IMPR', 'DJEP']
6+
feature:
7+
- head-branch: ['feat', 'FEAT']
68
documentation:
79
- changed-files:
810
- any-glob-to-any-file:
@@ -12,6 +14,8 @@ documentation:
1214
- CHANGELOG.md
1315
- CONTRIBUTING.md
1416
enhancement:
17+
- head-branch: ['enhance', 'improve', 'IMPR', 'DJEP']
18+
enhancement:
1519
- changed-files:
1620
- any-glob-to-any-file:
1721
- '**'

.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: 'Release $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: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
name: Manual docs release
1+
name: Docs release
22
on:
3+
# manually trigger
34
workflow_dispatch:
4-
workflow_call:
5+
# Once draft release is released, trigger the docs release
6+
release:
7+
types:
8+
## pre-release and stable release
9+
#- published
10+
## stable release only
11+
- released
512
jobs:
613
publish-docs:
714
runs-on: ubuntu-latest

.github/workflows/release.yaml

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ on:
1111
- 'false'
1212
jobs:
1313
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
1420
runs-on: ubuntu-latest
1521
# Use the oldest supported version to build, just in case there are issues
1622
# for our case, this doesn't matter that much, since the build is for 3.x
@@ -35,11 +41,13 @@ jobs:
3541
# since datajoint-python doesn't have platform specific dependencies or binaries,
3642
# and the build process is fairly fast, so removed upload/download artifacts
3743
- name: Build package
44+
id: build
3845
run: |
3946
python -m pip install build
4047
python -m build .
4148
echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV
4249
echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
50+
echo "DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)" >> $GITHUB_OUTPUT
4351
- name: Publish package
4452
run: |
4553
export HOST_UID=$(id -u)
@@ -55,48 +63,16 @@ jobs:
5563
-e TWINE_PASSWORD=${TWINE_PASSWORD} \
5664
-e TWINE_REPOSITORY=${TWINE_REPOSITORY} \
5765
app sh -c "pip install twine && python -m twine upload dist/*"
58-
- name: Login to DockerHub
66+
# Drafts your next Release notes as Pull Requests are merged into "master"
67+
- name: Draft release notes
68+
id: create_gh_release
69+
uses: release-drafter/release-drafter@v6
5970
if: ${{ github.event.inputs.testpypi == 'false' }}
60-
uses: docker/login-action@v3
6171
with:
62-
username: ${{secrets.docker_username}}
63-
password: ${{secrets.docker_password}}
64-
- name: Publish image
65-
if: ${{ github.event.inputs.testpypi == 'false' }}
66-
run: |
67-
IMAGE=$(docker images --filter "reference=datajoint/datajoint*" --format "{{.Repository}}")
68-
TAG=$(docker images --filter "reference=datajoint/datajoint*" --format "{{.Tag}}")
69-
docker push "${IMAGE}:${TAG}"
70-
docker tag "${IMAGE}:${TAG}" "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
71-
docker push "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
72-
[ "$PY_VER" == "3.9" ] && [ "$DISTRO" == "debian" ] \
73-
&& docker tag "${IMAGE}:${TAG}" "${IMAGE}:latest" \
74-
&& docker push "${IMAGE}:latest" \
75-
|| echo "skipping 'latest' tag..."
76-
# Make sure all above release targets are done first, then make a GH release
77-
- name: Make release notes
78-
if: ${{ github.event.inputs.testpypi == 'false' }}
79-
run: |
80-
DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)
81-
RELEASE_BODY=$(python -c \
82-
'print(open("./CHANGELOG.md").read().split("\n\n")[1].split("\n", 1)[1])' \
83-
)
84-
echo "DJ_VERSION=${DJ_VERSION}" >> $GITHUB_ENV
85-
echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV
86-
echo "$RELEASE_BODY" >> $GITHUB_ENV
87-
echo "EOF" >> $GITHUB_ENV
88-
- name: Create GH release
89-
if: ${{ github.event.inputs.testpypi == 'false' }}
90-
id: create_gh_release
91-
uses: actions/create-release@v1
72+
config-name: release_drafter.yaml
73+
disable-autolabeler: true
9274
env:
93-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
94-
with:
95-
tag_name: ${{env.DJ_VERSION}}
96-
release_name: Release ${{env.DJ_VERSION}}
97-
body: ${{env.RELEASE_BODY}}
98-
prerelease: false
99-
draft: false
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10076
# Upload package as release assets
10177
- name: Upload pip wheel asset to release
10278
if: ${{ github.event.inputs.testpypi == 'false' }}
@@ -118,10 +94,3 @@ jobs:
11894
asset_path: ${{env.DJ_SDIST_PATH}}
11995
asset_name: pip-datajoint-${{env.DJ_VERSION}}.tar.gz
12096
asset_content_type: application/gzip
121-
# only release docs when a release is published
122-
call-publish-docs:
123-
if: ${{ github.event.inputs.testpypi == 'false' }}
124-
needs: build-release
125-
runs-on: ubuntu-latest
126-
steps:
127-
- uses: ./.github/workflows/docs.yaml

.github/workflows/tag_latest.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Tag latest
2+
on:
3+
# Once draft release is released, trigger the docs release
4+
release:
5+
types:
6+
## stable release only
7+
- released
8+
jobs:
9+
tag-latest:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Tag latest
14+
run: |
15+
git tag -f latest
16+
git push origin latest

0 commit comments

Comments
 (0)