Automate release on PyPi (#4015)

This commit is contained in:
Silvano Cerza 2023-02-01 17:40:21 +01:00 committed by GitHub
parent 3fcfc8eb23
commit e8ff48094b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,32 @@
pretext: Triggered via {{eventName}} of {{env.VERSION}} by {{actor}}
title: "Haystack PyPi release"
text: |
<https://pypi.org/project/farm-haystack/{{env.VERSION}}/|PyPi release {{env.VERSION}}>
{{#if (eq jobStatus "SUCCESS")}}
Haystack {{env.VERSION}} has been released on PyPi :rocket:
{{else if (eq jobStatus "FAILURE")}}
{{icon jobStatus}} Haystack {{env.VERSION}} PyPi release failed! {{icon jobStatus}}
{{else if (eq jobStatus "CANCELLED")}}
{{icon jobStatus}} Haystack {{env.VERSION}} PyPi release has been cancelled! {{icon jobStatus}}
{{/if}}
fallback: |-
Haystack {{env.VERSION}} PyPi release status: {{jobStatus}}
footer: >-
<{{repositoryUrl}}|{{repositoryName}}> <{{workflowRunUrl}}|{{workflow}} #{{runNumber}}>
colors:
success: "#5DADE2"
failure: "#884EA0"
cancelled: "#A569BD"
default: "#7D3C98"
icons:
success: ":white_check_mark:"
failure: ":x:"
cancelled: ":interrobang:"
skipped: ":interrobang:"
default: ":interrobang:"

35
.github/workflows/pypi_release.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: Project release on PyPi
on:
tags:
- "v[0-9].[0-9]+.[0-9]+*"
jobs:
release-on-pypi:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Hatch
run: pip install hatch
- name: Build Haystack
run: hatch build
- name: Publish on PyPi
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_API_TOKEN }}
run: hatch publish -y
- name: Notify Slack
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
channel: "#haystack"
config: .github/config/pypi-release-slack-notification.yml