|
7 | 7 |
|
8 | 8 | permissions: |
9 | 9 | contents: write |
| 10 | + discussions: write # attach the release-linked repo Discussion (Announcements) |
10 | 11 |
|
11 | 12 | jobs: |
12 | 13 | release: |
@@ -82,12 +83,46 @@ jobs: |
82 | 83 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
83 | 84 |
|
84 | 85 | - name: Publish Release on GitHub |
85 | | - uses: softprops/action-gh-release@v1 |
| 86 | + uses: softprops/action-gh-release@v2 |
86 | 87 | with: |
87 | 88 | files: dist/* |
88 | 89 | body: ${{ steps.gen_changelog.outputs.changelog }} |
| 90 | + # Auto-open a repo-level Discussion linked to this release, seeded with |
| 91 | + # the same notes. Requires Discussions enabled and this category to exist. |
| 92 | + discussion_category_name: Announcements |
89 | 93 | env: |
90 | 94 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
91 | 95 |
|
| 96 | + # Mirror the release announcement into the ORG-level discussions, which are |
| 97 | + # backed by codellm-devkit/.github. GITHUB_TOKEN can't write cross-repo, so |
| 98 | + # this uses a PAT (ORG_DISCUSSIONS_TOKEN) with repo scope, and posts via the |
| 99 | + # createDiscussion GraphQL mutation. The body (the generated changelog) is |
| 100 | + # passed via env to avoid shell-injection, matching the repo-level post. |
| 101 | + - name: Announce in org-level discussions (codellm-devkit/.github) |
| 102 | + continue-on-error: true # a failed org post must not fail an otherwise-good release |
| 103 | + env: |
| 104 | + GH_TOKEN: ${{ secrets.ORG_DISCUSSIONS_TOKEN }} |
| 105 | + BODY: ${{ steps.gen_changelog.outputs.changelog }} |
| 106 | + run: | |
| 107 | + set -uo pipefail |
| 108 | + VERSION="${GITHUB_REF#refs/tags/v}" |
| 109 | + OWNER="codellm-devkit"; REPO=".github"; CATEGORY="Announcements" |
| 110 | + # The mutation needs GraphQL node IDs, not names — resolve them first. |
| 111 | + RESP=$(gh api graphql \ |
| 112 | + -f query='query($o:String!,$r:String!){repository(owner:$o,name:$r){id discussionCategories(first:25){nodes{id name}}}}' \ |
| 113 | + -f o="$OWNER" -f r="$REPO") \ |
| 114 | + || { echo "::warning::org discussion lookup failed — skipping org announcement."; exit 0; } |
| 115 | + REPO_ID=$(echo "$RESP" | jq -r '.data.repository.id') |
| 116 | + CAT_ID=$(echo "$RESP" | jq -r --arg c "$CATEGORY" '.data.repository.discussionCategories.nodes[]|select(.name==$c)|.id') |
| 117 | + if [[ -z "$REPO_ID" || "$REPO_ID" == "null" || -z "$CAT_ID" ]]; then |
| 118 | + echo "::warning::could not resolve $OWNER/$REPO discussion category '$CATEGORY' — skipping org announcement." |
| 119 | + exit 0 |
| 120 | + fi |
| 121 | + gh api graphql \ |
| 122 | + -f query='mutation($rid:ID!,$cid:ID!,$t:String!,$b:String!){createDiscussion(input:{repositoryId:$rid,categoryId:$cid,title:$t,body:$b}){discussion{url}}}' \ |
| 123 | + -f rid="$REPO_ID" -f cid="$CAT_ID" \ |
| 124 | + -f t="python-sdk v$VERSION" \ |
| 125 | + -f b="$BODY" |
| 126 | +
|
92 | 127 | - name: Publish package distributions to PyPI |
93 | 128 | run: uv publish --token ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments