lanpair 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.
- lanpair-0.1.0/.github/ISSUE_TEMPLATE/bug_report.yml +57 -0
- lanpair-0.1.0/.github/ISSUE_TEMPLATE/config.yml +8 -0
- lanpair-0.1.0/.github/ISSUE_TEMPLATE/feature_request.yml +15 -0
- lanpair-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +12 -0
- lanpair-0.1.0/.github/dependabot.yml +24 -0
- lanpair-0.1.0/.github/labeler.yml +22 -0
- lanpair-0.1.0/.github/workflows/changelog-draft.yml +73 -0
- lanpair-0.1.0/.github/workflows/ci.yml +54 -0
- lanpair-0.1.0/.github/workflows/issue-assistant.yml +194 -0
- lanpair-0.1.0/.github/workflows/label-apply.yml +44 -0
- lanpair-0.1.0/.github/workflows/labeler.yml +25 -0
- lanpair-0.1.0/.github/workflows/pr-assistant.yml +588 -0
- lanpair-0.1.0/.github/workflows/pr-commands.yml +253 -0
- lanpair-0.1.0/.github/workflows/release.yml +57 -0
- lanpair-0.1.0/.github/workflows/review-noted.yml +16 -0
- lanpair-0.1.0/.github/workflows/scorecard.yml +36 -0
- lanpair-0.1.0/.github/workflows/security-review-reminder.yml +40 -0
- lanpair-0.1.0/.github/workflows/security.yml +156 -0
- lanpair-0.1.0/.github/workflows/zizmor.yml +28 -0
- lanpair-0.1.0/.gitignore +8 -0
- lanpair-0.1.0/CHANGELOG.md +15 -0
- lanpair-0.1.0/CODE_OF_CONDUCT.md +21 -0
- lanpair-0.1.0/CONTRIBUTING.md +115 -0
- lanpair-0.1.0/LICENSE +21 -0
- lanpair-0.1.0/PKG-INFO +195 -0
- lanpair-0.1.0/README.md +174 -0
- lanpair-0.1.0/SECURITY.md +47 -0
- lanpair-0.1.0/SUPPORT.md +12 -0
- lanpair-0.1.0/docs/assets/banner.svg +34 -0
- lanpair-0.1.0/docs/design.md +62 -0
- lanpair-0.1.0/pyproject.toml +35 -0
- lanpair-0.1.0/src/lanpair/__init__.py +23 -0
- lanpair-0.1.0/src/lanpair/envelope.py +271 -0
- lanpair-0.1.0/src/lanpair/identity.py +97 -0
- lanpair-0.1.0/src/lanpair/py.typed +0 -0
- lanpair-0.1.0/tests/test_envelope.py +181 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: š Bug report
|
|
2
|
+
description: Something in lanpair does not work the way it should
|
|
3
|
+
labels: [bug, triage]
|
|
4
|
+
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
**Found a security problem?** Please do not open an issue: report it privately
|
|
9
|
+
(see SECURITY.md).
|
|
10
|
+
- type: textarea
|
|
11
|
+
id: what
|
|
12
|
+
attributes:
|
|
13
|
+
label: What happened?
|
|
14
|
+
description: What you did, what you expected, and what happened instead. A short code sample helps most.
|
|
15
|
+
validations:
|
|
16
|
+
required: true
|
|
17
|
+
- type: input
|
|
18
|
+
id: version
|
|
19
|
+
attributes:
|
|
20
|
+
label: lanpair version
|
|
21
|
+
description: "`python -c \"import lanpair; print(lanpair.__version__)\"`"
|
|
22
|
+
validations:
|
|
23
|
+
required: true
|
|
24
|
+
- type: input
|
|
25
|
+
id: python
|
|
26
|
+
attributes:
|
|
27
|
+
label: Python version
|
|
28
|
+
validations:
|
|
29
|
+
required: true
|
|
30
|
+
- type: dropdown
|
|
31
|
+
id: os
|
|
32
|
+
attributes:
|
|
33
|
+
label: System
|
|
34
|
+
multiple: true
|
|
35
|
+
options:
|
|
36
|
+
- macOS
|
|
37
|
+
- Windows
|
|
38
|
+
- Linux
|
|
39
|
+
- Other
|
|
40
|
+
validations:
|
|
41
|
+
required: true
|
|
42
|
+
- type: dropdown
|
|
43
|
+
id: area
|
|
44
|
+
attributes:
|
|
45
|
+
label: Where is the problem?
|
|
46
|
+
options:
|
|
47
|
+
- Finding devices (discovery)
|
|
48
|
+
- Pairing
|
|
49
|
+
- Sending or receiving messages
|
|
50
|
+
- Key storage
|
|
51
|
+
- Installing
|
|
52
|
+
- Something else
|
|
53
|
+
- type: textarea
|
|
54
|
+
id: log
|
|
55
|
+
attributes:
|
|
56
|
+
label: Traceback or log output
|
|
57
|
+
render: text
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
blank_issues_enabled: false
|
|
2
|
+
contact_links:
|
|
3
|
+
- name: š¬ Questions and ideas
|
|
4
|
+
url: https://github.com/TonyD365/lanpair/discussions
|
|
5
|
+
about: How do I� Share an idea before it becomes a feature request.
|
|
6
|
+
- name: š Security problem
|
|
7
|
+
url: https://github.com/TonyD365/lanpair/security/advisories/new
|
|
8
|
+
about: Please report vulnerabilities privately.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
name: ⨠Feature request
|
|
2
|
+
description: Suggest something lanpair should do
|
|
3
|
+
labels: [enhancement, triage]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: problem
|
|
7
|
+
attributes:
|
|
8
|
+
label: What would you like to do?
|
|
9
|
+
description: Describe your project and the situation, not only the solution.
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: idea
|
|
14
|
+
attributes:
|
|
15
|
+
label: How could it work?
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
## What and why
|
|
2
|
+
|
|
3
|
+
<!-- One or two sentences. Link the issue it solves: Fixes #123 -->
|
|
4
|
+
|
|
5
|
+
## How it was checked
|
|
6
|
+
|
|
7
|
+
- [ ] `ruff check .` and `ruff format --check .`
|
|
8
|
+
- [ ] `mypy src`
|
|
9
|
+
- [ ] `pytest`
|
|
10
|
+
- [ ] Security impact considered: <!-- does this touch keys, signatures, pairing or what is accepted from the network? -->
|
|
11
|
+
|
|
12
|
+
<!-- Labels are added automatically from the files you changed. -->
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Weekly dependency updates, each kind grouped into a single pull request.
|
|
2
|
+
version: 2
|
|
3
|
+
updates:
|
|
4
|
+
- package-ecosystem: github-actions
|
|
5
|
+
directory: /
|
|
6
|
+
schedule:
|
|
7
|
+
interval: weekly
|
|
8
|
+
cooldown:
|
|
9
|
+
default-days: 7
|
|
10
|
+
labels: [dependencies, ci]
|
|
11
|
+
groups:
|
|
12
|
+
actions:
|
|
13
|
+
patterns: ["*"]
|
|
14
|
+
- package-ecosystem: pip
|
|
15
|
+
directory: /
|
|
16
|
+
schedule:
|
|
17
|
+
interval: weekly
|
|
18
|
+
cooldown:
|
|
19
|
+
default-days: 7
|
|
20
|
+
versioning-strategy: increase
|
|
21
|
+
labels: [dependencies]
|
|
22
|
+
groups:
|
|
23
|
+
python:
|
|
24
|
+
patterns: ["*"]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Area labels for pull requests, by the files they touch (see workflows/labeler.yml).
|
|
2
|
+
crypto:
|
|
3
|
+
- changed-files:
|
|
4
|
+
- any-glob-to-any-file: ["src/lanpair/identity.py", "src/lanpair/envelope.py", "src/lanpair/pairing*.py", "src/lanpair/channel*.py"]
|
|
5
|
+
discovery:
|
|
6
|
+
- changed-files:
|
|
7
|
+
- any-glob-to-any-file: ["src/lanpair/discovery*.py"]
|
|
8
|
+
keystore:
|
|
9
|
+
- changed-files:
|
|
10
|
+
- any-glob-to-any-file: ["src/lanpair/keystore*.py"]
|
|
11
|
+
ci:
|
|
12
|
+
- changed-files:
|
|
13
|
+
- any-glob-to-any-file: [".github/**"]
|
|
14
|
+
documentation:
|
|
15
|
+
- changed-files:
|
|
16
|
+
- any-glob-to-any-file: ["*.md", "docs/**"]
|
|
17
|
+
dependencies:
|
|
18
|
+
- changed-files:
|
|
19
|
+
- any-glob-to-any-file: ["pyproject.toml"]
|
|
20
|
+
tests:
|
|
21
|
+
- changed-files:
|
|
22
|
+
- any-glob-to-any-file: ["tests/**"]
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Drafts the changelog for the next release (Actions -> Changelog draft -> Run workflow, with
|
|
2
|
+
# the version, e.g. 4.3.0): the pull requests merged since the latest release, one line each,
|
|
3
|
+
# grouped by kind, in a new section at the top of CHANGELOG.md. TonyD365-Agent opens it as a
|
|
4
|
+
# pull request, to be rewritten for users (what changed for them, not how) and reviewed.
|
|
5
|
+
#
|
|
6
|
+
# Runs from main only; reads titles through the API and passes them on in files and env
|
|
7
|
+
# values, never in the script itself.
|
|
8
|
+
name: Changelog draft
|
|
9
|
+
|
|
10
|
+
on:
|
|
11
|
+
workflow_dispatch:
|
|
12
|
+
inputs:
|
|
13
|
+
version:
|
|
14
|
+
description: Version, e.g. 4.3.0
|
|
15
|
+
required: true
|
|
16
|
+
|
|
17
|
+
permissions:
|
|
18
|
+
contents: read
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
draft:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
timeout-minutes: 10
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
26
|
+
with:
|
|
27
|
+
fetch-depth: 0
|
|
28
|
+
# The token is not left in .git/config; the push below gets it from gh.
|
|
29
|
+
persist-credentials: false
|
|
30
|
+
- env:
|
|
31
|
+
GH_TOKEN: ${{ secrets.AGENT_TOKEN }}
|
|
32
|
+
GH_REPO: ${{ github.repository }}
|
|
33
|
+
VERSION: ${{ inputs.version }}
|
|
34
|
+
run: |
|
|
35
|
+
set -euo pipefail
|
|
36
|
+
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::Version must look like 4.3.0"; exit 1; }
|
|
37
|
+
grep -q "^## $VERSION\$" CHANGELOG.md && { echo "::error::CHANGELOG.md already has $VERSION"; exit 1; }
|
|
38
|
+
last=$(gh release view --json tagName,publishedAt -q .publishedAt)
|
|
39
|
+
tag=$(gh release view --json tagName -q .tagName)
|
|
40
|
+
# Merged since the latest release; not the changelog's own pull requests or bots'.
|
|
41
|
+
gh pr list --state merged --base main --limit 200 \
|
|
42
|
+
--search "merged:>$last" --json number,title,author,labels,headRefName \
|
|
43
|
+
-q '.[] | select(.author.is_bot | not) | select(.headRefName | startswith("docs/changelog") | not)
|
|
44
|
+
| [ (if (.headRefName | test("^(fix|hotfix)/")) or (.title | test("(?i)\\bfix"))
|
|
45
|
+
then "fix"
|
|
46
|
+
elif (.headRefName | test("^(ci|build|chore)/")) or ([.labels[].name] | index("ci"))
|
|
47
|
+
then "also" else "new" end),
|
|
48
|
+
"\(.title) (#\(.number))" ] | @tsv' > prs.tsv
|
|
49
|
+
[ -s prs.tsv ] || { echo "::error::No pull requests merged since $tag"; exit 1; }
|
|
50
|
+
section() { awk -F'\t' -v k="$1" '$1 == k { print "- " $2 }' prs.tsv; }
|
|
51
|
+
{
|
|
52
|
+
echo "## $VERSION"
|
|
53
|
+
echo
|
|
54
|
+
echo "<!-- Draft from the pull requests merged since $tag: rewrite each line for users. -->"
|
|
55
|
+
for kind in "new|### ⨠New" "fix|### š Fixes" "also|### š§ Also"; do
|
|
56
|
+
lines=$(section "${kind%%|*}")
|
|
57
|
+
[ -n "$lines" ] && printf '\n%s\n%s\n' "${kind#*|}" "$lines"
|
|
58
|
+
done
|
|
59
|
+
echo
|
|
60
|
+
} > section.md
|
|
61
|
+
# Put it above the latest release's section.
|
|
62
|
+
awk 'FNR == NR { s = s $0 "\n"; next } !done && /^## / { printf "%s\n", s; done = 1 } { print }' \
|
|
63
|
+
section.md CHANGELOG.md > CHANGELOG.new && mv CHANGELOG.new CHANGELOG.md
|
|
64
|
+
branch="docs/changelog-$VERSION"
|
|
65
|
+
git config user.name TonyD365-Agent
|
|
66
|
+
git config user.email "$(gh api user -q .id)+TonyD365-Agent@users.noreply.github.com"
|
|
67
|
+
git switch -c "$branch"
|
|
68
|
+
git commit -qam "Changelog: $VERSION (draft)"
|
|
69
|
+
gh auth setup-git
|
|
70
|
+
git push -q origin "$branch"
|
|
71
|
+
printf '%s\n' "Draft of the changelog for $VERSION, from the pull requests merged since $tag." "" \
|
|
72
|
+
"Before approving: rewrite the lines for users (what changed for them), merge or drop small ones, and add a bold note at the top for a security update or anything users must do." > body.md
|
|
73
|
+
gh pr create --base main --head "$branch" --title "Changelog: $VERSION" --body-file body.md
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
# A pull request that only changes documentation skips the tests (main still runs
|
|
8
|
+
# everything after the merge).
|
|
9
|
+
paths-ignore: ["docs/**", "**/*.md", "LICENSE"]
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: ci-${{ github.ref }}
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
lint:
|
|
20
|
+
name: Lint and type-check
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
timeout-minutes: 10
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
25
|
+
with:
|
|
26
|
+
persist-credentials: false
|
|
27
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
|
|
28
|
+
with:
|
|
29
|
+
python-version: "3.13"
|
|
30
|
+
cache: pip
|
|
31
|
+
- run: python -m pip install -e ".[dev]"
|
|
32
|
+
- run: ruff check .
|
|
33
|
+
- run: ruff format --check .
|
|
34
|
+
- run: mypy src
|
|
35
|
+
|
|
36
|
+
test:
|
|
37
|
+
name: Tests (${{ matrix.os }}, Python ${{ matrix.python }})
|
|
38
|
+
runs-on: ${{ matrix.os }}
|
|
39
|
+
timeout-minutes: 15
|
|
40
|
+
strategy:
|
|
41
|
+
fail-fast: false
|
|
42
|
+
matrix:
|
|
43
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
44
|
+
python: ["3.10", "3.13"]
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
47
|
+
with:
|
|
48
|
+
persist-credentials: false
|
|
49
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
|
|
50
|
+
with:
|
|
51
|
+
python-version: ${{ matrix.python }}
|
|
52
|
+
cache: pip
|
|
53
|
+
- run: python -m pip install -e ".[dev]"
|
|
54
|
+
- run: pytest
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# The issue side of the bot (TonyD365-Agent):
|
|
2
|
+
#
|
|
3
|
+
# - Triage: a new or edited issue gets area and platform labels from what it says (the
|
|
4
|
+
# issue forms' answers and keywords). A bug report without a version or a system gets
|
|
5
|
+
# needs-info and one comment asking for them; the label goes once they are there.
|
|
6
|
+
# - Fixed notices: a merged pull request that says "Fixes #12" (or closes / resolves) leaves
|
|
7
|
+
# a note on #12 and the label fixed-in-next-release; when a release is published, those
|
|
8
|
+
# issues hear which version has the fix, and the label is removed.
|
|
9
|
+
# - Commands in issue comments: /label, /unlabel (maintainers), /close, /reopen (the
|
|
10
|
+
# issue's author or a maintainer), /help.
|
|
11
|
+
name: Issue assistant
|
|
12
|
+
|
|
13
|
+
on:
|
|
14
|
+
issues:
|
|
15
|
+
types: [opened, edited]
|
|
16
|
+
issue_comment: # zizmor: ignore[dangerous-triggers] -- reviewed: never runs PR code
|
|
17
|
+
types: [created]
|
|
18
|
+
pull_request_target: # zizmor: ignore[dangerous-triggers] -- reviewed: never runs PR code
|
|
19
|
+
types: [closed]
|
|
20
|
+
release:
|
|
21
|
+
types: [published]
|
|
22
|
+
|
|
23
|
+
permissions: {}
|
|
24
|
+
|
|
25
|
+
jobs:
|
|
26
|
+
triage:
|
|
27
|
+
if: github.event_name == 'issues' && github.event.issue.user.login != 'TonyD365-Agent'
|
|
28
|
+
runs-on: ubuntu-slim
|
|
29
|
+
permissions:
|
|
30
|
+
contents: read
|
|
31
|
+
issues: write
|
|
32
|
+
pull-requests: read
|
|
33
|
+
steps:
|
|
34
|
+
- env:
|
|
35
|
+
GH_TOKEN: ${{ secrets.AGENT_TOKEN || github.token }}
|
|
36
|
+
GH_REPO: ${{ github.repository }}
|
|
37
|
+
NUMBER: ${{ github.event.issue.number }}
|
|
38
|
+
AUTHOR: ${{ github.event.issue.user.login }}
|
|
39
|
+
TITLE: ${{ github.event.issue.title }}
|
|
40
|
+
BODY: ${{ github.event.issue.body }}
|
|
41
|
+
run: |
|
|
42
|
+
set -uo pipefail
|
|
43
|
+
text=$(printf '%s\n%s' "$TITLE" "$BODY" | tr '[:upper:]' '[:lower:]')
|
|
44
|
+
has() { grep -Eq -- "$1" <<<"$text"; }
|
|
45
|
+
add=()
|
|
46
|
+
# Areas (the bug form's "area" answers and plain keywords, in English and Chinese).
|
|
47
|
+
has 'discover|mdns|zeroconf|bonjour|find(ing)? (the )?device|åē°' && add+=(discovery)
|
|
48
|
+
has 'pair(ing)?|qr|code|é
对|ę«ē ' && add+=(pairing)
|
|
49
|
+
has 'sign(ature)?|verify|replay|envelope|ē¾å|éŖčÆ' && add+=(crypto)
|
|
50
|
+
has 'keychain|key ?store|credential manager|keyring|åÆé„|é„åäø²' && add+=(keystore)
|
|
51
|
+
has 'install|pip|wheel|å®č£
' && add+=(installing)
|
|
52
|
+
# Platforms.
|
|
53
|
+
has 'windows|win(10|11)' && add+=("platform: Windows")
|
|
54
|
+
has 'macos|mac os|apple silicon|intel mac|macbook|imac|č¹ę' && add+=("platform: macOS")
|
|
55
|
+
has 'linux|ubuntu|debian|fedora|arch|raspberry|appimage|ę č擾' && add+=("platform: Linux")
|
|
56
|
+
for label in "${add[@]}"; do
|
|
57
|
+
gh api -X POST "repos/$GH_REPO/issues/$NUMBER/labels" -f "labels[]=$label" >/dev/null 2>&1 || true
|
|
58
|
+
done
|
|
59
|
+
|
|
60
|
+
# A bug needs a version and a system.
|
|
61
|
+
labels=$(gh issue view "$NUMBER" --json labels -q '[.labels[].name] | join(",")')
|
|
62
|
+
case ",$labels," in *,bug,*) ;; *) exit 0 ;; esac
|
|
63
|
+
missing=()
|
|
64
|
+
grep -Eq '[0-9]+\.[0-9]+\.[0-9]+' <<<"$text" || missing+=("the **lanpair version** (\`pip show lanpair\`)")
|
|
65
|
+
has 'windows|macos|mac os|apple silicon|intel|linux|ubuntu|debian|fedora|raspberry' || missing+=("your **system** (macOS, Windows or Linux, and which version)")
|
|
66
|
+
asked=$(gh api "repos/$GH_REPO/issues/$NUMBER/comments?per_page=100" \
|
|
67
|
+
-q '[.[] | select(.body | startswith("<!-- lanpair-needs-info -->"))] | length')
|
|
68
|
+
if [ "${#missing[@]}" = 0 ]; then
|
|
69
|
+
gh api -X DELETE "repos/$GH_REPO/issues/$NUMBER/labels/needs-info" >/dev/null 2>&1 || true
|
|
70
|
+
exit 0
|
|
71
|
+
fi
|
|
72
|
+
gh label create needs-info --color d4c5f9 --description "Waiting for details from the reporter" 2>/dev/null || true
|
|
73
|
+
gh api -X POST "repos/$GH_REPO/issues/$NUMBER/labels" -f "labels[]=needs-info" >/dev/null || true
|
|
74
|
+
if [ "$asked" = 0 ]; then
|
|
75
|
+
{
|
|
76
|
+
echo "<!-- lanpair-needs-info -->"
|
|
77
|
+
echo "Thank you for the report, @$AUTHOR! To look into it, please add (edit the issue, or reply):"
|
|
78
|
+
echo
|
|
79
|
+
for m in "${missing[@]}"; do echo "- $m"; done
|
|
80
|
+
echo
|
|
81
|
+
echo "The \`needs-info\` label goes away by itself once they are there."
|
|
82
|
+
} > ask.md
|
|
83
|
+
gh issue comment "$NUMBER" --body-file ask.md >/dev/null
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
fixed:
|
|
87
|
+
if: github.event_name == 'pull_request_target' && github.event.pull_request.merged
|
|
88
|
+
runs-on: ubuntu-slim
|
|
89
|
+
permissions:
|
|
90
|
+
contents: read
|
|
91
|
+
issues: write
|
|
92
|
+
pull-requests: read
|
|
93
|
+
steps:
|
|
94
|
+
- env:
|
|
95
|
+
GH_TOKEN: ${{ secrets.AGENT_TOKEN || github.token }}
|
|
96
|
+
GH_REPO: ${{ github.repository }}
|
|
97
|
+
PR: ${{ github.event.pull_request.number }}
|
|
98
|
+
BODY: ${{ github.event.pull_request.body }}
|
|
99
|
+
TITLE: ${{ github.event.pull_request.title }}
|
|
100
|
+
run: |
|
|
101
|
+
set -uo pipefail
|
|
102
|
+
gh label create fixed-in-next-release --color 0e8a16 --description "Fixed on main; ships in the next release" 2>/dev/null || true
|
|
103
|
+
for n in $(printf '%s\n%s' "$TITLE" "$BODY" |
|
|
104
|
+
grep -oiE '(close[sd]?|fix(e[sd])?|resolve[sd]?) +#[0-9]+' | grep -oE '[0-9]+$' | sort -un); do
|
|
105
|
+
# Only issues (not pull requests) of this repository.
|
|
106
|
+
[ "$(gh api "repos/$GH_REPO/issues/$n" -q 'has("pull_request")' 2>/dev/null)" = false ] || continue
|
|
107
|
+
gh api -X POST "repos/$GH_REPO/issues/$n/labels" -f "labels[]=fixed-in-next-release" >/dev/null || true
|
|
108
|
+
printf '%s\n' "<!-- lanpair-fixed -->" "ā
Fixed by #$PR, now on \`main\`. It ships in the next release; I will say here which version has it." > note.md
|
|
109
|
+
gh issue comment "$n" --body-file note.md >/dev/null
|
|
110
|
+
done
|
|
111
|
+
|
|
112
|
+
released:
|
|
113
|
+
if: github.event_name == 'release' && !github.event.release.prerelease
|
|
114
|
+
runs-on: ubuntu-slim
|
|
115
|
+
permissions:
|
|
116
|
+
contents: read
|
|
117
|
+
issues: write
|
|
118
|
+
pull-requests: read
|
|
119
|
+
steps:
|
|
120
|
+
- env:
|
|
121
|
+
GH_TOKEN: ${{ secrets.AGENT_TOKEN || github.token }}
|
|
122
|
+
GH_REPO: ${{ github.repository }}
|
|
123
|
+
TAG: ${{ github.event.release.tag_name }}
|
|
124
|
+
URL: ${{ github.event.release.html_url }}
|
|
125
|
+
run: |
|
|
126
|
+
set -uo pipefail
|
|
127
|
+
for n in $(gh issue list --state all --label fixed-in-next-release --limit 200 --json number -q '.[].number'); do
|
|
128
|
+
printf '%s\n' "<!-- lanpair-released -->" "š The fix is in **lanpair $TAG** ($URL). Update with \`pip install -U lanpair\`." > note.md
|
|
129
|
+
gh issue comment "$n" --body-file note.md >/dev/null
|
|
130
|
+
gh api -X DELETE "repos/$GH_REPO/issues/$n/labels/fixed-in-next-release" >/dev/null 2>&1 || true
|
|
131
|
+
done
|
|
132
|
+
|
|
133
|
+
command:
|
|
134
|
+
if: >-
|
|
135
|
+
github.event_name == 'issue_comment' && !github.event.issue.pull_request &&
|
|
136
|
+
startsWith(github.event.comment.body, '/') &&
|
|
137
|
+
github.event.comment.user.login != 'TonyD365-Agent'
|
|
138
|
+
runs-on: ubuntu-slim
|
|
139
|
+
permissions:
|
|
140
|
+
contents: read
|
|
141
|
+
issues: write
|
|
142
|
+
pull-requests: read
|
|
143
|
+
steps:
|
|
144
|
+
- env:
|
|
145
|
+
GH_TOKEN: ${{ secrets.AGENT_TOKEN || github.token }}
|
|
146
|
+
GH_REPO: ${{ github.repository }}
|
|
147
|
+
NUMBER: ${{ github.event.issue.number }}
|
|
148
|
+
WHO: ${{ github.event.comment.user.login }}
|
|
149
|
+
WHO_ID: ${{ github.event.comment.user.id }}
|
|
150
|
+
AUTHOR_ID: ${{ github.event.issue.user.id }}
|
|
151
|
+
ROLE: ${{ github.event.comment.author_association }}
|
|
152
|
+
BODY: ${{ github.event.comment.body }}
|
|
153
|
+
COMMENT_ID: ${{ github.event.comment.id }}
|
|
154
|
+
run: |
|
|
155
|
+
set -uo pipefail
|
|
156
|
+
line=$(printf '%s' "$BODY" | head -n 1 | tr -d '\r')
|
|
157
|
+
cmd=$(printf '%s' "$line" | awk '{print tolower($1)}')
|
|
158
|
+
rest=$(printf '%s' "$line" | sed -E 's#^/[A-Za-z]+[[:space:]]*##')
|
|
159
|
+
case "$ROLE" in OWNER|MEMBER|COLLABORATOR) maintainer=1 ;; *) maintainer="" ;; esac
|
|
160
|
+
react() { gh api -X POST "repos/$GH_REPO/issues/comments/$COMMENT_ID/reactions" -f content="$1" >/dev/null || true; }
|
|
161
|
+
reply() { printf '%s\n' "$@" > reply.md; gh issue comment "$NUMBER" --body-file reply.md >/dev/null; }
|
|
162
|
+
deny() { react confused; reply "Sorry @$WHO, \`$cmd\` is for $1."; exit 0; }
|
|
163
|
+
case "$cmd" in
|
|
164
|
+
/help)
|
|
165
|
+
react eyes
|
|
166
|
+
reply "Commands for this issue (at the start of a comment):" "" \
|
|
167
|
+
"- \`/close\`, \`/reopen\`: close or reopen it (whoever opened it, or a maintainer)." \
|
|
168
|
+
"- \`/label name ...\`, \`/unlabel name ...\`: add or remove labels (maintainers)." \
|
|
169
|
+
"- \`/help\`: this list."
|
|
170
|
+
;;
|
|
171
|
+
/close|/reopen)
|
|
172
|
+
[ "$WHO_ID" = "$AUTHOR_ID" ] || [ -n "$maintainer" ] || deny "whoever opened the issue, or a maintainer"
|
|
173
|
+
state=closed; [ "$cmd" = /reopen ] && state=open
|
|
174
|
+
gh api -X PATCH "repos/$GH_REPO/issues/$NUMBER" -f state="$state" >/dev/null
|
|
175
|
+
react "+1"
|
|
176
|
+
;;
|
|
177
|
+
/label|/unlabel)
|
|
178
|
+
[ -n "$maintainer" ] || deny "maintainers (the repository's owner and collaborators)"
|
|
179
|
+
[ -n "$rest" ] || { reply "Usage: \`$cmd name\` (several names separated by spaces or commas)."; exit 0; }
|
|
180
|
+
done_list=""
|
|
181
|
+
# Split on spaces and commas without expanding * or ? against the runner's files.
|
|
182
|
+
IFS=', ' read -ra names <<<"$rest"
|
|
183
|
+
for name in "${names[@]}"; do
|
|
184
|
+
if [ "$cmd" = /label ]; then
|
|
185
|
+
gh label create "$name" --color ededed 2>/dev/null || true
|
|
186
|
+
gh api -X POST "repos/$GH_REPO/issues/$NUMBER/labels" -f "labels[]=$name" >/dev/null && done_list="$done_list \`$name\`"
|
|
187
|
+
else
|
|
188
|
+
gh api -X DELETE "repos/$GH_REPO/issues/$NUMBER/labels/$(jq -rn --arg n "$name" '$n|@uri')" >/dev/null 2>&1 && done_list="$done_list \`$name\`"
|
|
189
|
+
fi
|
|
190
|
+
done
|
|
191
|
+
react "+1"
|
|
192
|
+
if [ "$cmd" = /label ]; then reply "Added:${done_list:- nothing}"; else reply "Removed:${done_list:- nothing}"; fi
|
|
193
|
+
;;
|
|
194
|
+
esac
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Step 2 of labelling pull requests (see labeler.yml). This runs the workflow file
|
|
2
|
+
# from main, never from the pull request, so its write access stays safe.
|
|
3
|
+
name: Apply pull request labels
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
workflow_run: # zizmor: ignore[dangerous-triggers] -- reviewed: never runs PR code
|
|
7
|
+
workflows: [Label pull requests]
|
|
8
|
+
types: [completed]
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
actions: read
|
|
12
|
+
contents: read
|
|
13
|
+
pull-requests: write
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
label:
|
|
17
|
+
if: github.event.workflow_run.conclusion == 'success'
|
|
18
|
+
runs-on: ubuntu-slim
|
|
19
|
+
steps:
|
|
20
|
+
# Into a folder of its own: the artifact comes from the pull request's run, so nothing
|
|
21
|
+
# in it may land where the labeler looks for its config (that is read from main).
|
|
22
|
+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
23
|
+
with:
|
|
24
|
+
name: pr-number
|
|
25
|
+
path: ${{ runner.temp }}/pr
|
|
26
|
+
run-id: ${{ github.event.workflow_run.id }}
|
|
27
|
+
github-token: ${{ github.token }}
|
|
28
|
+
- id: pr
|
|
29
|
+
# The number comes from a fork's run: accept nothing but digits, and only the pull
|
|
30
|
+
# request that run was for (same head commit), not any other.
|
|
31
|
+
env:
|
|
32
|
+
GH_TOKEN: ${{ github.token }}
|
|
33
|
+
GH_REPO: ${{ github.repository }}
|
|
34
|
+
FILE: ${{ runner.temp }}/pr/pr-number
|
|
35
|
+
SHA: ${{ github.event.workflow_run.head_sha }}
|
|
36
|
+
run: |
|
|
37
|
+
number=$(head -c 12 "$FILE" | tr -d '\n')
|
|
38
|
+
[[ "$number" =~ ^[0-9]+$ ]] || { echo "Not a pull request number"; exit 1; }
|
|
39
|
+
head=$(gh api "repos/$GH_REPO/pulls/$number" -q .head.sha)
|
|
40
|
+
[ "$head" = "$SHA" ] || { echo "Pull request $number is not the one that run was for"; exit 1; }
|
|
41
|
+
echo "number=$number" >> "$GITHUB_OUTPUT"
|
|
42
|
+
- uses: actions/labeler@bf12e9b00b37c5c0ca2b87b79b2daf7891dbda13 # v7
|
|
43
|
+
with:
|
|
44
|
+
pr-number: ${{ steps.pr.outputs.number }}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Labels pull requests by the parts of lanpair they touch (.github/labeler.yml).
|
|
2
|
+
# Two steps, so a pull request from a fork is labelled too without its code ever
|
|
3
|
+
# getting write access:
|
|
4
|
+
# 1. This job runs on pull_request with a read-only token and only saves the
|
|
5
|
+
# pull request's number.
|
|
6
|
+
# 2. label-apply.yml runs afterwards from main, with write access, and labels
|
|
7
|
+
# that pull request from the list of changed files. It never runs its code.
|
|
8
|
+
name: Label pull requests
|
|
9
|
+
|
|
10
|
+
on:
|
|
11
|
+
pull_request:
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
note:
|
|
18
|
+
runs-on: ubuntu-slim
|
|
19
|
+
steps:
|
|
20
|
+
- run: echo "${{ github.event.pull_request.number }}" > pr-number
|
|
21
|
+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
22
|
+
with:
|
|
23
|
+
name: pr-number
|
|
24
|
+
path: pr-number
|
|
25
|
+
retention-days: 1
|