-
Notifications
You must be signed in to change notification settings - Fork 14
skpkg: add CI and issue/PR templates #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7d506a8
skpkg: add CI and issue/PR templates
stevenhua0320 fc6e88b
skpkg: add CI and issue/PR templates
stevenhua0320 3ba9b97
skpkg: add release-github.yml workflow
stevenhua0320 19ac985
style: change string to pass flake8
stevenhua0320 fdc93f0
style: change workflow to open source format.
stevenhua0320 ab33f27
style: change workflow for tests-on-pr
stevenhua0320 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| name: Release on GitHub | ||
|
|
||
| on: | ||
| workflow_call: | ||
| secrets: | ||
| PAT_TOKEN: | ||
| description: "GitHub Personal Access Token" | ||
| required: true | ||
|
|
||
| env: | ||
| TAG: ${{ github.ref_name }} | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash {0} | ||
|
|
||
| jobs: | ||
| prepare-release: | ||
| if: ${{ ! contains(github.ref, 'rc') }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout the repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| fetch-depth: 0 | ||
| ref: main | ||
|
|
||
| - name: Update CHANGELOG | ||
| run: | | ||
| wget https://raw.githubusercontent.com/scikit-package/release-scripts/v0/.github/workflows/update-changelog.py | ||
| python update-changelog.py "$TAG" | ||
| rm update-changelog.py | ||
|
|
||
| - name: Commit updated CHANGELOG.rst | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add . | ||
| if ! git diff --cached --quiet; then | ||
| git commit -m "update changelog for $TAG" | ||
| git push origin main | ||
| else | ||
| echo "No CHANGELOG.rst changes" | ||
| fi | ||
|
|
||
| - name: New tag | ||
| run: | | ||
| git fetch --tags | ||
| git tag -d "$TAG" 2>/dev/null || true | ||
| git push origin ":$TAG" 2>/dev/null || true | ||
| git tag "$TAG" | ||
| git push origin "$TAG" | ||
|
|
||
| - name: Get CHANGELOG.txt | ||
| run: | | ||
| wget https://raw.githubusercontent.com/scikit-package/release-scripts/v0/.github/workflows/get-latest-changelog.py | ||
| python get-latest-changelog.py "$TAG" | ||
| rm get-latest-changelog.py | ||
|
|
||
| - name: Upload changelog.txt | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: changelog | ||
| path: CHANGELOG.txt | ||
|
|
||
| release: | ||
| needs: [prepare-release] | ||
| if: always() | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| REPO_FULL: ${{ github.repository }} | ||
| PAT_TOKEN: ${{ secrets.PAT_TOKEN }} | ||
| steps: | ||
| - name: Check prepare release | ||
| run: | | ||
| if [[ ${{ needs.prepare-release.result }} != 'success' && "$TAG" != *rc* ]]; then | ||
| echo "::error::Skipping release job because prepare-release failed" | ||
| exit 78 | ||
| fi | ||
| echo "Continuing with release job" | ||
|
|
||
| - name: Download built wheels | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| path: dist/ | ||
|
|
||
| - name: Download changelog | ||
| if: ${{ needs.prepare-release.result == 'success' }} | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: changelog | ||
| path: . | ||
|
|
||
| - name: Download instructions | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: instructions | ||
| path: . | ||
|
|
||
| - name: Zip wheels and instructions into dist/srxplanar-$TAG-wheels.zip | ||
| run: | | ||
| mkdir -p dist | ||
| find dist -type f -name '*.whl' | zip -j dist/srxplanar-"$TAG"-wheels.zip -@ | ||
| zip -j dist/srxplanar-"$TAG"-wheels.zip INSTRUCTIONS.txt | ||
|
|
||
| - name: Prepare release metadata | ||
| id: meta | ||
| run: | | ||
| if [[ "$TAG" == *rc* ]]; then | ||
| PRERELEASE=true | ||
| TITLE="Pre-release $TAG" | ||
| BODY_RAW="Changelog: https://github.com/$REPO_FULL/commits/$TAG" | ||
| else | ||
| PRERELEASE=false | ||
| TITLE="Release $TAG" | ||
| BODY_RAW=$(<CHANGELOG.txt) | ||
| fi | ||
|
|
||
| jq -n \ | ||
| --arg tag "$TAG" \ | ||
| --arg name "$TITLE" \ | ||
| --arg body "$BODY_RAW" \ | ||
| --argjson prerelease "$PRERELEASE" \ | ||
| '{ tag_name: $tag, | ||
| name: $name, | ||
| body: $body, | ||
| prerelease: $prerelease | ||
| }' > payload.json | ||
|
|
||
| echo "Release metadata:" | ||
| cat payload.json | ||
|
|
||
| - name: Create GitHub Release | ||
| id: create_release | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| HTTP_STATUS=$( | ||
| curl --silent --output resp.json --write-out "%{http_code}" \ | ||
| -X POST "https://api.github.com/repos/$REPO_FULL/releases" \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "Content-Type: application/json" \ | ||
| -H "Authorization: Bearer $PAT_TOKEN" \ | ||
| --data @payload.json | ||
| ) | ||
| if [[ "$HTTP_STATUS" -ne 201 ]]; then | ||
| echo "::error::Failed to create release (status $HTTP_STATUS)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| UPLOAD_URL=$(jq -r .upload_url resp.json | sed 's/{.*}//') | ||
| echo "upload_url=$UPLOAD_URL" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Upload srxplanar-$TAG-wheels.zip | ||
| if: steps.create_release.outputs.upload_url != '' | ||
| run: | | ||
| FILE=dist/srxplanar-$TAG-wheels.zip | ||
| echo "Uploading asset: $FILE" | ||
| curl --silent --fail --data-binary @"$FILE" \ | ||
| -H "Content-Type: application/zip" \ | ||
| -H "Authorization: Bearer $PAT_TOKEN" \ | ||
| "${{ steps.create_release.outputs.upload_url }}?name=$(basename "$FILE")" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| name: Tests on PR | ||
|
|
||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| tests-on-pr: | ||
| uses: scikit-package/release-scripts/.github/workflows/_tests-on-pr-no-codecov.yml@v0 | ||
| with: | ||
| project: diffpy.srxplanar | ||
| c_extension: false | ||
| headless: false | ||
| python_version: "3.13" | ||
| secrets: | ||
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,93 @@ | ||
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
|
|
||
| # C extensions | ||
| *.so | ||
|
|
||
| # Packages | ||
| *.egg | ||
| *.egg-info | ||
| dist | ||
| build | ||
| eggs | ||
| parts | ||
| bin | ||
| var | ||
| sdist | ||
| temp | ||
| develop-eggs | ||
| # Distribution / packaging | ||
| .Python | ||
| env/ | ||
| build/ | ||
| _build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| venv/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| lib | ||
| lib64 | ||
| tags | ||
| *.egg | ||
| bin/ | ||
| temp/ | ||
| tags/ | ||
| errors.err | ||
|
|
||
| # PyInstaller | ||
| # Usually these files are written by a python script from a template | ||
| # before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
| *.manifest | ||
| *.spec | ||
|
|
||
| # Installer logs | ||
| pip-log.txt | ||
| pip-delete-this-directory.txt | ||
| MANIFEST | ||
|
|
||
| # Unit test / coverage reports | ||
| htmlcov/ | ||
| .tox/ | ||
| .coverage | ||
| .tox | ||
| .coverage.* | ||
| .cache | ||
| nosetests.xml | ||
| coverage.xml | ||
| *,cover | ||
| .hypothesis/ | ||
|
|
||
| # Translations | ||
| *.mo | ||
| *.pot | ||
|
|
||
| # Mr Developer | ||
| .mr.developer.cfg | ||
| .project | ||
| .pydevproject | ||
| .settings | ||
|
|
||
| # version information | ||
| setup.cfg | ||
| /diffpy/srxplanar/version.cfg | ||
| /diffpy/confutils/version.cfg | ||
| # Django stuff: | ||
| *.log | ||
|
|
||
| # Sphinx documentation | ||
| docs/build/ | ||
| docs/source/generated/ | ||
|
|
||
| # pytest | ||
| .pytest_cache/ | ||
|
|
||
| # PyBuilder | ||
| target/ | ||
|
|
||
| # Editor files | ||
| # mac | ||
| .DS_Store | ||
| *~ | ||
|
|
||
| # vim | ||
| *.swp | ||
| *.swo | ||
|
|
||
| # pycharm | ||
| .idea/ | ||
|
|
||
| # VSCode | ||
| .vscode/ | ||
|
|
||
| # Ipython Notebook | ||
| .ipynb_checkpoints |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import argparse | ||
|
|
||
| from diffpy.srxplanar.version import __version__ # noqa | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser( | ||
| prog="diffpy.srxplanar", | ||
| description=( | ||
| "Distance Printer, calculate the inter atomic distances." | ||
| " Part of xPDFsuite\n\n" | ||
| "For more information, visit: " | ||
| "https://github.com/diffpy/diffpy.srxplanar/" | ||
| ), | ||
| formatter_class=argparse.RawDescriptionHelpFormatter, | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--version", | ||
| action="store_true", | ||
| help="Show the program's version number and exit", | ||
| ) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| if args.version: | ||
| print(f"diffpy.srxplanar {__version__}") | ||
| else: | ||
| # Default behavior when no arguments are given | ||
| parser.print_help() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need codecov token if we're calling the no-codecov workflow I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is open source so we want to call codecove