BeatKeeper 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.
- beatkeeper-0.1.0/.github/ISSUE_TEMPLATE/01.feature.yml +37 -0
- beatkeeper-0.1.0/.github/ISSUE_TEMPLATE/02.bug.yml +62 -0
- beatkeeper-0.1.0/.github/ISSUE_TEMPLATE/03.fix.yml +55 -0
- beatkeeper-0.1.0/.github/ISSUE_TEMPLATE/04.task.yml +38 -0
- beatkeeper-0.1.0/.github/ISSUE_TEMPLATE/config.yml +1 -0
- beatkeeper-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +24 -0
- beatkeeper-0.1.0/.github/workflows/ci.yml +378 -0
- beatkeeper-0.1.0/.github/workflows/scripts/check_distributions.py +275 -0
- beatkeeper-0.1.0/.github/workflows/scripts/plan_release.py +216 -0
- beatkeeper-0.1.0/.github/workflows/scripts/prepare_upload.py +96 -0
- beatkeeper-0.1.0/.github/workflows/scripts/tests/__init__.py +0 -0
- beatkeeper-0.1.0/.github/workflows/scripts/tests/test_plan_release.py +204 -0
- beatkeeper-0.1.0/.github/workflows/scripts/tests/test_release.py +228 -0
- beatkeeper-0.1.0/.github/workflows/scripts/tests/test_release_notes.py +78 -0
- beatkeeper-0.1.0/.gitignore +54 -0
- beatkeeper-0.1.0/BeatKeeper.egg-info/PKG-INFO +150 -0
- beatkeeper-0.1.0/BeatKeeper.egg-info/SOURCES.txt +36 -0
- beatkeeper-0.1.0/BeatKeeper.egg-info/dependency_links.txt +1 -0
- beatkeeper-0.1.0/BeatKeeper.egg-info/top_level.txt +1 -0
- beatkeeper-0.1.0/LICENSE +674 -0
- beatkeeper-0.1.0/PKG-INFO +150 -0
- beatkeeper-0.1.0/README.md +125 -0
- beatkeeper-0.1.0/samples/sample.py +149 -0
- beatkeeper-0.1.0/setup.cfg +4 -0
- beatkeeper-0.1.0/setup.py +89 -0
- beatkeeper-0.1.0/src/Calendar.py +57 -0
- beatkeeper-0.1.0/src/Cron.py +152 -0
- beatkeeper-0.1.0/src/Executor.py +246 -0
- beatkeeper-0.1.0/src/Pool.py +116 -0
- beatkeeper-0.1.0/src/Properties.py +27 -0
- beatkeeper-0.1.0/src/Startup.py +114 -0
- beatkeeper-0.1.0/src/Task.py +119 -0
- beatkeeper-0.1.0/src/Worker.py +198 -0
- beatkeeper-0.1.0/src/__init__.py +41 -0
- beatkeeper-0.1.0/tests/test_cron.py +134 -0
- beatkeeper-0.1.0/tests/test_pools.py +487 -0
- beatkeeper-0.1.0/tests/test_task.py +202 -0
- beatkeeper-0.1.0/tests/test_worker.py +921 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: 기능 제안
|
|
2
|
+
description: 추가하거나 개선할 기능을 제안합니다.
|
|
3
|
+
labels:
|
|
4
|
+
- feature
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: >
|
|
9
|
+
해결하려는 문제와 제안하는 사용 경험을 중심으로 작성해 주세요.
|
|
10
|
+
- type: textarea
|
|
11
|
+
id: problem
|
|
12
|
+
attributes:
|
|
13
|
+
label: 해결하려는 문제
|
|
14
|
+
description: 현재 어떤 불편이나 제약이 있는지 설명해 주세요.
|
|
15
|
+
validations:
|
|
16
|
+
required: true
|
|
17
|
+
- type: textarea
|
|
18
|
+
id: proposal
|
|
19
|
+
attributes:
|
|
20
|
+
label: 제안하는 해결 방법
|
|
21
|
+
description: 원하는 기능과 기대하는 동작을 설명해 주세요.
|
|
22
|
+
validations:
|
|
23
|
+
required: true
|
|
24
|
+
- type: textarea
|
|
25
|
+
id: alternatives
|
|
26
|
+
attributes:
|
|
27
|
+
label: 고려한 대안
|
|
28
|
+
description: 고려한 다른 방법이나 우회 방법이 있다면 적어 주세요.
|
|
29
|
+
validations:
|
|
30
|
+
required: false
|
|
31
|
+
- type: textarea
|
|
32
|
+
id: additional
|
|
33
|
+
attributes:
|
|
34
|
+
label: 추가 정보
|
|
35
|
+
description: 예제, 참고 자료 등 제안의 맥락을 이해하는 데 도움이 되는 정보를 적어 주세요.
|
|
36
|
+
validations:
|
|
37
|
+
required: false
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
name: 버그/오류 제보
|
|
2
|
+
description: 예상과 다르게 동작하거나 오류가 발생하는 문제를 제보합니다.
|
|
3
|
+
labels:
|
|
4
|
+
- bug
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: >
|
|
9
|
+
재현 가능한 버그를 제보해 주세요. 로그나 설정을 첨부할 때 토큰, 비밀번호,
|
|
10
|
+
개인정보 등 민감한 정보는 반드시 삭제해 주세요.
|
|
11
|
+
- type: input
|
|
12
|
+
id: version
|
|
13
|
+
attributes:
|
|
14
|
+
label: 버전
|
|
15
|
+
description: 사용 중인 버전 또는 커밋을 입력해 주세요.
|
|
16
|
+
placeholder: 예) 0.1.12
|
|
17
|
+
validations:
|
|
18
|
+
required: true
|
|
19
|
+
- type: textarea
|
|
20
|
+
id: expected
|
|
21
|
+
attributes:
|
|
22
|
+
label: 기대한 동작
|
|
23
|
+
description: 어떤 결과를 기대했는지 설명해 주세요.
|
|
24
|
+
validations:
|
|
25
|
+
required: true
|
|
26
|
+
- type: textarea
|
|
27
|
+
id: actual
|
|
28
|
+
attributes:
|
|
29
|
+
label: 실제 동작
|
|
30
|
+
description: 실제로 발생한 결과를 설명해 주세요. 오류가 표시되면 메시지도 포함해 주세요.
|
|
31
|
+
validations:
|
|
32
|
+
required: true
|
|
33
|
+
- type: textarea
|
|
34
|
+
id: reproduction
|
|
35
|
+
attributes:
|
|
36
|
+
label: 재현 방법
|
|
37
|
+
description: 문제를 재현하는 단계나 최소 코드 예제를 작성해 주세요.
|
|
38
|
+
placeholder: |
|
|
39
|
+
1. 다음 설정으로 Worker를 시작합니다.
|
|
40
|
+
2. 특정 메시지를 전달합니다.
|
|
41
|
+
3. 오류가 발생합니다.
|
|
42
|
+
validations:
|
|
43
|
+
required: true
|
|
44
|
+
- type: textarea
|
|
45
|
+
id: environment
|
|
46
|
+
attributes:
|
|
47
|
+
label: 실행 환경
|
|
48
|
+
description: Python 버전, 운영체제, 브로커 및 관련 어댑터 버전을 입력해 주세요.
|
|
49
|
+
placeholder: |
|
|
50
|
+
- Python:
|
|
51
|
+
- 운영체제:
|
|
52
|
+
- 브로커:
|
|
53
|
+
- 어댑터:
|
|
54
|
+
validations:
|
|
55
|
+
required: true
|
|
56
|
+
- type: textarea
|
|
57
|
+
id: additional
|
|
58
|
+
attributes:
|
|
59
|
+
label: 추가 정보
|
|
60
|
+
description: 관련 로그나 스크린샷 등 문제 파악에 도움이 되는 정보를 적어 주세요.
|
|
61
|
+
validations:
|
|
62
|
+
required: false
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: 변경 제안
|
|
2
|
+
description: 일반 변경이나 핫픽스의 목적과 범위를 정리합니다.
|
|
3
|
+
labels:
|
|
4
|
+
- fix
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: >
|
|
9
|
+
일반 변경이나 긴급 수정이 필요한 핫픽스를 제안할 때 사용해 주세요.
|
|
10
|
+
재현 가능한 기존 결함은 버그/오류 제보 양식을 이용해 주세요.
|
|
11
|
+
- type: dropdown
|
|
12
|
+
id: change_type
|
|
13
|
+
attributes:
|
|
14
|
+
label: 변경 유형
|
|
15
|
+
description: 제안하는 변경의 성격을 선택해 주세요.
|
|
16
|
+
options:
|
|
17
|
+
- 일반 변경
|
|
18
|
+
- 핫픽스
|
|
19
|
+
validations:
|
|
20
|
+
required: true
|
|
21
|
+
- type: textarea
|
|
22
|
+
id: purpose
|
|
23
|
+
attributes:
|
|
24
|
+
label: 변경 목적
|
|
25
|
+
description: 왜 이 변경이 필요한지, 해결하려는 불편이나 상황을 설명해 주세요.
|
|
26
|
+
validations:
|
|
27
|
+
required: true
|
|
28
|
+
- type: textarea
|
|
29
|
+
id: proposed_changes
|
|
30
|
+
attributes:
|
|
31
|
+
label: 제안하는 변경 내용
|
|
32
|
+
description: 무엇을 어떻게 바꾸면 좋을지 적어 주세요.
|
|
33
|
+
validations:
|
|
34
|
+
required: true
|
|
35
|
+
- type: textarea
|
|
36
|
+
id: scope
|
|
37
|
+
attributes:
|
|
38
|
+
label: 영향 범위
|
|
39
|
+
description: 영향을 받는 기능, 사용자, 호환성 또는 설정을 알고 있다면 적어 주세요.
|
|
40
|
+
validations:
|
|
41
|
+
required: false
|
|
42
|
+
- type: textarea
|
|
43
|
+
id: hotfix_context
|
|
44
|
+
attributes:
|
|
45
|
+
label: 긴급 수정 정보
|
|
46
|
+
description: 핫픽스인 경우 긴급한 이유, 영향받는 버전 및 임시 대응 방법을 적어 주세요.
|
|
47
|
+
validations:
|
|
48
|
+
required: false
|
|
49
|
+
- type: textarea
|
|
50
|
+
id: acceptance_criteria
|
|
51
|
+
attributes:
|
|
52
|
+
label: 완료 기준
|
|
53
|
+
description: 변경이 완료되었다고 판단할 수 있는 조건이나 검증 방법을 적어 주세요.
|
|
54
|
+
validations:
|
|
55
|
+
required: false
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: 작업 제안
|
|
2
|
+
description: 리소스 변경, 문서화 등 소스 코드 변경이 아닌 작업을 정리합니다.
|
|
3
|
+
labels:
|
|
4
|
+
- task
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: >
|
|
9
|
+
리소스 변경, 문서 작성·정리 등 소스 코드를 변경하지 않는 작업에 사용해 주세요.
|
|
10
|
+
기능 추가, 버그 제보 또는 소스 코드 변경은 해당 이슈 양식을 이용해 주세요.
|
|
11
|
+
- type: textarea
|
|
12
|
+
id: purpose
|
|
13
|
+
attributes:
|
|
14
|
+
label: 작업 목적
|
|
15
|
+
description: 이 작업이 필요한 이유와 기대하는 효과를 설명해 주세요.
|
|
16
|
+
validations:
|
|
17
|
+
required: true
|
|
18
|
+
- type: textarea
|
|
19
|
+
id: scope
|
|
20
|
+
attributes:
|
|
21
|
+
label: 작업 내용 및 대상
|
|
22
|
+
description: 수행할 작업과 대상 리소스, 문서 또는 경로를 적어 주세요.
|
|
23
|
+
validations:
|
|
24
|
+
required: true
|
|
25
|
+
- type: textarea
|
|
26
|
+
id: acceptance_criteria
|
|
27
|
+
attributes:
|
|
28
|
+
label: 완료 기준
|
|
29
|
+
description: 작업이 완료되었다고 판단할 수 있는 결과물이나 확인 방법을 적어 주세요.
|
|
30
|
+
validations:
|
|
31
|
+
required: true
|
|
32
|
+
- type: textarea
|
|
33
|
+
id: additional
|
|
34
|
+
attributes:
|
|
35
|
+
label: 관련 자료 및 주의사항
|
|
36
|
+
description: 참고 링크, 관련 이슈, 사전 준비나 주의사항이 있다면 적어 주세요.
|
|
37
|
+
validations:
|
|
38
|
+
required: false
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
blank_issues_enabled: false
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
## 변경 내용
|
|
2
|
+
|
|
3
|
+
<!-- 무엇을 왜 변경했는지 간단히 요약해 주세요. -->
|
|
4
|
+
|
|
5
|
+
## 변경 유형
|
|
6
|
+
|
|
7
|
+
- [ ] 버그 수정 및 일반 변경, 핫픽스 처리
|
|
8
|
+
- [ ] 기능 추가
|
|
9
|
+
- [ ] 호환성에 영향을 주는 변경
|
|
10
|
+
- [ ] 문서 또는 예제 변경
|
|
11
|
+
- [ ] 기타
|
|
12
|
+
|
|
13
|
+
## 검증
|
|
14
|
+
|
|
15
|
+
<!-- 실행한 테스트와 결과를 작성해 주세요. 테스트를 실행하지 않았다면 사유를 적어 주세요. -->
|
|
16
|
+
|
|
17
|
+
- [ ] 관련 테스트를 실행했습니다.
|
|
18
|
+
- [ ] 문서와 예제를 확인했습니다.
|
|
19
|
+
|
|
20
|
+
## 확인 사항
|
|
21
|
+
|
|
22
|
+
- [ ] 변경 범위가 요청 사항에 한정되어 있습니다.
|
|
23
|
+
- [ ] 공개 API나 기존 동작에 영향을 주는 경우 변경 내용과 마이그레이션 방법을 설명했습니다.
|
|
24
|
+
- [ ] 민감 정보나 불필요한 디버깅 코드를 포함하지 않았습니다.
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [master]
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
13
|
+
cancel-in-progress: false
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
changes:
|
|
17
|
+
name: Prepare CI and master release metadata
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
issues: read
|
|
21
|
+
pull-requests: read
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
timeout-minutes: 5
|
|
24
|
+
outputs:
|
|
25
|
+
release: ${{ steps.changes.outputs.release }}
|
|
26
|
+
version: ${{ steps.changes.outputs.version }}
|
|
27
|
+
build: ${{ steps.changes.outputs.build }}
|
|
28
|
+
new_version: ${{ steps.changes.outputs.new_version }}
|
|
29
|
+
tag: ${{ steps.changes.outputs.tag }}
|
|
30
|
+
head_sha: ${{ steps.changes.outputs.head_sha }}
|
|
31
|
+
head_repository: ${{ steps.changes.outputs.head_repository }}
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v7
|
|
34
|
+
with:
|
|
35
|
+
fetch-depth: 0
|
|
36
|
+
persist-credentials: false
|
|
37
|
+
- name: Set up release planner Python
|
|
38
|
+
uses: actions/setup-python@v7
|
|
39
|
+
with:
|
|
40
|
+
python-version: '3.13'
|
|
41
|
+
- name: Plan version from linked issues
|
|
42
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
43
|
+
id: changes
|
|
44
|
+
env:
|
|
45
|
+
BEFORE: ${{ github.event.before }}
|
|
46
|
+
GH_TOKEN: ${{ github.token }}
|
|
47
|
+
run: python .github/workflows/scripts/plan_release.py
|
|
48
|
+
- name: Collect branch changelog for release
|
|
49
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.changes.outputs.release == 'true'
|
|
50
|
+
env:
|
|
51
|
+
GH_TOKEN: ${{ github.token }}
|
|
52
|
+
NEW_VERSION: ${{ steps.changes.outputs.new_version }}
|
|
53
|
+
RELEASE_TAG: ${{ steps.changes.outputs.tag }}
|
|
54
|
+
HEAD_SHA: ${{ steps.changes.outputs.head_sha }}
|
|
55
|
+
HEAD_REPOSITORY: ${{ steps.changes.outputs.head_repository }}
|
|
56
|
+
run: |
|
|
57
|
+
python - <<'PY'
|
|
58
|
+
from json import loads
|
|
59
|
+
from os import environ
|
|
60
|
+
from pathlib import Path
|
|
61
|
+
from subprocess import CalledProcessError, check_output
|
|
62
|
+
|
|
63
|
+
repository = environ['GITHUB_REPOSITORY']
|
|
64
|
+
if environ['NEW_VERSION'] == 'false':
|
|
65
|
+
tag = environ['RELEASE_TAG']
|
|
66
|
+
release = loads(check_output([
|
|
67
|
+
'gh', 'api', f'repos/{repository}/releases/tags/{tag}',
|
|
68
|
+
]))
|
|
69
|
+
if release['tag_name'] != tag or not release.get('body', '').strip():
|
|
70
|
+
raise ValueError(f'Existing release notes are missing or empty: {tag}')
|
|
71
|
+
body = release['body'].encode('utf-8')
|
|
72
|
+
print(f'Reusing release notes unchanged: {tag}')
|
|
73
|
+
else:
|
|
74
|
+
sha = environ['HEAD_SHA']
|
|
75
|
+
source_repository = environ['HEAD_REPOSITORY']
|
|
76
|
+
tag = f'changes/{sha}'
|
|
77
|
+
where = f'tag {tag} in {source_repository}'
|
|
78
|
+
try:
|
|
79
|
+
ref = loads(check_output([
|
|
80
|
+
'gh', 'api', f'repos/{source_repository}/git/ref/tags/{tag}',
|
|
81
|
+
]))
|
|
82
|
+
except CalledProcessError as error:
|
|
83
|
+
raise ValueError(f'Release notes tag not found: {where}') from error
|
|
84
|
+
if ref['object']['type'] != 'tag':
|
|
85
|
+
raise ValueError(f'Release notes tag must be an annotated tag: {where}')
|
|
86
|
+
annotated = loads(check_output([
|
|
87
|
+
'gh', 'api', f'repos/{source_repository}/git/tags/{ref["object"]["sha"]}',
|
|
88
|
+
]))
|
|
89
|
+
message = annotated.get('message') or ''
|
|
90
|
+
if not message.strip():
|
|
91
|
+
raise ValueError(f'Release notes tag message is empty: {where}')
|
|
92
|
+
body = message.encode('utf-8')
|
|
93
|
+
print(f'Release notes: annotated {where}')
|
|
94
|
+
notes = Path(environ['RUNNER_TEMP'], 'release-notes', 'README.md')
|
|
95
|
+
notes.parent.mkdir(parents=True, exist_ok=True)
|
|
96
|
+
notes.write_bytes(body)
|
|
97
|
+
PY
|
|
98
|
+
- name: Preserve customer release notes
|
|
99
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.changes.outputs.release == 'true'
|
|
100
|
+
uses: actions/upload-artifact@v7
|
|
101
|
+
with:
|
|
102
|
+
name: release-notes
|
|
103
|
+
path: ${{ runner.temp }}/release-notes/README.md
|
|
104
|
+
if-no-files-found: error
|
|
105
|
+
retention-days: 14
|
|
106
|
+
overwrite: true
|
|
107
|
+
|
|
108
|
+
test:
|
|
109
|
+
name: Test Python ${{ matrix.python }}
|
|
110
|
+
needs: changes
|
|
111
|
+
runs-on: ubuntu-latest
|
|
112
|
+
timeout-minutes: 25
|
|
113
|
+
strategy:
|
|
114
|
+
fail-fast: false
|
|
115
|
+
matrix:
|
|
116
|
+
python: ['3.10', '3.12', '3.13', '3.14']
|
|
117
|
+
env:
|
|
118
|
+
PROJECT: BeatKeeper
|
|
119
|
+
steps:
|
|
120
|
+
- name: Check out core
|
|
121
|
+
uses: actions/checkout@v7
|
|
122
|
+
with:
|
|
123
|
+
ref: ${{ github.sha }}
|
|
124
|
+
fetch-depth: 0
|
|
125
|
+
persist-credentials: false
|
|
126
|
+
|
|
127
|
+
- name: Set up Python
|
|
128
|
+
uses: actions/setup-python@v7
|
|
129
|
+
with:
|
|
130
|
+
python-version: ${{ matrix.python }}
|
|
131
|
+
|
|
132
|
+
- name: Record source commits and configure candidate version
|
|
133
|
+
env:
|
|
134
|
+
RELEASE_BUILD: ${{ needs.changes.outputs.release }}
|
|
135
|
+
RELEASE_VERSION: ${{ needs.changes.outputs.version }}
|
|
136
|
+
run: |
|
|
137
|
+
echo "$PROJECT: $(git rev-parse HEAD)"
|
|
138
|
+
echo "SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD)" >> "$GITHUB_ENV"
|
|
139
|
+
python - <<'PY'
|
|
140
|
+
from os import environ
|
|
141
|
+
from pathlib import Path
|
|
142
|
+
from re import fullmatch
|
|
143
|
+
|
|
144
|
+
project = environ['PROJECT']
|
|
145
|
+
if project != 'BeatKeeper':
|
|
146
|
+
raise ValueError(f'Unexpected project: {project}')
|
|
147
|
+
if environ['RELEASE_BUILD'] != 'true':
|
|
148
|
+
print('Test-only build: using the existing Git-derived development version.')
|
|
149
|
+
raise SystemExit(0)
|
|
150
|
+
version = environ['RELEASE_VERSION']
|
|
151
|
+
if fullmatch(r'(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)', version) is None:
|
|
152
|
+
raise ValueError(f'Invalid planned version: {version!r}')
|
|
153
|
+
with Path(environ['GITHUB_ENV']).open('a', encoding='utf-8') as output:
|
|
154
|
+
output.write(f'RELEASE_VERSION={version}\n')
|
|
155
|
+
print(f'{project}: candidate {version}')
|
|
156
|
+
with Path(environ['GITHUB_STEP_SUMMARY']).open('a', encoding='utf-8') as summary:
|
|
157
|
+
summary.write(f'## {project} {version}\n\nSource: `{environ["GITHUB_SHA"]}`\n')
|
|
158
|
+
PY
|
|
159
|
+
|
|
160
|
+
- name: Install build tools
|
|
161
|
+
run: python -m pip install --upgrade "pip>=23" build twine wheel "setuptools>=77" "setuptools-scm>=8,<10"
|
|
162
|
+
|
|
163
|
+
- name: Build source distributions and wheels
|
|
164
|
+
env:
|
|
165
|
+
RELEASE_BUILD: ${{ needs.changes.outputs.release }}
|
|
166
|
+
NEW_VERSION: ${{ needs.changes.outputs.new_version }}
|
|
167
|
+
WHEEL_BUILD: ${{ needs.changes.outputs.build }}
|
|
168
|
+
run: |
|
|
169
|
+
mkdir -p dist
|
|
170
|
+
if [ "$RELEASE_BUILD" = "true" ]; then
|
|
171
|
+
if [ "$NEW_VERSION" = "true" ]; then
|
|
172
|
+
SETUPTOOLS_SCM_PRETEND_VERSION="$RELEASE_VERSION" python -m build
|
|
173
|
+
else
|
|
174
|
+
SETUPTOOLS_SCM_PRETEND_VERSION="$RELEASE_VERSION" python -m build --wheel
|
|
175
|
+
fi
|
|
176
|
+
python -m wheel tags --build "$WHEEL_BUILD" --remove dist/*.whl
|
|
177
|
+
else
|
|
178
|
+
python -m build
|
|
179
|
+
fi
|
|
180
|
+
python -m twine check --strict dist/*
|
|
181
|
+
|
|
182
|
+
- name: Normalize source archive timestamps
|
|
183
|
+
run: |
|
|
184
|
+
python - <<'PY'
|
|
185
|
+
from gzip import GzipFile
|
|
186
|
+
from io import BytesIO
|
|
187
|
+
from os import environ
|
|
188
|
+
from pathlib import Path
|
|
189
|
+
from tarfile import open as open_tar
|
|
190
|
+
|
|
191
|
+
epoch = int(environ['SOURCE_DATE_EPOCH'])
|
|
192
|
+
for path in Path('dist').glob('*.tar.gz'):
|
|
193
|
+
with BytesIO() as buffer:
|
|
194
|
+
with open_tar(path, 'r:gz') as source:
|
|
195
|
+
with GzipFile(fileobj=buffer, mode='wb', filename='', mtime=epoch) as compressed:
|
|
196
|
+
with open_tar(fileobj=compressed, mode='w') as target:
|
|
197
|
+
for member in sorted(source.getmembers(), key=lambda item: item.name):
|
|
198
|
+
member.mtime = epoch
|
|
199
|
+
member.uid = member.gid = 0
|
|
200
|
+
member.uname = member.gname = ''
|
|
201
|
+
member.pax_headers = {
|
|
202
|
+
key: value for key, value in member.pax_headers.items()
|
|
203
|
+
if key not in ('mtime', 'atime', 'ctime')
|
|
204
|
+
}
|
|
205
|
+
target.addfile(member, source.extractfile(member) if member.isfile() else None)
|
|
206
|
+
path.write_bytes(buffer.getvalue())
|
|
207
|
+
PY
|
|
208
|
+
|
|
209
|
+
- name: Install package
|
|
210
|
+
run: python -m pip install --editable .
|
|
211
|
+
- name: Run tests
|
|
212
|
+
run: python -m unittest discover -s tests -v
|
|
213
|
+
- name: Verify distributions and installation
|
|
214
|
+
run: python .github/workflows/scripts/check_distributions.py --editable
|
|
215
|
+
- name: Test release preparation
|
|
216
|
+
run: python -m unittest discover -s .github/workflows/scripts/tests -t .github/workflows/scripts -p 'test_*.py'
|
|
217
|
+
|
|
218
|
+
- name: Preserve verified release distributions
|
|
219
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && needs.changes.outputs.release == 'true' && matrix.python == '3.13'
|
|
220
|
+
uses: actions/upload-artifact@v7
|
|
221
|
+
with:
|
|
222
|
+
name: distributions
|
|
223
|
+
path: dist/*
|
|
224
|
+
if-no-files-found: error
|
|
225
|
+
retention-days: 14
|
|
226
|
+
|
|
227
|
+
publish:
|
|
228
|
+
name: Publish PyPI
|
|
229
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && needs.changes.outputs.release == 'true'
|
|
230
|
+
needs: [changes, test]
|
|
231
|
+
runs-on: ubuntu-latest
|
|
232
|
+
timeout-minutes: 10
|
|
233
|
+
environment: pypi
|
|
234
|
+
permissions:
|
|
235
|
+
contents: write
|
|
236
|
+
steps:
|
|
237
|
+
- name: Check out release source for tagging
|
|
238
|
+
uses: actions/checkout@v7
|
|
239
|
+
with:
|
|
240
|
+
ref: ${{ github.sha }}
|
|
241
|
+
path: release-source
|
|
242
|
+
fetch-depth: 0
|
|
243
|
+
|
|
244
|
+
- name: Download verified distributions
|
|
245
|
+
uses: actions/download-artifact@v8
|
|
246
|
+
with:
|
|
247
|
+
name: distributions
|
|
248
|
+
path: dist
|
|
249
|
+
|
|
250
|
+
- name: Download customer release notes
|
|
251
|
+
uses: actions/download-artifact@v8
|
|
252
|
+
with:
|
|
253
|
+
name: release-notes
|
|
254
|
+
path: release-notes
|
|
255
|
+
|
|
256
|
+
- name: Set up Python
|
|
257
|
+
uses: actions/setup-python@v7
|
|
258
|
+
with:
|
|
259
|
+
python-version: '3.13'
|
|
260
|
+
|
|
261
|
+
- name: Check release status
|
|
262
|
+
id: release
|
|
263
|
+
env:
|
|
264
|
+
PROJECT: ${{ github.event.repository.name }}
|
|
265
|
+
RELEASE_VERSION: ${{ needs.changes.outputs.version }}
|
|
266
|
+
WHEEL_BUILD: ${{ needs.changes.outputs.build }}
|
|
267
|
+
NEW_VERSION: ${{ needs.changes.outputs.new_version }}
|
|
268
|
+
run: python release-source/.github/workflows/scripts/prepare_upload.py
|
|
269
|
+
|
|
270
|
+
- name: Record verified release tag
|
|
271
|
+
env:
|
|
272
|
+
VERSION: ${{ needs.changes.outputs.tag }}
|
|
273
|
+
NEW_VERSION: ${{ needs.changes.outputs.new_version }}
|
|
274
|
+
run: |
|
|
275
|
+
tag="$VERSION"
|
|
276
|
+
cd release-source
|
|
277
|
+
if git show-ref --verify --quiet "refs/tags/$tag"; then
|
|
278
|
+
if [ "$NEW_VERSION" = "true" ] && [ "$(git rev-parse "$tag^{commit}")" != "$GITHUB_SHA" ]; then
|
|
279
|
+
echo "::error::$tag already points at another commit."
|
|
280
|
+
exit 1
|
|
281
|
+
fi
|
|
282
|
+
else
|
|
283
|
+
if [ "$NEW_VERSION" != "true" ]; then
|
|
284
|
+
echo "::error::Existing release tag is missing: $tag"
|
|
285
|
+
exit 1
|
|
286
|
+
fi
|
|
287
|
+
git tag "$tag" "$GITHUB_SHA"
|
|
288
|
+
fi
|
|
289
|
+
git push origin "refs/tags/$tag"
|
|
290
|
+
|
|
291
|
+
- name: Install upload tool
|
|
292
|
+
if: steps.release.outputs.publish == 'true'
|
|
293
|
+
run: python -m pip install --upgrade twine
|
|
294
|
+
|
|
295
|
+
- name: Upload to PyPI
|
|
296
|
+
if: steps.release.outputs.publish == 'true'
|
|
297
|
+
env:
|
|
298
|
+
TWINE_USERNAME: __token__
|
|
299
|
+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
|
300
|
+
run: |
|
|
301
|
+
if [ -z "$TWINE_PASSWORD" ]; then
|
|
302
|
+
echo "::error::Configure PYPI_API_TOKEN in the pypi environment or repository Actions secrets."
|
|
303
|
+
exit 1
|
|
304
|
+
fi
|
|
305
|
+
python -m twine upload --non-interactive upload/*
|
|
306
|
+
|
|
307
|
+
- name: Publish GitHub Release with verified distributions
|
|
308
|
+
env:
|
|
309
|
+
GH_TOKEN: ${{ github.token }}
|
|
310
|
+
VERSION: ${{ steps.release.outputs.version }}
|
|
311
|
+
RELEASE_TAG: ${{ needs.changes.outputs.tag }}
|
|
312
|
+
WHEEL_BUILD: ${{ needs.changes.outputs.build }}
|
|
313
|
+
NEW_VERSION: ${{ needs.changes.outputs.new_version }}
|
|
314
|
+
run: |
|
|
315
|
+
python - <<'PY'
|
|
316
|
+
from json import load
|
|
317
|
+
from hashlib import sha256
|
|
318
|
+
from os import environ
|
|
319
|
+
from pathlib import Path
|
|
320
|
+
from subprocess import run
|
|
321
|
+
from tempfile import TemporaryDirectory
|
|
322
|
+
from urllib.error import HTTPError
|
|
323
|
+
from urllib.parse import quote
|
|
324
|
+
from urllib.request import Request, urlopen
|
|
325
|
+
|
|
326
|
+
repository = environ['GITHUB_REPOSITORY']
|
|
327
|
+
version = environ['VERSION']
|
|
328
|
+
tag = environ['RELEASE_TAG']
|
|
329
|
+
release = None
|
|
330
|
+
notes = Path('release-notes/README.md')
|
|
331
|
+
if not notes.read_text(encoding='utf-8').strip():
|
|
332
|
+
raise ValueError('Customer release notes are empty')
|
|
333
|
+
request = Request(
|
|
334
|
+
f'{environ["GITHUB_API_URL"]}/repos/{repository}/releases/tags/{quote(tag, safe="")}',
|
|
335
|
+
headers={
|
|
336
|
+
'Authorization': f'Bearer {environ["GH_TOKEN"]}',
|
|
337
|
+
'Accept': 'application/vnd.github+json',
|
|
338
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
339
|
+
},
|
|
340
|
+
)
|
|
341
|
+
try:
|
|
342
|
+
with urlopen(request, timeout=30) as response:
|
|
343
|
+
release = load(response)
|
|
344
|
+
except HTTPError as error:
|
|
345
|
+
if error.code != 404:
|
|
346
|
+
raise
|
|
347
|
+
if environ['NEW_VERSION'] != 'true':
|
|
348
|
+
raise RuntimeError('Existing GitHub Release is missing') from error
|
|
349
|
+
run([
|
|
350
|
+
'gh', 'release', 'create', tag, '--repo', repository,
|
|
351
|
+
'--verify-tag', '--title', version, '--notes-file', str(notes), '--draft',
|
|
352
|
+
], check=True)
|
|
353
|
+
else:
|
|
354
|
+
if release['tag_name'] != tag:
|
|
355
|
+
raise ValueError('GitHub Release does not match the verified version')
|
|
356
|
+
if environ['NEW_VERSION'] != 'true':
|
|
357
|
+
if not (release['body'] or '').strip():
|
|
358
|
+
raise ValueError('Existing release notes are empty')
|
|
359
|
+
notes.write_text(release['body'], encoding='utf-8')
|
|
360
|
+
artifacts = sorted(str(path) for path in Path('dist').iterdir() if path.is_file())
|
|
361
|
+
existing = {asset['name'] for asset in release['assets']} if release is not None else set()
|
|
362
|
+
for artifact in artifacts:
|
|
363
|
+
path = Path(artifact)
|
|
364
|
+
if path.name in existing:
|
|
365
|
+
with TemporaryDirectory() as directory:
|
|
366
|
+
run([
|
|
367
|
+
'gh', 'release', 'download', tag, '--repo', repository,
|
|
368
|
+
'--pattern', path.name, '--dir', directory,
|
|
369
|
+
], check=True)
|
|
370
|
+
if sha256((Path(directory) / path.name).read_bytes()).digest() != sha256(path.read_bytes()).digest():
|
|
371
|
+
raise RuntimeError(f'GitHub asset differs; refusing to overwrite {path.name}')
|
|
372
|
+
else:
|
|
373
|
+
run(['gh', 'release', 'upload', tag, '--repo', repository, artifact], check=True)
|
|
374
|
+
run([
|
|
375
|
+
'gh', 'release', 'edit', tag, '--repo', repository,
|
|
376
|
+
'--notes-file', str(notes), '--draft=false',
|
|
377
|
+
], check=True)
|
|
378
|
+
PY
|