diff --git a/.github/workflows/publish-install-script.yml b/.github/workflows/publish-install-script.yml index 8b6d5e86..94f2b1b0 100644 --- a/.github/workflows/publish-install-script.yml +++ b/.github/workflows/publish-install-script.yml @@ -14,6 +14,9 @@ jobs: name: Upload to Cloudflare R2 runs-on: ubuntu-latest + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + steps: - uses: actions/checkout@v4 @@ -54,3 +57,17 @@ jobs: --content-type "text/plain" echo "✓ examples.ps1 uploaded to R2" + - name: Notify Slack (success) + if: ${{ success() && env.SLACK_WEBHOOK_URL != '' }} + run: | + curl -s -X POST "$SLACK_WEBHOOK_URL" \ + -H 'Content-type: application/json' \ + --data "{\"text\":\"*Codeplain Client*: Install scripts deployed to R2 :white_check_mark: (\`${GITHUB_SHA:0:7}\`, by *${{ github.actor }}*).\"}" + + - name: Notify Slack (failure) + if: ${{ failure() && env.SLACK_WEBHOOK_URL != '' }} + run: | + curl -s -X POST "$SLACK_WEBHOOK_URL" \ + -H 'Content-type: application/json' \ + --data "{\"text\":\"*Codeplain Client*: Install script deploy to R2 FAILED :x: (\`${GITHUB_SHA:0:7}\`). Users may be getting a stale installer. See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.\"}" + diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 72148d87..01d06903 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -15,12 +15,22 @@ jobs: permissions: contents: write + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + steps: - uses: actions/checkout@v4 with: # hatch-vcs derives the version from git tags, so we need full history. fetch-depth: 0 + - name: Notify Slack (start) + if: ${{ env.SLACK_WEBHOOK_URL != '' }} + run: | + curl -s -X POST "$SLACK_WEBHOOK_URL" \ + -H 'Content-type: application/json' \ + --data "{\"text\":\"*Codeplain Client*: Release \`${{ github.ref_name }}\` published by *${{ github.actor }}* — building and publishing to PyPI...\"}" + - name: Install uv # uv provisions its own Python (honoring requires-python), so no # separate actions/setup-python step is needed. @@ -47,6 +57,13 @@ jobs: run: | gh release upload ${{ github.ref_name }} dist/* --clobber + - name: Notify Slack (build failure) + if: ${{ failure() && env.SLACK_WEBHOOK_URL != '' }} + run: | + curl -s -X POST "$SLACK_WEBHOOK_URL" \ + -H 'Content-type: application/json' \ + --data "{\"text\":\"*Codeplain Client*: Build of \`${{ github.ref_name }}\` FAILED :x:. Nothing was published to PyPI. See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.\"}" + publish-to-pypi: name: Publish to PyPI needs: build @@ -59,6 +76,9 @@ jobs: # authenticate this run — no long-lived API token needed. id-token: write + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + steps: - name: Download distribution packages uses: actions/download-artifact@v4 @@ -68,3 +88,17 @@ jobs: - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + + - name: Notify Slack (success) + if: ${{ success() && env.SLACK_WEBHOOK_URL != '' }} + run: | + curl -s -X POST "$SLACK_WEBHOOK_URL" \ + -H 'Content-type: application/json' \ + --data "{\"text\":\"*Codeplain Client*: \`${{ github.ref_name }}\` published to PyPI :white_check_mark:. Install with \`pip install --upgrade codeplain\`.\"}" + + - name: Notify Slack (failure) + if: ${{ failure() && env.SLACK_WEBHOOK_URL != '' }} + run: | + curl -s -X POST "$SLACK_WEBHOOK_URL" \ + -H 'Content-type: application/json' \ + --data "{\"text\":\"*Codeplain Client*: Publishing \`${{ github.ref_name }}\` to PyPI FAILED :x:. See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.\"}"