From 61074ed2956acfaab070055604a83a8719da137e Mon Sep 17 00:00:00 2001 From: tr4nt0r <4445816+tr4nt0r@users.noreply.github.com> Date: Mon, 27 Oct 2025 23:10:16 +0100 Subject: [PATCH] Update GitHub actions --- .github/FUNDING.yml | 3 + .github/labels.yml | 93 +++++++++++++++++++++++++++++ .github/release-drafter.yml | 96 ++++++++++++++++++++++++++++++ .github/workflows/build.yml | 106 +++++++++++++++++++++------------- .github/workflows/draft.yml | 26 +++++++++ .github/workflows/labeler.yml | 21 +++++++ 6 files changed, 304 insertions(+), 41 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/labels.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/draft.yml create mode 100644 .github/workflows/labeler.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..4a6a8cb --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +github: [tr4nt0r] +buy_me_a_coffee: tr4nt0r + diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..6fe598f --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,93 @@ +--- +# Labels names are important as they are used by Release Drafter to decide +# regarding where to record them in changelog or if to skip them. +# +# The repository labels will be automatically configured using this file and +# the GitHub Action https://github.com/marketplace/actions/github-labeler. +- name: ':boom: breaking change' + from_name: breaking + description: Breaking Changes + color: bfd4f2 +- name: ':ghost: bug' + from_name: bug + description: Something isn't working + color: d73a4a +- name: ':building_construction: build' + from_name: build + description: Build System and Dependencies + color: bfdadc +- name: ':construction_worker_woman: ci' + from_name: ci + description: Continuous Integration + color: 4a97d6 +- name: ':recycle: dependencies' + from_name: dependencies + description: Pull requests that update a dependency file + color: 0366d6 +- name: ':book: documentation' + from_name: documentation + description: Improvements or additions to documentation + color: 0075ca +- name: ':roll_eyes: duplicate' + from_name: duplicate + description: This issue or pull request already exists + color: cfd3d7 +- name: ':rocket: feature' + from_name: enhancement + description: New feature or request + color: a2eeef +- name: ':clapper: github_actions' + from_name: github_actions + description: Pull requests that update Github_actions code + color: '000000' +- name: ':hatching_chick: good first issue' + from_name: good first issue + description: Good for newcomers + color: 7057ff +- name: ':pray: help wanted' + from_name: help wanted + description: Extra attention is needed + color: '008672' +- name: ':no_entry_sign: invalid' + from_name: invalid + description: This doesn't seem right + color: e4e669 +- name: ':racing_car: performance' + from_name: performance + description: Performance + color: '016175' +- name: ':snake: python' + from_name: python + description: Pull requests that update Python code + color: 2b67c6 +- name: ':question: question' + from_name: question + description: Further information is requested + color: d876e3 +- name: ':sparkles: code quality' + from_name: code quality + description: Code quality improvements + color: ef67c4 +- name: ':file_cabinet: deprecation' + from_name: deprecation + description: Removals and Deprecations + color: 9ae7ea +- name: ':nail_care: style' + from_name: style + description: Style + color: c120e5 +- name: ':test_tube: testing' + from_name: testing + description: Pull request that adds tests + color: b1fc6f +- name: ':woman_shrugging: wontfix' + from_name: wontfix + description: This will not be worked on + color: ffffff +- name: ':arrow_up: bump' + description: Bump the version + color: 3C5D34 +- name: ':sparkles: enhancement' + color: CBF8DA +- name: 'skip-changelog' + color: D3D3D3 diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..95679e2 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,96 @@ +name-template: "v$RESOLVED_VERSION" +tag-template: "v$RESOLVED_VERSION" + +categories: + - title: "💥 Breaking changes" + labels: + - ":boom: breaking change" + - title: "🚀 New Features" + labels: + - ":rocket: feature" + - title: "👻 Bug Fixes" + labels: + - ":ghost: bug" + - title: "⏳ Deprecations" + labels: + - ":file_cabinet: deprecation" + - title: "📃 Documentation" + labels: + - ":book: documentation" + - title: "🧰 Maintenance" + labels: + - ":building_construction: build" + - ":construction_worker_woman: ci" + - ":clapper: github_actions" + collapse-after: 5 + - title: "🔬 Other updates" + labels: + - ":nail_care: style" + - ":test_tube: testing" + - ":racing_car: performance" + - ":sparkles: code quality" + - ":sparkles: enhancement" + - title: "🧩 Dependency Updates" + labels: + - ":recycle: dependencies" + collapse-after: 5 +exclude-labels: + - ":arrow_up: bump" + - "skip-changelog" + +autolabeler: + - label: ":rocket: feature" + title: + - "/adds/i" + - "/add method/i" + - label: ":ghost: bug" + title: + - "/fix/i" + - label: ":sparkles: code quality" + title: + - "/Refactor/i" + - label: ":test_tube: testing" + files: + - "test_*" + - "conftest.py" + - label: ":book: documentation" + title: + - "/docs:/i" + files: + - "*.md" + - "mkdocs.yml" + - label: ":construction_worker_woman: ci" + files: + - ".github/*" + - label: ":recycle: dependencies" + title: + - "/^bump(?! version)/i" + - label: ":file_cabinet: deprecation" + title: + - "/Deprecate/i" + +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +exclude-contributors: + - "dependabot" + - "renovate" + +version-resolver: + major: + labels: + - ":boom: breaking change" + minor: + labels: + - ":rocket: feature" + default: patch + +template: | + ## What's Changed + + $CHANGES + + Contributors: $CONTRIBUTORS + +replacers: + - search: '/(?:and )?@dependabot(?:\[bot\])?,?/g' + replace: "" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1af700b..cbcf83a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,51 +1,75 @@ -name: build +name: Build -on: ['push', 'pull_request'] +on: [push, pull_request] jobs: - build: - - runs-on: ubuntu-latest + test: strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] - + os: [windows-latest, ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies + - uses: actions/checkout@v5 + - name: Install Hatch + uses: pypa/hatch@install + - name: Lint and typecheck run: | - python -m pip install --upgrade pip - pip install -e .[dev] - - name: Lint with ruff + hatch fmt --linter + - name: Test run: | - ruff check xbox - ruff check tests - - name: Test with pytest - run: | - pytest - - deploy: + hatch test --all + + - uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: false + verbose: true + + release: runs-on: ubuntu-latest - needs: build + environment: release + needs: test + if: startsWith(github.ref, 'refs/tags/') + permissions: + contents: write + id-token: write + steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.12' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine build - - name: Build and publish - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_API_KEY }} - run: | - python -m build - twine upload dist/* + - uses: actions/checkout@v5 + - name: Install dependencies + shell: bash + run: pipx install hatch + - name: mint API token + id: mint-token + run: | + # retrieve the ambient OIDC token + resp=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \ + "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=pypi") + oidc_token=$(jq -r '.value' <<< "${resp}") + + # exchange the OIDC token for an API token + resp=$(curl -X POST https://pypi.org/_/oidc/mint-token -d "{\"token\": \"${oidc_token}\"}") + api_token=$(jq -r '.token' <<< "${resp}") + + # mask the newly minted API token, so that we don't accidentally leak it + echo "::add-mask::${api_token}" + + # see the next step in the workflow for an example of using this step output + echo "api-token=${api_token}" >> "${GITHUB_OUTPUT}" + - name: Build and publish on PyPI + env: + HATCH_INDEX_USER: __token__ + HATCH_INDEX_AUTH: ${{ steps.mint-token.outputs.api-token }} + run: | + hatch build + hatch publish + - name: Create release + uses: ncipollo/release-action@v1 + with: + draft: true + body: ${{ github.event.head_commit.message }} + allowUpdates: true + omitBodyDuringUpdate: true + updateOnlyUnreleased: true + artifacts: dist/*.whl,dist/*.tar.gz + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/draft.yml b/.github/workflows/draft.yml new file mode 100644 index 0000000..23f3b42 --- /dev/null +++ b/.github/workflows/draft.yml @@ -0,0 +1,26 @@ +name: Release Drafter + +on: + push: + branches: + - main + # pull_request event is required only for autolabeler + pull_request: + types: [opened, reopened, synchronize] + pull_request_target: + types: [opened, reopened, synchronize] + +permissions: + contents: read + +jobs: + update-draft: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + # Drafts your next Release notes as Pull Requests are merged into "main" + - uses: release-drafter/release-drafter@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..d58b273 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,21 @@ +name: Labeler + +on: workflow_dispatch + +permissions: + actions: read + contents: read + security-events: write + pull-requests: write + +jobs: + labeler: + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v5 + + - name: Run Labeler + uses: crazy-max/ghaction-github-labeler@v5.3.0 + with: + skip-delete: true