Skip to content

Publish and Notification #2

Publish and Notification

Publish and Notification #2

name: Publish and Notification
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APPLICATION_ID }}
private-key: ${{ secrets.APPLICATION_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v4.1.7
with:
fetch-tags: true
fetch-depth: 0
ref: main
token: ${{ steps.app-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
- name: Get Latest Release Version
id: get_release
run: |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "Latest release version: $latest_tag"
echo "tag=$latest_tag" >> $GITHUB_ENV # Save the tag to an environment variable
- name: Publish to PyPI
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}
run: |
hatch build
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${{env.tag}}* is on the way :rocket:",
"fields": [
{
"title": "Release Notes",
"value": "https://github.com/${{ github.repository }}/releases/tag/${{env.tag}}",
"short": false
},
{
"title": "Repository",
"value": "https://github.com/${{ github.repository }}",
"short": false
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}