Python Package Release #103
This file contains 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: Python Package Release and notification | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version Tag in the form X.Y.Z' | |
required: true | |
type: string | |
jobs: | |
build: | |
if: github.actor != 'github-actions[bot]' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get Token | |
id: get_workflow_token | |
uses: peter-murray/workflow-application-token-action@v2 | |
with: | |
application_id: ${{ secrets.APPLICATION_ID }} | |
application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }} | |
- name: Checkout code | |
uses: actions/checkout@v4.1.7 | |
with: | |
fetch-tags: true | |
ref: main | |
token: ${{ steps.get_workflow_token.outputs.token }} # Needed to trigger other actions | |
- name: Set up Python | |
uses: actions/setup-python@v5.1.1 | |
with: | |
python-version: "3.9" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install hatch git-cliff | |
- name: Update changelog | |
run: | | |
git cliff -o CHANGELOG.md | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.APP_SECRET }} | |
with: | |
tag_name: ${{ inputs.version }} | |
release_name: Release ${{ inputs.version }} | |
draft: false | |
prerelease: false | |
- name: Commit and push changes | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "Update version and changelog" | |
git push --follow-tags | |
- name: Bump version and create tag | |
run: | | |
hatch version ${{ inputs.version }} | |
hatch build | |
- name: Publish to PyPI | |
env: | |
HATCH_INDEX_USER: __token__ | |
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
hatch publish | |
- name: Post to a Slack channel | |
id: slack | |
uses: slackapi/slack-github-action@v1.26.0 | |
with: | |
channel-id: "${{ vars.SLACK_CHANNEL_ID }}" | |
payload: | | |
{ | |
"attachments": [ | |
{ | |
"color": "#36a64f", | |
"pretext": "Release holisticai *v${{ github.event.inputs.version }}* is on the way :rocket:", | |
"fields": [ | |
{ | |
"title": "Release Notes", | |
"value": "https://github.com/${{ github.repository }}/releases/tag/${{ github.event.inputs.version }}", | |
"short": false | |
}, | |
{ | |
"title": "Repository", | |
"value": "https://github.com/${{ github.repository }}", | |
"short": false | |
} | |
] | |
} | |
] | |
} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |