Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ name: Publish to PyPI
# 1. Push a tag matching `v*` (e.g. `v1.0.2`) on a commit on `main` →
# publishes to PyPI. The `verify` job refuses the release unless the
# tag is exactly `v` + the version in BOTH `pyproject.toml` and
# `src/agentchatme/_version.py`, and the tagged commit is on `main`.
# `src/agentchatme/_version.py`, the tagged commit is on `main`, and
# the tag still points at it on origin (a tag deletion can start a
# run too, on `main`'s head).
#
# 2. Manual `workflow_dispatch` with `target=test` → uploads to TestPyPI
# for a dry-run install. Use before the first real publish, or whenever
Expand Down Expand Up @@ -79,6 +81,17 @@ jobs:
exit 1
fi
fi
# The tag as origin has it now: a deleted or moved tag is refused
# (a tag deletion can start a run, on main's head).
if [ "$EVENT" = "push" ]; then
if ! fetched="$(git fetch -q --no-tags origin "+refs/tags/$GITHUB_REF_NAME:refs/verify/tag" 2>&1)"; then
echo "::error::tag $GITHUB_REF_NAME is not on origin (deleted): ${fetched//$'\n'/ }"
exit 1
elif [ "$(git rev-parse 'refs/verify/tag^{commit}')" != "$GITHUB_SHA" ]; then
echo "::error::tag $GITHUB_REF_NAME on origin points at $(git rev-parse 'refs/verify/tag^{commit}'), not $GITHUB_SHA (moved); a release publishes the commit its tag points at"
exit 1
fi
fi
# Re-run the full check matrix on the tagged commit. Don't trust prior
# CI status — someone could tag a feature branch directly.
test:
Expand Down Expand Up @@ -220,7 +233,10 @@ jobs:
# awaiting-tap: fires after build succeeds, while the environment-gated
# publish job sits waiting for the human approval — so the tap request
# lives in Slack, not email. failure: any red job in the pipeline.
# Both fail-safe: absent secret → logged warning, exit 0.
# Both fail-safe: absent secret → logged warning, exit 0. A post that
# Slack refuses (a revoked webhook) or never answers fails its step, with
# an error annotation on the run; continue-on-error keeps the job and the
# run green. No publish job depends on a notify job.
notify-awaiting-tap:
runs-on: ubuntu-24.04
needs: build
Expand All @@ -229,22 +245,32 @@ jobs:
(github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'prod')
steps:
- name: Post to Slack
continue-on-error: true
env:
WEBHOOK: ${{ secrets.SLACK_WEBHOOK_WARNING }}
TEXT: ":hourglass_flowing_sand: *agentchatme (PyPI) release awaiting your approval* (`${{ github.ref_name }}` → pypi gate). Tap it here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
run: |
set -o pipefail
if [ -z "$WEBHOOK" ]; then echo "::warning::SLACK_WEBHOOK_WARNING not set — skipped"; exit 0; fi
printf '%s' "$TEXT" | jq -Rs '{text: .}' | curl -sS -o /dev/null --max-time 15 -H 'Content-Type: application/json' -d @- "$WEBHOOK" || true
if ! printf '%s' "$TEXT" | jq -Rs '{text: .}' | curl -fsS -o /dev/null --max-time 15 -H 'Content-Type: application/json' -d @- "$WEBHOOK"; then
echo "::error::the Slack post failed (webhook revoked, or Slack unreachable)"
exit 1
fi

notify-failure:
runs-on: ubuntu-24.04
needs: [verify, test, build, publish-testpypi, publish-pypi]
if: failure()
steps:
- name: Post to Slack
continue-on-error: true
env:
WEBHOOK: ${{ secrets.SLACK_WEBHOOK_WARNING }}
TEXT: ":warning: *agentchatme (PyPI) publish pipeline failed* on `${{ github.ref_name }}` — ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
run: |
set -o pipefail
if [ -z "$WEBHOOK" ]; then echo "::warning::SLACK_WEBHOOK_WARNING not set — skipped"; exit 0; fi
printf '%s' "$TEXT" | jq -Rs '{text: .}' | curl -sS -o /dev/null --max-time 15 -H 'Content-Type: application/json' -d @- "$WEBHOOK" || true
if ! printf '%s' "$TEXT" | jq -Rs '{text: .}' | curl -fsS -o /dev/null --max-time 15 -H 'Content-Type: application/json' -d @- "$WEBHOOK"; then
echo "::error::the Slack post failed (webhook revoked, or Slack unreachable)"
exit 1
fi
Loading