Post Release 2.3.2 #28
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Post Draft Release Published | |
| on: | |
| release: | |
| types: | |
| ## pre-release and stable release | |
| #- published | |
| ## stable release only | |
| - released | |
| run-name: Post ${{ github.event.release.name }} | |
| jobs: | |
| pypi-release: | |
| permissions: | |
| # write permission is required to upload build artifacts as release assets | |
| contents: write | |
| # 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.10" | |
| runs-on: ubuntu-latest | |
| 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}} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| # Full history + tags so hatch-vcs can derive the version from the | |
| # release tag. The checked-out ref is the tag itself, so the build | |
| # reports exactly X.Y.Z — no version.py bump or follow-up PR needed. | |
| fetch-depth: 0 | |
| - 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 | |
| - name: Publish package | |
| id: publish | |
| env: | |
| RELEASE_NAME: ${{ github.event.release.name }} | |
| run: | | |
| python -m pip install --upgrade twine | |
| if [[ "$RELEASE_NAME" =~ ^Test ]]; then | |
| echo "TEST_PYPI=true" >> $GITHUB_ENV | |
| export TWINE_REPOSITORY="testpypi" | |
| export TWINE_USERNAME=${TWINE_TEST_USERNAME} | |
| export TWINE_PASSWORD=${TWINE_TEST_PASSWORD} | |
| else | |
| echo "TEST_PYPI=false" >> $GITHUB_ENV | |
| export TWINE_REPOSITORY="pypi" | |
| fi | |
| # Upload the artifacts built in the previous step. --skip-existing | |
| # keeps re-runs idempotent (no error if the version already exists). | |
| python -m twine upload --skip-existing dist/* | |
| # Upload package as release assets | |
| - name: Upload pip wheel asset to release | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| with: | |
| upload_url: ${{github.event.release.upload_url}} | |
| asset_path: ${{env.DJ_WHEEL_PATH}} | |
| asset_name: pip-datajoint-${{ github.event.release.tag_name }}.whl | |
| asset_content_type: application/zip | |
| - name: Upload pip sdist asset to release | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| with: | |
| upload_url: ${{github.event.release.upload_url}} | |
| asset_path: ${{env.DJ_SDIST_PATH}} | |
| asset_name: pip-datajoint-${{ github.event.release.tag_name }}.tar.gz | |
| asset_content_type: application/gzip | |
| - name: Post release notification to Slack | |
| if: ${{ env.TEST_PYPI == 'false' }} | |
| uses: slackapi/slack-github-action@v2.0.0 | |
| with: | |
| webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| webhook-type: incoming-webhook | |
| payload: | | |
| { | |
| "text": "*New Release Published!* :tada: \n*Repository:* ${{ github.repository }}\n*Version:* ${{ github.event.release.tag_name }}\n*URL:* ${{ github.event.release.html_url }}", | |
| "blocks": [ | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "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>" | |
| } | |
| } | |
| ] | |
| } |