Skip to content

Commit 8092064

Browse files
authored
Merge pull request #12 from zmx27/setup-CI
skpkg: setup CI after migrating tests, src, requirements, and .github folder
2 parents dc66eef + 9691ebc commit 8092064

20 files changed

+634
-70
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Bug Report or Feature Request
3+
about: Report a bug or suggest a new feature!
4+
title: ""
5+
labels: ""
6+
assignees: ""
7+
---
8+
9+
### Problem
10+
11+
<!--
12+
For a bug report, please copy and paste any error messages from the application or command-line here.
13+
For a feature request, please state how the new functionality could benefit the community.
14+
-->
15+
16+
### Proposed solution
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: Release
3+
about: Checklist and communication channel for PyPI and GitHub release
4+
title: "Ready for <version-number> PyPI/GitHub release"
5+
labels: "release"
6+
assignees: ""
7+
---
8+
9+
### PyPI/GitHub rc-release preparation checklist:
10+
11+
- [ ] All PRs/issues attached to the release are merged.
12+
- [ ] All the badges on the README are passing.
13+
- [ ] License information is verified as correct. If you are unsure, please comment below.
14+
- [ ] Locally rendered documentation contains all appropriate pages, including API references (check no modules are
15+
missing), tutorials, and other human-written text is up-to-date with any changes in the code.
16+
- [ ] Installation instructions in the README, documentation, and the website are updated.
17+
- [ ] Successfully run any tutorial examples or do functional testing with the latest Python version.
18+
- [ ] Grammar and writing quality are checked (no typos).
19+
- [ ] Install `pip install build twine`, run `python -m build` and `twine check dist/*` to ensure that the package can be built and is correctly formatted for PyPI release.
20+
21+
Please tag the maintainer (e.g., @username) in the comment here when you are ready for the PyPI/GitHub release. Include any additional comments necessary, such as version information and details about the pre-release here:
22+
23+
### PyPI/GitHub full-release preparation checklist:
24+
25+
- [ ] Create a new conda environment and install the rc from PyPI (`pip install <package-name>==??`)
26+
- [ ] License information on PyPI is correct.
27+
- [ ] Docs are deployed successfully to `https://<github-username-or-orgname>/<package-name>`.
28+
- [ ] Successfully run all tests, tutorial examples or do functional testing.
29+
30+
Please let the maintainer know that all checks are done and the package is ready for full release.
31+
32+
### conda-forge release preparation checklist:
33+
34+
<!-- After the maintainer releases the PyPI package, please check the following when creating a PR for conda-forge release.-->
35+
36+
- [ ] Ensure that the full release has appeared on PyPI successfully.
37+
- [ ] New package dependencies listed in `conda.txt` and `tests.txt` are added to `meta.yaml` in the feedstock.
38+
- [ ] Close any open issues on the feedstock. Reach out to the maintainer if you have questions.
39+
- [ ] Tag the maintainer for conda-forge release.
40+
41+
### Post-release checklist
42+
43+
<!-- Before closing this issue, please complete the following: -->
44+
45+
- [ ] Run tutorial examples and conduct functional testing using the installation guide in the README. Attach screenshots/results as comments.
46+
- [ ] Documentation (README, tutorials, API references, and websites) is deployed without broken links or missing figures.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### What problem does this PR address?
2+
3+
<!-- Provide a brief overview and link to the issue. Attach outputs, including screenshots (before/after), if helpful for the reviewer. -->
4+
5+
### What should the reviewer(s) do?
6+
7+
<!-- Merge the code, provide feedback, initiate a discussion, etc. -->
8+
9+
<!--
10+
Use the following checklist items when applicable (select only what applies):
11+
- [ ] This PR introduces a public-facing change (e.g., figures, CLI input/output, API).
12+
- [ ] Documentation (e.g., tutorials, examples, README) has been updated.
13+
- [ ] A tracking issue or plan to update documentation exists.
14+
- [ ] This PR affects internal functionality only (no user-facing change).
15+
-->
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
name: Release on GitHub
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
PAT_TOKEN:
7+
description: "GitHub Personal Access Token"
8+
required: true
9+
10+
env:
11+
TAG: ${{ github.ref_name }}
12+
13+
defaults:
14+
run:
15+
shell: bash {0}
16+
17+
jobs:
18+
prepare-release:
19+
if: ${{ ! contains(github.ref, 'rc') }}
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout the repository
23+
uses: actions/checkout@v4
24+
with:
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
fetch-depth: 0
27+
ref: main
28+
29+
- name: Update CHANGELOG
30+
run: |
31+
wget https://raw.githubusercontent.com/scikit-package/release-scripts/v0/.github/workflows/update-changelog.py
32+
python update-changelog.py "$TAG"
33+
rm update-changelog.py
34+
35+
- name: Commit updated CHANGELOG.rst
36+
run: |
37+
git config user.name "github-actions[bot]"
38+
git config user.email "github-actions[bot]@users.noreply.github.com"
39+
git add .
40+
if ! git diff --cached --quiet; then
41+
git commit -m "update changelog for $TAG"
42+
git push origin main
43+
else
44+
echo "No CHANGELOG.rst changes"
45+
fi
46+
47+
- name: New tag
48+
run: |
49+
git fetch --tags
50+
git tag -d "$TAG" 2>/dev/null || true
51+
git push origin ":$TAG" 2>/dev/null || true
52+
git tag "$TAG"
53+
git push origin "$TAG"
54+
55+
- name: Get CHANGELOG.txt
56+
run: |
57+
wget https://raw.githubusercontent.com/scikit-package/release-scripts/v0/.github/workflows/get-latest-changelog.py
58+
python get-latest-changelog.py "$TAG"
59+
rm get-latest-changelog.py
60+
61+
- name: Upload changelog.txt
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: changelog
65+
path: CHANGELOG.txt
66+
67+
release:
68+
needs: [prepare-release]
69+
if: always()
70+
runs-on: ubuntu-latest
71+
env:
72+
REPO_FULL: ${{ github.repository }}
73+
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
74+
steps:
75+
- name: Check prepare release
76+
run: |
77+
if [[ ${{ needs.prepare-release.result }} != 'success' && "$TAG" != *rc* ]]; then
78+
echo "::error::Skipping release job because prepare-release failed"
79+
exit 78
80+
fi
81+
echo "Continuing with release job"
82+
83+
- name: Download built wheels
84+
uses: actions/download-artifact@v4
85+
with:
86+
path: dist/
87+
88+
- name: Download changelog
89+
if: ${{ needs.prepare-release.result == 'success' }}
90+
uses: actions/download-artifact@v4
91+
with:
92+
name: changelog
93+
path: .
94+
95+
- name: Download instructions
96+
uses: actions/download-artifact@v4
97+
with:
98+
name: instructions
99+
path: .
100+
101+
- name: Zip wheels and instructions into dist/srxconfutils-$TAG-wheels.zip
102+
run: |
103+
mkdir -p dist
104+
find dist -type f -name '*.whl' | zip -j dist/srxconfutils-"$TAG"-wheels.zip -@
105+
zip -j dist/srxconfutils-"$TAG"-wheels.zip INSTRUCTIONS.txt
106+
107+
- name: Prepare release metadata
108+
id: meta
109+
run: |
110+
if [[ "$TAG" == *rc* ]]; then
111+
PRERELEASE=true
112+
TITLE="Pre-release $TAG"
113+
BODY_RAW="Changelog: https://github.com/$REPO_FULL/commits/$TAG"
114+
else
115+
PRERELEASE=false
116+
TITLE="Release $TAG"
117+
BODY_RAW=$(<CHANGELOG.txt)
118+
fi
119+
120+
jq -n \
121+
--arg tag "$TAG" \
122+
--arg name "$TITLE" \
123+
--arg body "$BODY_RAW" \
124+
--argjson prerelease "$PRERELEASE" \
125+
'{ tag_name: $tag,
126+
name: $name,
127+
body: $body,
128+
prerelease: $prerelease
129+
}' > payload.json
130+
131+
echo "Release metadata:"
132+
cat payload.json
133+
134+
- name: Create GitHub Release
135+
id: create_release
136+
run: |
137+
set -euo pipefail
138+
139+
HTTP_STATUS=$(
140+
curl --silent --output resp.json --write-out "%{http_code}" \
141+
-X POST "https://api.github.com/repos/$REPO_FULL/releases" \
142+
-H "Accept: application/vnd.github+json" \
143+
-H "Content-Type: application/json" \
144+
-H "Authorization: Bearer $PAT_TOKEN" \
145+
--data @payload.json
146+
)
147+
if [[ "$HTTP_STATUS" -ne 201 ]]; then
148+
echo "::error::Failed to create release (status $HTTP_STATUS)"
149+
exit 1
150+
fi
151+
152+
UPLOAD_URL=$(jq -r .upload_url resp.json | sed 's/{.*}//')
153+
echo "upload_url=$UPLOAD_URL" >> $GITHUB_OUTPUT
154+
155+
- name: Upload srxconfutils-$TAG-wheels.zip
156+
if: steps.create_release.outputs.upload_url != ''
157+
run: |
158+
FILE=dist/srxconfutils-$TAG-wheels.zip
159+
echo "Uploading asset: $FILE"
160+
curl --silent --fail --data-binary @"$FILE" \
161+
-H "Content-Type: application/zip" \
162+
-H "Authorization: Bearer $PAT_TOKEN" \
163+
"${{ steps.create_release.outputs.upload_url }}?name=$(basename "$FILE")"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Check for News
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check-news-item:
10+
uses: scikit-package/release-scripts/.github/workflows/_check-news-item.yml@v0
11+
with:
12+
project: diffpy.srxconfutils
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
release:
8+
types:
9+
- prereleased
10+
- published
11+
workflow_dispatch:
12+
13+
jobs:
14+
matrix-coverage:
15+
uses: scikit-package/release-scripts/.github/workflows/_matrix-no-codecov-on-merge-to-main.yml@v0
16+
with:
17+
project: diffpy.srxconfutils
18+
c_extension: false
19+
headless: false

0 commit comments

Comments
 (0)