Skip to content

Commit 0c22de8

Browse files
author
Drew Yang
committed
fix: 🐛 update release flow logic | add update version.py
1 parent af4abf0 commit 0c22de8

File tree

4 files changed

+56
-20
lines changed

4 files changed

+56
-20
lines changed

.github/workflows/docs.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@ name: Docs release
22
on:
33
# manually trigger
44
workflow_dispatch:
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
12-
run-name: "📚 Release docs ${{ github.event.release.tag_name }}"
5+
# been called by other workflows
6+
workflow_call:
7+
138
jobs:
149
publish-docs:
1510
runs-on: ubuntu-latest

.github/workflows/post-release.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Update version.py on Release
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+
12+
jobs:
13+
update-version:
14+
permissions:
15+
# write permission is required to update version.py
16+
contents: write
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
- name: Publish docs
24+
call-publish-docs:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: ./.github/workflows/docs.yaml
28+
- name: Update version.py
29+
id: update_version
30+
run: |
31+
VERSION=$(echo "${{ github.event.release.name }}" | grep -oP '\d+\.\d+\.\d+')
32+
echo "VERSION=$VERSION" >> $GITHUB_ENV
33+
sed -i "s/^__version__ = .*/__version__ = \"$VERSION\"/" datajoint/version.py
34+
# Commit the changes
35+
git config --global user.name "github-actions"
36+
git config --global user.email "[email protected]"
37+
git add datajoint/version.py
38+
git commit -m "Update version.py to $VERSION"
39+
git push

.github/workflows/release.yaml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ jobs:
3232
TWINE_TEST_PASSWORD: ${{secrets.twine_test_password}}
3333
TESTPYPI: ${{ github.event.inputs.testpypi }}
3434
steps:
35+
# Drafts your next Release notes as Pull Requests are merged into "master"
36+
- name: Draft release notes
37+
id: create_gh_release
38+
uses: release-drafter/release-drafter@v6
39+
with:
40+
config-name: release_drafter.yaml
41+
disable-autolabeler: true
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3544
- uses: actions/checkout@v4
3645
- name: Set up Python ${{matrix.py_ver}}
3746
uses: actions/setup-python@v5
@@ -47,7 +56,7 @@ jobs:
4756
python -m build .
4857
echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV
4958
echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
50-
echo "NEW_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)" >> $GITHUB_ENV
59+
echo "NEW_VERSION=${{steps.create_gh_release.outputs.resolved_version}}" >> $GITHUB_ENV
5160
- name: Publish package
5261
run: |
5362
export HOST_UID=$(id -u)
@@ -68,18 +77,8 @@ jobs:
6877
-e TWINE_REPOSITORY=${TWINE_REPOSITORY} \
6978
app sh -c "pip install twine && python -m twine upload dist/*"
7079
else
71-
echo "::warning::The latest version $LATEST_PYPI on $TWINE_REPOSITORY is the new version $NEW_VERSION"
80+
echo "::warning::Latest version $LATEST_PYPI on $TWINE_REPOSITORY is the new version $NEW_VERSION"
7281
fi
73-
# Drafts your next Release notes as Pull Requests are merged into "master"
74-
- name: Draft release notes
75-
id: create_gh_release
76-
uses: release-drafter/release-drafter@v6
77-
if: ${{ github.event.inputs.testpypi == 'false' }}
78-
with:
79-
config-name: release_drafter.yaml
80-
disable-autolabeler: true
81-
env:
82-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8382
# Upload package as release assets
8483
- name: Upload pip wheel asset to release
8584
if: ${{ github.event.inputs.testpypi == 'false' }}

datajoint/version.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# version bump auto managed by Github Actions:
2+
# label_prs.yaml(prep), release.yaml(bump), post_release.yaml(edit)
3+
# manually set this version will be eventaully overwriten by the above actions
14
__version__ = "0.14.4"
25

36
assert len(__version__) <= 10 # The log table limits version to the 10 characters

0 commit comments

Comments
 (0)