Initial commit

This commit is contained in:
Hal 2025-01-06 01:26:03 +08:00 committed by GitHub
commit b1a1a6866d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 495 additions and 0 deletions

60
.github/workflows/build-exe.yml vendored Normal file
View file

@ -0,0 +1,60 @@
name: Build Executable
on:
workflow_run:
workflows: ["Python Package"]
types:
- completed
branches:
- "main"
jobs:
build:
# Only run if the python-publish workflow succeeded
if: ${{ github.event.workflow_run.conclusion == 'success' }}
strategy:
fail-fast: false
matrix:
target:
- os: windows-2022
triple: x86_64-pc-windows-msvc
- os: ubuntu-22.04
triple: x86_64-unknown-linux-gnu
- os: macos-12
triple: x86_64-apple-darwin
runs-on: ${{ matrix.target.os }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: olegtarasov/get-tag@v2.1.4
id: get_tag_name
with:
tagRegex: "v(?<version>.*)"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nox
- name: Build exe
run: |
nox -s build-exe -- --release --version ${{ steps.get_tag_name.outputs.version }}
- uses: ncipollo/release-action@v1
with:
allowUpdates: true
updateOnlyUnreleased: false
omitBody: true
artifacts: ".zip/*.zip"
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

23
.github/workflows/bumpversion.yml vendored Normal file
View file

@ -0,0 +1,23 @@
name: Bump version
on:
push:
branches:
- main
jobs:
bump-version:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
name: "Bump version and create changelog with commitizen"
steps:
- name: Check out
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
branch: main

34
.github/workflows/codecov.yml vendored Normal file
View file

@ -0,0 +1,34 @@
name: Codecov
on: [push, pull_request]
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get repository name
id: repo-name
uses: MariachiBear/get-repo-name-action@v1.3.0
with:
with-owner: 'true'
string-case: 'uppercase'
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install -r requirements-dev.txt
poetry --version
- name: Run tests and collect coverage
run: |
nox -s pytest
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
slug: loonghao/${{ steps.repo-name.outputs.repository-name }}
files: 'coverage.xml'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

18
.github/workflows/issue-translator.yml vendored Normal file
View file

@ -0,0 +1,18 @@
name: 'issue-translator'
on:
issue_comment:
types: [created]
issues:
types: [opened]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: usthe/issues-translate-action@v2.7
with:
IS_MODIFY_TITLE: false
# not require, default false, . Decide whether to modify the issue title
# if true, the robot account @Issues-translate-bot must have modification permissions, invite @Issues-translate-bot to your project or use your custom bot.
CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿
# not require. Customize the translation robot prefix message.

35
.github/workflows/mr-test.yml vendored Normal file
View file

@ -0,0 +1,35 @@
name: MR Checks
on: [ pull_request ]
jobs:
python-check:
strategy:
max-parallel: 3
matrix:
target:
- os: 'ubuntu-22.04'
triple: 'x86_64-unknown-linux-gnu'
- os: 'macos-12'
triple: 'x86_64-apple-darwin'
- os: 'windows-2022'
triple: 'x86_64-pc-windows-msvc'
python-version: ["3.10"]
fail-fast: false
runs-on: ${{ matrix.target.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -r requirements-dev.txt
poetry --version
- name: lint
run: |
nox -s lint
- name: test build
run: |
nox -s build-exe -- --test

66
.github/workflows/python-publish.yml vendored Normal file
View file

@ -0,0 +1,66 @@
name: Upload Python Package
on:
push:
tags:
- "v*"
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
contents: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
token: "${{ secrets.GITHUB_TOKEN }}"
fetch-depth: 0
ref: main
- uses: olegtarasov/get-tag@v2.1.4
id: get_tag_name
with:
tagRegex: "v(?<version>.*)"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install -r requirements-dev.txt
poetry --version
poetry build
# Note that we don't need credentials.
# We rely on https://docs.pypi.org/trusted-publishers/.
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
- name: Generate changelog
id: changelog
uses: jaywcjlove/changelog-generator@main
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
filter-author: (|dependabot|renovate\\[bot\\]|dependabot\\[bot\\]|Renovate Bot)
filter: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'
template: |
## Bugs
{{fix}}
## Feature
{{feat}}
## Improve
{{refactor,perf,clean}}
## Misc
{{chore,style,ci||🔶 Nothing change}}
## Unknown
{{__unknown__}}
- uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
body: |
Comparing Changes: ${{ steps.changelog.outputs.compareurl }}
${{ steps.changelog.outputs.changelog }}