Skip to content

Commit 1638764

Browse files
author
Drew Yang
committed
fix: 🐛 fix release flow name
1 parent 175c275 commit 1638764

File tree

4 files changed

+176
-175
lines changed

4 files changed

+176
-175
lines changed

.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' || github.event.release.name }}
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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+
id: update_version
42+
run: |
43+
VERSION=$(echo "${{ github.event.release.name }}" | grep -oP '\d+\.\d+\.\d+')
44+
sed -i "s/^__version__ = .*/__version__ = \"$VERSION\"/" datajoint/version.py
45+
cat datajoint/version.py
46+
# Commit the changes
47+
BRANCH_NAME="update-version-$VERSION"
48+
git switch -c $BRANCH_NAME
49+
git config --global user.name "github-actions"
50+
git config --global user.email "[email protected]"
51+
git add datajoint/version.py
52+
git commit -m "Update version.py to $VERSION"
53+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
54+
echo "VERSION=$VERSION" >> $GITHUB_ENV
55+
- name: Set up Python ${{matrix.py_ver}}
56+
uses: actions/setup-python@v5
57+
with:
58+
python-version: ${{matrix.py_ver}}
59+
# Merging build and release steps just for the simplicity,
60+
# since datajoint-python doesn't have platform specific dependencies or binaries,
61+
# and the build process is fairly fast, so removed upload/download artifacts
62+
- name: Build package
63+
id: build
64+
run: |
65+
python -m pip install build
66+
python -m build .
67+
echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV
68+
echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
69+
echo "NEW_VERSION=${{github.event.release.resolved_version}}" >> $GITHUB_ENV
70+
- name: Publish package
71+
run: |
72+
# TODO - if test pypi or not
73+
export HOST_UID=$(id -u)
74+
if [ "$TESTPYPI" == "true" ]; then
75+
LATEST_PYPI=$(curl -s https://test.pypi.org/pypi/datajoint/json | jq -r '.info.version')
76+
export TWINE_REPOSITORY="testpypi"
77+
export TWINE_USERNAME=${TWINE_TEST_USERNAME}
78+
export TWINE_PASSWORD=${TWINE_TEST_PASSWORD}
79+
else
80+
LATEST_PYPI=$(curl -s https://pypi.org/pypi/datajoint/json | jq -r '.info.version')
81+
export TWINE_REPOSITORY="pypi"
82+
fi
83+
# Check if the new version is different from the latest on PyPI, avoid re-uploading error
84+
if [ "$NEW_VERSION" != "$LATEST_PYPI" ]; then
85+
docker compose run --build --quiet-pull \
86+
-e TWINE_USERNAME=${TWINE_USERNAME} \
87+
-e TWINE_PASSWORD=${TWINE_PASSWORD} \
88+
-e TWINE_REPOSITORY=${TWINE_REPOSITORY} \
89+
app sh -c "pip install twine && python -m twine upload dist/*"
90+
else
91+
echo "::warning::Latest version $LATEST_PYPI on $TWINE_REPOSITORY is the new version $NEW_VERSION"
92+
fi
93+
# Upload package as release assets
94+
- name: Upload pip wheel asset to release
95+
if: ${{ github.event.inputs.testpypi == 'false' }}
96+
uses: actions/upload-release-asset@v1
97+
env:
98+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
99+
with:
100+
upload_url: ${{github.event.release.upload_url}}
101+
asset_path: ${{env.DJ_WHEEL_PATH}}
102+
asset_name: pip-datajoint-${{env.DJ_VERSION}}.whl
103+
asset_content_type: application/zip
104+
- name: Upload pip sdist asset to release
105+
if: ${{ github.event.inputs.testpypi == 'false' }}
106+
uses: actions/upload-release-asset@v1
107+
env:
108+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
109+
with:
110+
upload_url: ${{github.event.release.upload_url}}
111+
asset_path: ${{env.DJ_SDIST_PATH}}
112+
asset_name: pip-datajoint-${{env.DJ_VERSION}}.tar.gz
113+
asset_content_type: application/gzip
114+
- name: Create Pull Request
115+
env:
116+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
run: |
118+
git push origin ${{ env.BRANCH_NAME }}
119+
gh pr create \
120+
--title "[github-actions]Update version.py to ${{ github.event.release.name }}" \
121+
--body "This PR updates \`version.py\` to match the latest release: ${{ github.event.release.name }}" \
122+
--base master \
123+
--head ${{ env.BRANCH_NAME }} \
124+
--reviewer dimitri-yatsenko,yambottle,ttngu207
125+
slack-notification:
126+
runs-on: ubuntu-latest
127+
steps:
128+
- name: Post a message in a channel
129+
uses: slackapi/[email protected]
130+
with:
131+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
132+
webhook-type: incoming-webhook
133+
payload: |
134+
{
135+
"text": "*New Release Published!* :tada: \n*Repository:* ${{ github.repository }}\n*Version:* ${{ github.event.release.tag_name }}\n*URL:* ${{ github.event.release.html_url }}",
136+
"blocks": [
137+
{
138+
"type": "section",
139+
"text": {
140+
"type": "mrkdwn",
141+
"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>"
142+
}
143+
}
144+
]
145+
}

.github/workflows/post_release.yaml

Lines changed: 0 additions & 73 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)