diff --git a/.github/config/pypi-release-slack-notification.yml b/.github/config/pypi-release-slack-notification.yml new file mode 100644 index 000000000..e2d9875e8 --- /dev/null +++ b/.github/config/pypi-release-slack-notification.yml @@ -0,0 +1,32 @@ +pretext: Triggered via {{eventName}} of {{env.VERSION}} by {{actor}} +title: "Haystack PyPi release" + +text: | + + + {{#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:" diff --git a/.github/workflows/pypi_release.yml b/.github/workflows/pypi_release.yml new file mode 100644 index 000000000..084a3b705 --- /dev/null +++ b/.github/workflows/pypi_release.yml @@ -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