File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -223,3 +223,54 @@ jobs:
223223 body_path : release-notes.md
224224 overwrite_files : true
225225 files : release-assets/checksums.txt
226+
227+ notify :
228+ needs : [prepare, release]
229+ if : ${{ always() && needs.prepare.result == 'success' && needs.release.result == 'success' }}
230+ runs-on : ubuntu-latest
231+ steps :
232+ - name : Notify WeCom release
233+ env :
234+ WECHAT_WEBHOOK_URL : ${{ secrets.WECHAT_WEBHOOK_URL }}
235+ TAG : ${{ needs.prepare.outputs.tag }}
236+ VERSION : ${{ needs.prepare.outputs.version }}
237+ REPOSITORY : ${{ github.repository }}
238+ RELEASE_URL : https://github.com/${{ github.repository }}/releases/tag/${{ needs.prepare.outputs.tag }}
239+ run : |
240+ set -euo pipefail
241+
242+ if [ -z "${WECHAT_WEBHOOK_URL}" ]; then
243+ echo "WECHAT_WEBHOOK_URL secret is required for release notifications" >&2
244+ exit 1
245+ fi
246+
247+ python - <<'PY' > wecom-payload.json
248+ import json
249+ import os
250+
251+ content = "\n".join(
252+ [
253+ f"{os.environ['REPOSITORY']} {os.environ['TAG']} published.",
254+ f"Version: {os.environ['VERSION']}",
255+ f"Release: {os.environ['RELEASE_URL']}",
256+ ]
257+ )
258+ print(
259+ json.dumps(
260+ {
261+ "msgtype": "text",
262+ "text": {
263+ "content": content,
264+ "mentioned_list": ["@all"],
265+ },
266+ },
267+ ensure_ascii=False,
268+ )
269+ )
270+ PY
271+
272+ curl -fsS \
273+ -X POST \
274+ -H 'Content-Type: application/json' \
275+ --data @wecom-payload.json \
276+ "${WECHAT_WEBHOOK_URL}"
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44
55[project ]
66name = " atlassian-cli"
7- version = " 0.1.7 "
7+ version = " 0.1.8 "
88description = " CLI for Atlassian Server and Data Center products"
99readme = " README.md"
1010requires-python = " >=3.12"
Original file line number Diff line number Diff line change 11__all__ = ["__version__" ]
22
3- __version__ = "0.1.7 "
3+ __version__ = "0.1.8 "
Original file line number Diff line number Diff line change @@ -55,6 +55,20 @@ def test_release_workflow_publishes_generated_release_notes() -> None:
5555 assert all (step ["with" ]["body_path" ] == "release-notes.md" for step in upload_steps )
5656
5757
58+ def test_release_workflow_notifies_wecom_after_publish () -> None :
59+ workflow = yaml .safe_load (Path (".github/workflows/release.yml" ).read_text ())
60+
61+ notify = workflow ["jobs" ]["notify" ]
62+ step = next (step for step in notify ["steps" ] if step ["name" ] == "Notify WeCom release" )
63+
64+ assert notify ["needs" ] == ["prepare" , "release" ]
65+ assert "needs.release.result == 'success'" in notify ["if" ]
66+ assert step ["env" ]["WECHAT_WEBHOOK_URL" ] == "${{ secrets.WECHAT_WEBHOOK_URL }}"
67+ assert "WECHAT_WEBHOOK_URL secret is required" in step ["run" ]
68+ assert '"mentioned_list": ["@all"]' in step ["run" ]
69+ assert "curl -fsS" in step ["run" ]
70+
71+
5872def test_generate_release_notes_script_outputs_changes_and_assets (tmp_path ) -> None :
5973 script = Path (".github/scripts/generate_release_notes.py" ).resolve ()
6074 repo = tmp_path / "repo"
You can’t perform that action at this time.
0 commit comments