undervoice 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- undervoice-0.1.0/.editorconfig +17 -0
- undervoice-0.1.0/.gitattributes +21 -0
- undervoice-0.1.0/.github/ISSUE_TEMPLATE/bug_report.yml +43 -0
- undervoice-0.1.0/.github/ISSUE_TEMPLATE/config.yml +5 -0
- undervoice-0.1.0/.github/ISSUE_TEMPLATE/feature_request.yml +25 -0
- undervoice-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +27 -0
- undervoice-0.1.0/.github/dependabot.yml +18 -0
- undervoice-0.1.0/.github/workflows/ai-disclosure.yml +109 -0
- undervoice-0.1.0/.github/workflows/changelog.yml +77 -0
- undervoice-0.1.0/.github/workflows/ci.yml +49 -0
- undervoice-0.1.0/.github/workflows/cla.yml +157 -0
- undervoice-0.1.0/.github/workflows/release.yml +124 -0
- undervoice-0.1.0/.gitignore +18 -0
- undervoice-0.1.0/CHANGELOG.md +20 -0
- undervoice-0.1.0/CLA.md +91 -0
- undervoice-0.1.0/CONTRIBUTING.md +58 -0
- undervoice-0.1.0/LICENSE +21 -0
- undervoice-0.1.0/PKG-INFO +290 -0
- undervoice-0.1.0/README.md +256 -0
- undervoice-0.1.0/pyproject.toml +60 -0
- undervoice-0.1.0/scripts/release_notes.py +77 -0
- undervoice-0.1.0/tests/test_audio.py +47 -0
- undervoice-0.1.0/tests/test_fec.py +26 -0
- undervoice-0.1.0/tests/test_link.py +76 -0
- undervoice-0.1.0/tests/test_message.py +45 -0
- undervoice-0.1.0/undervoice/__init__.py +31 -0
- undervoice-0.1.0/undervoice/__main__.py +5 -0
- undervoice-0.1.0/undervoice/_audio.py +81 -0
- undervoice-0.1.0/undervoice/_channel.py +62 -0
- undervoice-0.1.0/undervoice/_cli.py +180 -0
- undervoice-0.1.0/undervoice/_demodulator.py +154 -0
- undervoice-0.1.0/undervoice/_fec.py +55 -0
- undervoice-0.1.0/undervoice/_live.py +142 -0
- undervoice-0.1.0/undervoice/_lpc.py +52 -0
- undervoice-0.1.0/undervoice/_message.py +124 -0
- undervoice-0.1.0/undervoice/_modulator.py +65 -0
- undervoice-0.1.0/undervoice/_sweep.py +53 -0
- undervoice-0.1.0/undervoice/_waveform.py +35 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# https://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
end_of_line = lf
|
|
7
|
+
insert_final_newline = true
|
|
8
|
+
trim_trailing_whitespace = true
|
|
9
|
+
indent_style = space
|
|
10
|
+
indent_size = 4
|
|
11
|
+
|
|
12
|
+
[*.{json,yml,yaml}]
|
|
13
|
+
indent_size = 2
|
|
14
|
+
|
|
15
|
+
[*.md]
|
|
16
|
+
# Markdown uses trailing double-space for hard line breaks.
|
|
17
|
+
trim_trailing_whitespace = false
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Normalise line endings to LF everywhere, in the repository *and* in the
|
|
2
|
+
# working tree, on every platform. Without this, Git on Windows defaults to
|
|
3
|
+
# core.autocrlf=true and checks files out with CRLF, which breaks byte-exact
|
|
4
|
+
# test fixtures and shell scripts ("bad interpreter: /bin/sh^M").
|
|
5
|
+
# Modern Windows editors all handle LF, so forcing it costs nothing.
|
|
6
|
+
* text=auto eol=lf
|
|
7
|
+
*.sh text eol=lf
|
|
8
|
+
# batch files are the exception: cmd.exe misreads labels and long lines in
|
|
9
|
+
# LF-only .cmd/.bat files, so they check out with CRLF
|
|
10
|
+
*.cmd text eol=crlf
|
|
11
|
+
*.bat text eol=crlf
|
|
12
|
+
|
|
13
|
+
# Binary assets
|
|
14
|
+
*.png binary
|
|
15
|
+
*.ico binary
|
|
16
|
+
*.icns binary
|
|
17
|
+
*.gif binary
|
|
18
|
+
*.msi binary
|
|
19
|
+
*.exe binary
|
|
20
|
+
*.londopy binary
|
|
21
|
+
*.wav binary
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Bug report
|
|
2
|
+
description: Something does not work, or frames do not decode when they should
|
|
3
|
+
labels: [bug]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: what
|
|
7
|
+
attributes:
|
|
8
|
+
label: What happened
|
|
9
|
+
description: What you ran, what you expected, and what you got instead.
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: command
|
|
14
|
+
attributes:
|
|
15
|
+
label: Command and output
|
|
16
|
+
description: The exact undervoice command and everything it printed.
|
|
17
|
+
render: text
|
|
18
|
+
validations:
|
|
19
|
+
required: true
|
|
20
|
+
- type: textarea
|
|
21
|
+
id: setup
|
|
22
|
+
attributes:
|
|
23
|
+
label: Setup
|
|
24
|
+
description: >
|
|
25
|
+
undervoice version (pip show undervoice), Python version, OS. For on-air problems:
|
|
26
|
+
radios, sound card interfaces, band, simplex or repeater, and the --level and --shape
|
|
27
|
+
you used.
|
|
28
|
+
validations:
|
|
29
|
+
required: true
|
|
30
|
+
- type: textarea
|
|
31
|
+
id: recording
|
|
32
|
+
attributes:
|
|
33
|
+
label: Recording
|
|
34
|
+
description: >
|
|
35
|
+
If decoding failed, attach the received audio (rx --record) as a zipped WAV. It is the
|
|
36
|
+
fastest way to find out why.
|
|
37
|
+
- type: input
|
|
38
|
+
id: ai
|
|
39
|
+
attributes:
|
|
40
|
+
label: AI tools
|
|
41
|
+
description: Did an AI tool write or summarize this report? "No", or which one.
|
|
42
|
+
validations:
|
|
43
|
+
required: true
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Feature request
|
|
2
|
+
description: Suggest a change or something new
|
|
3
|
+
labels: [enhancement]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: problem
|
|
7
|
+
attributes:
|
|
8
|
+
label: What you are trying to do
|
|
9
|
+
description: The situation on the air or at the bench, and what gets in the way today.
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: idea
|
|
14
|
+
attributes:
|
|
15
|
+
label: What would help
|
|
16
|
+
description: >
|
|
17
|
+
Your idea, if you have one. Changes to what goes on air also change the published
|
|
18
|
+
format, so say whether old and new stations would still understand each other.
|
|
19
|
+
- type: input
|
|
20
|
+
id: ai
|
|
21
|
+
attributes:
|
|
22
|
+
label: AI tools
|
|
23
|
+
description: Did an AI tool write or summarize this request? "No", or which one.
|
|
24
|
+
validations:
|
|
25
|
+
required: true
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
## What this changes
|
|
2
|
+
|
|
3
|
+
<!-- One or two sentences. If it fixes an issue: "Fixes #123". -->
|
|
4
|
+
|
|
5
|
+
## Why
|
|
6
|
+
|
|
7
|
+
<!-- Skip if it is obvious from the above. -->
|
|
8
|
+
|
|
9
|
+
## AI tools
|
|
10
|
+
|
|
11
|
+
<!-- Required. "None", or which tool and what it did (drafted the change, wrote the tests, explained the code, wrote this description). See CONTRIBUTING.md. -->
|
|
12
|
+
|
|
13
|
+
## How I tested it
|
|
14
|
+
|
|
15
|
+
- [ ] `pytest` and `ruff check .` pass
|
|
16
|
+
- [ ] Sweep before and after, if decoding could be affected (paste both tables)
|
|
17
|
+
- [ ] Tried it over a sound card or a radio, if it touches `tx` or `rx`
|
|
18
|
+
|
|
19
|
+
## On-air format
|
|
20
|
+
|
|
21
|
+
- [ ] This does not change what goes on air, or the README's Format section is updated to match
|
|
22
|
+
|
|
23
|
+
## Checklist
|
|
24
|
+
|
|
25
|
+
- [ ] `CHANGELOG.md` entry under `[Unreleased]`, if this is user-visible
|
|
26
|
+
- [ ] The "AI tools" section above is filled in, and I have read and understood everything I am submitting
|
|
27
|
+
- [ ] I accept the [Contributor License Agreement](../CLA.md) (the CLA check will ask on a first pull request)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: pip
|
|
4
|
+
directory: /
|
|
5
|
+
schedule:
|
|
6
|
+
interval: weekly
|
|
7
|
+
groups:
|
|
8
|
+
minor-and-patch:
|
|
9
|
+
update-types: [minor, patch]
|
|
10
|
+
commit-message:
|
|
11
|
+
prefix: deps
|
|
12
|
+
|
|
13
|
+
- package-ecosystem: github-actions
|
|
14
|
+
directory: /
|
|
15
|
+
schedule:
|
|
16
|
+
interval: monthly
|
|
17
|
+
commit-message:
|
|
18
|
+
prefix: ci
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
name: AI disclosure
|
|
2
|
+
|
|
3
|
+
# Every pull request says whether AI tools were used and what they did, in the
|
|
4
|
+
# template's "## AI tools" section ("None" is a fine answer). This check:
|
|
5
|
+
# - fails while that section is missing or still empty
|
|
6
|
+
# - fails when a commit lists an AI tool as author or co-author (tools are
|
|
7
|
+
# never authors; people are) or carries a "Generated with ..." line
|
|
8
|
+
# - fails when the PR says "None" but its commits or description show AI
|
|
9
|
+
# tool markers
|
|
10
|
+
# - labels disclosed PRs `ai-assisted`, so review knows to look closer
|
|
11
|
+
# The policy itself is in CONTRIBUTING.md ("AI-assisted contributions").
|
|
12
|
+
#
|
|
13
|
+
# pull_request_target so it can label PRs from forks. It never checks out or
|
|
14
|
+
# runs the PR's code: it only reads the description and commit messages, and
|
|
15
|
+
# those reach the script through environment variables, never through ${{ }}
|
|
16
|
+
# inside the script (which would let a PR body inject shell commands).
|
|
17
|
+
on:
|
|
18
|
+
pull_request_target:
|
|
19
|
+
types: [opened, edited, reopened, synchronize]
|
|
20
|
+
|
|
21
|
+
permissions:
|
|
22
|
+
contents: read
|
|
23
|
+
pull-requests: write # the ai-assisted label
|
|
24
|
+
|
|
25
|
+
jobs:
|
|
26
|
+
disclosure:
|
|
27
|
+
name: AI tools disclosed
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
# the maintainer's own PRs and bots (Dependabot) are exempt
|
|
30
|
+
if: >-
|
|
31
|
+
github.event.pull_request.author_association != 'OWNER' &&
|
|
32
|
+
github.event.pull_request.user.type != 'Bot'
|
|
33
|
+
steps:
|
|
34
|
+
- name: Collect commit messages and authors
|
|
35
|
+
env:
|
|
36
|
+
GH_TOKEN: ${{ github.token }}
|
|
37
|
+
REPO: ${{ github.repository }}
|
|
38
|
+
PR: ${{ github.event.pull_request.number }}
|
|
39
|
+
run: |
|
|
40
|
+
set -euo pipefail
|
|
41
|
+
gh api "repos/$REPO/pulls/$PR/commits" --paginate \
|
|
42
|
+
--jq '.[] | "author: \(.commit.author.name) <\(.commit.author.email)>\n\(.commit.message)\n----"' \
|
|
43
|
+
> commits.txt
|
|
44
|
+
wc -l < commits.txt
|
|
45
|
+
|
|
46
|
+
- name: Check the disclosure
|
|
47
|
+
id: check
|
|
48
|
+
env:
|
|
49
|
+
PR_BODY: ${{ github.event.pull_request.body }}
|
|
50
|
+
run: |
|
|
51
|
+
python3 - <<'PY'
|
|
52
|
+
import os, re, sys
|
|
53
|
+
|
|
54
|
+
body = os.environ.get("PR_BODY") or ""
|
|
55
|
+
commits = open("commits.txt", encoding="utf-8").read()
|
|
56
|
+
errors = []
|
|
57
|
+
|
|
58
|
+
# the "## AI tools" section, minus HTML comments (the template's hint)
|
|
59
|
+
m = re.search(r"^##\s*AI tools\s*$(.*?)(?=^##\s|\Z)", body, re.M | re.S | re.I)
|
|
60
|
+
answer = re.sub(r"<!--.*?-->", "", m.group(1), flags=re.S).strip() if m else ""
|
|
61
|
+
if not m:
|
|
62
|
+
errors.append('The PR description has no "## AI tools" section. Use the pull request template.')
|
|
63
|
+
elif not answer:
|
|
64
|
+
errors.append('The "## AI tools" section is empty. Write "None", or which tool and what it did.')
|
|
65
|
+
said_none = bool(re.fullmatch(r"(?i)\W*(none|no|n/?a|nothing)\W*", answer))
|
|
66
|
+
|
|
67
|
+
# AI tools as authors or co-authors, and tool-generated footers.
|
|
68
|
+
# Word boundaries keep people named Cody or Jules out of it.
|
|
69
|
+
tools = (r"\b(claude|anthropic|copilot|chatgpt|openai|gemini|codeium|windsurf|cursor|"
|
|
70
|
+
r"devin|aider|tabnine|codewhisperer|amazon q|codex|deepseek|ai[- ]agent|"
|
|
71
|
+
r"swe-agent)\b")
|
|
72
|
+
trailer = re.compile(rf"^(co-authored-by|author):[^\n]*{tools}", re.I | re.M)
|
|
73
|
+
footer = re.compile(r"(generated (with|by)[^\n]*\b(ai|claude|copilot|chatgpt|codex|cursor|gemini|"
|
|
74
|
+
r"devin|aider)\b)|(^claude-session:)|(noreply@anthropic\.com)", re.I | re.M)
|
|
75
|
+
if trailer.search(commits):
|
|
76
|
+
errors.append("A commit lists an AI tool as author or co-author. Tools are never authors: "
|
|
77
|
+
"rewrite those commits without it (git rebase -i, then force-push your "
|
|
78
|
+
"branch) and say what the tool did in this PR instead.")
|
|
79
|
+
commit_marker = footer.search(commits)
|
|
80
|
+
if commit_marker:
|
|
81
|
+
errors.append("Remove AI tool footers (\"Generated with ...\", session links) from the "
|
|
82
|
+
"commits; the disclosure belongs in the PR description.")
|
|
83
|
+
marker = commit_marker or footer.search(body) or trailer.search(commits)
|
|
84
|
+
if marker and said_none:
|
|
85
|
+
errors.append('The PR says "None" for AI tools, but it carries an AI tool marker '
|
|
86
|
+
f'("{marker.group(0).strip()[:60]}"). Correct the disclosure.')
|
|
87
|
+
|
|
88
|
+
with open(os.environ["GITHUB_OUTPUT"], "a") as out:
|
|
89
|
+
out.write(f"assisted={'false' if (said_none or not answer) else 'true'}\n")
|
|
90
|
+
summary = open(os.environ["GITHUB_STEP_SUMMARY"], "a")
|
|
91
|
+
if errors:
|
|
92
|
+
summary.write("### AI disclosure: changes needed\n\n" + "\n".join(f"- {e}" for e in errors) + "\n")
|
|
93
|
+
for e in errors:
|
|
94
|
+
print(f"::error title=AI disclosure::{e}")
|
|
95
|
+
sys.exit(1)
|
|
96
|
+
summary.write(f"### AI disclosure\n\n{answer}\n")
|
|
97
|
+
print("disclosure ok:", answer[:200])
|
|
98
|
+
PY
|
|
99
|
+
|
|
100
|
+
- name: Label AI-assisted PRs
|
|
101
|
+
if: steps.check.outputs.assisted == 'true'
|
|
102
|
+
env:
|
|
103
|
+
GH_TOKEN: ${{ github.token }}
|
|
104
|
+
REPO: ${{ github.repository }}
|
|
105
|
+
PR: ${{ github.event.pull_request.number }}
|
|
106
|
+
run: |
|
|
107
|
+
gh label create ai-assisted --repo "$REPO" --color 8957e5 \
|
|
108
|
+
--description "Contributor used AI tools (see the PR's AI tools section)" 2>/dev/null || true
|
|
109
|
+
gh pr edit "$PR" --repo "$REPO" --add-label ai-assisted
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
name: Changelog
|
|
2
|
+
|
|
3
|
+
# Runs on every pull request and every push to main. The point is not
|
|
4
|
+
# bureaucracy: a changelog that only gets written on release day gets written
|
|
5
|
+
# from `git log`, and a changelog written from `git log` is a commit list, not
|
|
6
|
+
# release notes.
|
|
7
|
+
on:
|
|
8
|
+
pull_request:
|
|
9
|
+
branches: [main]
|
|
10
|
+
push:
|
|
11
|
+
branches: [main]
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: write # only used by the badge publish on main
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
validate:
|
|
18
|
+
name: Validate CHANGELOG.md
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.12"
|
|
26
|
+
|
|
27
|
+
# Strict mode turns recoverable style problems into failures, and emits
|
|
28
|
+
# ::error annotations pinned to the exact line in the PR's diff.
|
|
29
|
+
# The version check against pyproject.toml runs in release.yml, where there is a tag
|
|
30
|
+
# to compare with; before the first release there is nothing to check.
|
|
31
|
+
#
|
|
32
|
+
# The badge is published only from main: fork PRs have no write token,
|
|
33
|
+
# and a badge is not worth failing a contributor's first PR over.
|
|
34
|
+
# Pinned rather than floating on @v2: the v2 tag resolves to a release
|
|
35
|
+
# that predates the badge inputs, and the action only *warns* about
|
|
36
|
+
# inputs it does not recognise, so the badge silently never published.
|
|
37
|
+
- uses: Londopy/patchnotes@v2.6.0
|
|
38
|
+
id: changelog
|
|
39
|
+
with:
|
|
40
|
+
file: CHANGELOG.md
|
|
41
|
+
strict: "true"
|
|
42
|
+
badge: ${{ github.event_name == 'push' && 'gh-pages' || 'none' }}
|
|
43
|
+
badge-label: changelog
|
|
44
|
+
|
|
45
|
+
- name: Summary
|
|
46
|
+
run: |
|
|
47
|
+
echo "Latest documented release: **${{ steps.changelog.outputs.latest-version }}**" \
|
|
48
|
+
>> "$GITHUB_STEP_SUMMARY"
|
|
49
|
+
|
|
50
|
+
entry-present:
|
|
51
|
+
name: PR touches the changelog
|
|
52
|
+
if: github.event_name == 'pull_request'
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
steps:
|
|
55
|
+
- uses: actions/checkout@v4
|
|
56
|
+
with:
|
|
57
|
+
fetch-depth: 0
|
|
58
|
+
|
|
59
|
+
# Advisory, not blocking. Plenty of legitimate PRs (a typo fix, a CI
|
|
60
|
+
# tweak) have nothing to say to users, and a bot that demands an entry
|
|
61
|
+
# for those just teaches people to write "misc changes".
|
|
62
|
+
- name: Look for a changelog edit
|
|
63
|
+
run: |
|
|
64
|
+
set -euo pipefail
|
|
65
|
+
BASE="origin/${{ github.base_ref }}"
|
|
66
|
+
if git diff --name-only "$BASE"...HEAD | grep -qx "CHANGELOG.md"; then
|
|
67
|
+
echo "CHANGELOG.md was updated." >> "$GITHUB_STEP_SUMMARY"
|
|
68
|
+
else
|
|
69
|
+
{
|
|
70
|
+
echo "### No changelog entry"
|
|
71
|
+
echo
|
|
72
|
+
echo "This PR does not touch \`CHANGELOG.md\`. If it changes anything a user"
|
|
73
|
+
echo "would notice, add an entry under \`## [Unreleased]\`. If it does not"
|
|
74
|
+
echo "(docs, CI, refactors), ignore this: it is a note, not a gate."
|
|
75
|
+
} >> "$GITHUB_STEP_SUMMARY"
|
|
76
|
+
echo "::notice title=No changelog entry::Add one under [Unreleased] if this is user-visible."
|
|
77
|
+
fi
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
pull_request:
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
concurrency:
|
|
13
|
+
group: ci-${{ github.ref }}
|
|
14
|
+
cancel-in-progress: true
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
test:
|
|
18
|
+
name: Python ${{ matrix.python }} on ${{ matrix.os }}
|
|
19
|
+
runs-on: ${{ matrix.os }}
|
|
20
|
+
timeout-minutes: 20
|
|
21
|
+
strategy:
|
|
22
|
+
fail-fast: false
|
|
23
|
+
matrix:
|
|
24
|
+
os: [ubuntu-latest]
|
|
25
|
+
python: ["3.10", "3.11", "3.12", "3.13"]
|
|
26
|
+
# the oldest and newest Python are enough to catch platform differences
|
|
27
|
+
include:
|
|
28
|
+
- { os: windows-latest, python: "3.10" }
|
|
29
|
+
- { os: windows-latest, python: "3.13" }
|
|
30
|
+
- { os: macos-latest, python: "3.10" }
|
|
31
|
+
- { os: macos-latest, python: "3.13" }
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v4
|
|
34
|
+
|
|
35
|
+
- uses: actions/setup-python@v5
|
|
36
|
+
with:
|
|
37
|
+
python-version: ${{ matrix.python }}
|
|
38
|
+
cache: pip
|
|
39
|
+
cache-dependency-path: pyproject.toml
|
|
40
|
+
|
|
41
|
+
# sounddevice (the live extra) is left out: runners have no sound cards and the tests
|
|
42
|
+
# never open one
|
|
43
|
+
- run: pip install -e .[dev]
|
|
44
|
+
|
|
45
|
+
- run: ruff check .
|
|
46
|
+
|
|
47
|
+
- run: ruff format --check .
|
|
48
|
+
|
|
49
|
+
- run: pytest
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
name: CLA
|
|
2
|
+
|
|
3
|
+
# Every contributor accepts CLA.md once, by commenting the sentence below on a
|
|
4
|
+
# pull request. Signatures are recorded on the cla-signatures branch of this
|
|
5
|
+
# repository (signatures/version1/cla.json, the same format nexium's CLA
|
|
6
|
+
# assistant used, so its signatures carry over). Each PR's head commit gets a
|
|
7
|
+
# "CLA" status: make it a required status check (Settings > Rules) so an
|
|
8
|
+
# unsigned PR can't merge. Comment "recheck" to run it again.
|
|
9
|
+
#
|
|
10
|
+
# Same rules as nexium. Written in-repo because the action nexium uses
|
|
11
|
+
# (contributor-assistant/github-action) was archived in March 2026.
|
|
12
|
+
#
|
|
13
|
+
# pull_request_target so it can comment and set statuses on PRs from forks.
|
|
14
|
+
# It never checks out or runs PR code; comment text reaches the script only
|
|
15
|
+
# through environment variables.
|
|
16
|
+
on:
|
|
17
|
+
pull_request_target:
|
|
18
|
+
types: [opened, synchronize, reopened]
|
|
19
|
+
issue_comment:
|
|
20
|
+
types: [created]
|
|
21
|
+
|
|
22
|
+
permissions:
|
|
23
|
+
contents: write # the signatures file on cla-signatures
|
|
24
|
+
pull-requests: write # the "please sign" comment
|
|
25
|
+
statuses: write # the CLA status on the head commit
|
|
26
|
+
|
|
27
|
+
# one signature write at a time, so two people signing at once can't collide
|
|
28
|
+
concurrency:
|
|
29
|
+
group: cla-${{ github.repository }}
|
|
30
|
+
cancel-in-progress: false
|
|
31
|
+
|
|
32
|
+
jobs:
|
|
33
|
+
cla:
|
|
34
|
+
# the job itself always passes; the result is the "CLA" commit status,
|
|
35
|
+
# which a signing comment can flip to success later (a failed job can't)
|
|
36
|
+
name: CLA check
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
if: >-
|
|
39
|
+
github.event_name == 'pull_request_target' ||
|
|
40
|
+
(github.event.issue.pull_request &&
|
|
41
|
+
(github.event.comment.body == 'recheck' ||
|
|
42
|
+
startsWith(github.event.comment.body, 'I have read the CLA Document and I hereby sign the CLA')))
|
|
43
|
+
steps:
|
|
44
|
+
- name: Check signatures
|
|
45
|
+
env:
|
|
46
|
+
GH_TOKEN: ${{ github.token }}
|
|
47
|
+
REPO: ${{ github.repository }}
|
|
48
|
+
REPO_ID: ${{ github.repository_id }}
|
|
49
|
+
EVENT: ${{ github.event_name }}
|
|
50
|
+
PR: ${{ github.event.pull_request.number || github.event.issue.number }}
|
|
51
|
+
COMMENT_BODY: ${{ github.event.comment.body }}
|
|
52
|
+
COMMENT_ID: ${{ github.event.comment.id }}
|
|
53
|
+
COMMENTER: ${{ github.event.comment.user.login }}
|
|
54
|
+
COMMENTER_ID: ${{ github.event.comment.user.id }}
|
|
55
|
+
COMMENT_AT: ${{ github.event.comment.created_at }}
|
|
56
|
+
CLA_URL: https://github.com/${{ github.repository }}/blob/HEAD/CLA.md
|
|
57
|
+
run: |
|
|
58
|
+
python3 - <<'PY'
|
|
59
|
+
import base64, json, os, subprocess, sys
|
|
60
|
+
|
|
61
|
+
SENTENCE = "I have read the CLA Document and I hereby sign the CLA"
|
|
62
|
+
BRANCH, PATH = "cla-signatures", "signatures/version1/cla.json"
|
|
63
|
+
ALLOW = {"londopy"} # the maintainer; any "...[bot]" is allowed too
|
|
64
|
+
MARK = "<!-- cla-check -->" # finds our own comment to update it
|
|
65
|
+
E = os.environ
|
|
66
|
+
repo, pr = E["REPO"], E["PR"]
|
|
67
|
+
|
|
68
|
+
def gh(*args, data=None, ok_missing=False, pages=False):
|
|
69
|
+
cmd = ["gh", "api", *args] + (["--paginate", "--slurp"] if pages else [])
|
|
70
|
+
if data is not None:
|
|
71
|
+
cmd += ["--input", "-"]
|
|
72
|
+
r = subprocess.run(cmd, input=json.dumps(data) if data is not None else None,
|
|
73
|
+
capture_output=True, text=True)
|
|
74
|
+
if r.returncode != 0:
|
|
75
|
+
if ok_missing and ("404" in r.stderr or "Not Found" in r.stderr):
|
|
76
|
+
return None
|
|
77
|
+
sys.exit(f"gh api {' '.join(args)} failed: {r.stderr.strip()}")
|
|
78
|
+
out = json.loads(r.stdout) if r.stdout.strip() else {}
|
|
79
|
+
return [item for page in out for item in page] if pages else out
|
|
80
|
+
|
|
81
|
+
def load():
|
|
82
|
+
f = gh(f"repos/{repo}/contents/{PATH}?ref={BRANCH}", ok_missing=True)
|
|
83
|
+
if f is None:
|
|
84
|
+
return {"signedContributors": []}, None
|
|
85
|
+
return json.loads(base64.b64decode(f["content"])), f["sha"]
|
|
86
|
+
|
|
87
|
+
def save(doc, sha, who):
|
|
88
|
+
if gh(f"repos/{repo}/branches/{BRANCH}", ok_missing=True) is None:
|
|
89
|
+
default = gh(f"repos/{repo}")["default_branch"]
|
|
90
|
+
head = gh(f"repos/{repo}/git/ref/heads/{default}")["object"]["sha"]
|
|
91
|
+
gh(f"repos/{repo}/git/refs", "-X", "POST",
|
|
92
|
+
data={"ref": f"refs/heads/{BRANCH}", "sha": head})
|
|
93
|
+
body = {"message": f"CLA: {who} signed", "branch": BRANCH,
|
|
94
|
+
"content": base64.b64encode((json.dumps(doc, indent=2) + "\n").encode()).decode()}
|
|
95
|
+
if sha:
|
|
96
|
+
body["sha"] = sha
|
|
97
|
+
gh(f"repos/{repo}/contents/{PATH}", "-X", "PUT", data=body)
|
|
98
|
+
|
|
99
|
+
info = gh(f"repos/{repo}/pulls/{pr}")
|
|
100
|
+
head_sha = info["head"]["sha"]
|
|
101
|
+
|
|
102
|
+
# who has to sign: the PR's author and every commit author
|
|
103
|
+
people, unlinked = {}, []
|
|
104
|
+
people[info["user"]["login"].lower()] = info["user"]["login"]
|
|
105
|
+
for c in gh(f"repos/{repo}/pulls/{pr}/commits", pages=True):
|
|
106
|
+
if c.get("author") and c["author"].get("login"):
|
|
107
|
+
people[c["author"]["login"].lower()] = c["author"]["login"]
|
|
108
|
+
else:
|
|
109
|
+
unlinked.append(c["sha"][:7])
|
|
110
|
+
needed = {k: v for k, v in people.items() if k not in ALLOW and not k.endswith("[bot]")}
|
|
111
|
+
|
|
112
|
+
doc, sha = load()
|
|
113
|
+
signed = {s["name"].lower() for s in doc.get("signedContributors", [])}
|
|
114
|
+
|
|
115
|
+
# a signing comment counts only for the person who wrote it
|
|
116
|
+
if E["EVENT"] == "issue_comment" and E["COMMENT_BODY"].strip().startswith(SENTENCE):
|
|
117
|
+
who = E["COMMENTER"]
|
|
118
|
+
if who.lower() not in signed:
|
|
119
|
+
doc.setdefault("signedContributors", []).append({
|
|
120
|
+
"name": who, "id": int(E["COMMENTER_ID"]), "comment_id": int(E["COMMENT_ID"]),
|
|
121
|
+
"created_at": E["COMMENT_AT"], "repoId": int(E["REPO_ID"]), "pullRequestNo": int(pr)})
|
|
122
|
+
save(doc, sha, who)
|
|
123
|
+
signed.add(who.lower())
|
|
124
|
+
|
|
125
|
+
missing = sorted(v for k, v in needed.items() if k not in signed)
|
|
126
|
+
ok = not missing and not unlinked
|
|
127
|
+
gh(f"repos/{repo}/statuses/{head_sha}", "-X", "POST", data={
|
|
128
|
+
"state": "success" if ok else "failure", "context": "CLA",
|
|
129
|
+
"description": "All contributors have signed the CLA" if ok
|
|
130
|
+
else f"Waiting on: {', '.join(missing) or 'unlinked commit authors'}"[:139],
|
|
131
|
+
"target_url": E["CLA_URL"]})
|
|
132
|
+
|
|
133
|
+
# one comment per PR, kept up to date
|
|
134
|
+
if ok:
|
|
135
|
+
text = f"{MARK}\nAll contributors have accepted the CLA. Thank you!"
|
|
136
|
+
else:
|
|
137
|
+
lines = [MARK, "Thank you for the pull request. Before it can be merged, please read the "
|
|
138
|
+
f"[Contributor License Agreement]({E['CLA_URL']}) and accept it by commenting this "
|
|
139
|
+
"sentence exactly:", "", f"> {SENTENCE}", "",
|
|
140
|
+
"You keep your copyright; the agreement lets the project distribute your work under "
|
|
141
|
+
"its license. You only sign once, for every later pull request too.", ""]
|
|
142
|
+
if missing:
|
|
143
|
+
lines.append("Still to sign: " + ", ".join(f"@{m}" for m in missing))
|
|
144
|
+
if unlinked:
|
|
145
|
+
lines.append("These commits have an author email that isn't linked to a GitHub account, so "
|
|
146
|
+
f"nobody can sign for them: {', '.join(unlinked)}. Add the email to your GitHub "
|
|
147
|
+
"account, or rewrite the commits with one that is.")
|
|
148
|
+
text = "\n".join(lines)
|
|
149
|
+
mine = [c for c in gh(f"repos/{repo}/issues/{pr}/comments", pages=True) if MARK in (c.get("body") or "")]
|
|
150
|
+
if mine:
|
|
151
|
+
if mine[0]["body"] != text:
|
|
152
|
+
gh(f"repos/{repo}/issues/comments/{mine[0]['id']}", "-X", "PATCH", data={"body": text})
|
|
153
|
+
elif not ok:
|
|
154
|
+
gh(f"repos/{repo}/issues/{pr}/comments", "-X", "POST", data={"body": text})
|
|
155
|
+
|
|
156
|
+
print("CLA ok" if ok else f"CLA missing: {missing} unlinked: {unlinked}")
|
|
157
|
+
PY
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
# rebuilds the release for a tag that already exists, e.g. after fixing a broken run
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
inputs:
|
|
9
|
+
tag:
|
|
10
|
+
description: Existing tag to release, e.g. v0.1.0
|
|
11
|
+
required: true
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
validate:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
timeout-minutes: 10
|
|
20
|
+
outputs:
|
|
21
|
+
tag: ${{ steps.tag.outputs.tag }}
|
|
22
|
+
version: ${{ steps.tag.outputs.version }}
|
|
23
|
+
steps:
|
|
24
|
+
# the tag goes through an env var so a crafted tag name cannot inject shell
|
|
25
|
+
- id: tag
|
|
26
|
+
env:
|
|
27
|
+
TAG: ${{ inputs.tag || github.ref_name }}
|
|
28
|
+
run: |
|
|
29
|
+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
|
|
30
|
+
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
|
|
31
|
+
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
with:
|
|
34
|
+
ref: ${{ steps.tag.outputs.tag }}
|
|
35
|
+
|
|
36
|
+
- uses: actions/setup-python@v5
|
|
37
|
+
with:
|
|
38
|
+
python-version: "3.12"
|
|
39
|
+
|
|
40
|
+
# gate everything on the notes: the tag, CHANGELOG.md and pyproject.toml must agree
|
|
41
|
+
- uses: Londopy/patchnotes@v2.6.0
|
|
42
|
+
with:
|
|
43
|
+
file: CHANGELOG.md
|
|
44
|
+
strict: "true"
|
|
45
|
+
check-version: ${{ steps.tag.outputs.version }}
|
|
46
|
+
|
|
47
|
+
- run: |
|
|
48
|
+
pip install patchnotes==2.6.0
|
|
49
|
+
patchnotes CHANGELOG.md check-version --against pyproject.toml
|
|
50
|
+
|
|
51
|
+
build:
|
|
52
|
+
needs: validate
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
timeout-minutes: 10
|
|
55
|
+
steps:
|
|
56
|
+
- uses: actions/checkout@v4
|
|
57
|
+
with:
|
|
58
|
+
ref: ${{ needs.validate.outputs.tag }}
|
|
59
|
+
|
|
60
|
+
- uses: actions/setup-python@v5
|
|
61
|
+
with:
|
|
62
|
+
python-version: "3.12"
|
|
63
|
+
|
|
64
|
+
- run: |
|
|
65
|
+
pip install build
|
|
66
|
+
python -m build
|
|
67
|
+
|
|
68
|
+
- uses: actions/upload-artifact@v4
|
|
69
|
+
with:
|
|
70
|
+
name: dist
|
|
71
|
+
path: dist/
|
|
72
|
+
|
|
73
|
+
github-release:
|
|
74
|
+
needs: [validate, build]
|
|
75
|
+
runs-on: ubuntu-latest
|
|
76
|
+
timeout-minutes: 10
|
|
77
|
+
permissions:
|
|
78
|
+
contents: write
|
|
79
|
+
steps:
|
|
80
|
+
- uses: actions/checkout@v4
|
|
81
|
+
with:
|
|
82
|
+
ref: ${{ needs.validate.outputs.tag }}
|
|
83
|
+
# the previous tag is needed for the compare link
|
|
84
|
+
fetch-depth: 0
|
|
85
|
+
|
|
86
|
+
- uses: actions/download-artifact@v4
|
|
87
|
+
with:
|
|
88
|
+
name: dist
|
|
89
|
+
path: dist/
|
|
90
|
+
|
|
91
|
+
- uses: actions/setup-python@v5
|
|
92
|
+
with:
|
|
93
|
+
python-version: "3.12"
|
|
94
|
+
|
|
95
|
+
- env:
|
|
96
|
+
TAG: ${{ needs.validate.outputs.tag }}
|
|
97
|
+
VERSION: ${{ needs.validate.outputs.version }}
|
|
98
|
+
GH_TOKEN: ${{ github.token }}
|
|
99
|
+
run: |
|
|
100
|
+
prev="$(git describe --tags --abbrev=0 "$TAG^" 2>/dev/null || true)"
|
|
101
|
+
python scripts/release_notes.py "$VERSION" dist "$prev"
|
|
102
|
+
flags=()
|
|
103
|
+
# a tag with a dash (v0.2.0-rc1) is a prerelease
|
|
104
|
+
if [[ "$TAG" == *-* ]]; then flags+=(--prerelease); fi
|
|
105
|
+
gh release create "$TAG" dist/* --verify-tag --title "undervoice $VERSION" \
|
|
106
|
+
--notes-file body.md "${flags[@]}"
|
|
107
|
+
|
|
108
|
+
pypi:
|
|
109
|
+
needs: [validate, build]
|
|
110
|
+
runs-on: ubuntu-latest
|
|
111
|
+
timeout-minutes: 10
|
|
112
|
+
# trusted publishing: PyPI must list this repo, release.yml and the pypi environment
|
|
113
|
+
environment: pypi
|
|
114
|
+
permissions:
|
|
115
|
+
id-token: write
|
|
116
|
+
steps:
|
|
117
|
+
- uses: actions/download-artifact@v4
|
|
118
|
+
with:
|
|
119
|
+
name: dist
|
|
120
|
+
path: dist/
|
|
121
|
+
|
|
122
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
123
|
+
with:
|
|
124
|
+
skip-existing: true
|