Skip to content

Commit

Permalink
Improve and update gh-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dalito committed Sep 2, 2024
1 parent e961b93 commit 7245aad
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ updates:
directory: "/"
schedule:
interval: monthly
assignees:
- "dalito"
21 changes: 11 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
- '3.12'

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- uses: actions/setup-python@v5
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -48,29 +48,30 @@ jobs:
python -m coverage run -p -m pytest
- name: Upload coverage data
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: coverage-data
name: coverage-data-${{ matrix.python-version }}
path: .coverage.*

coverage:
name: Combine & check coverage
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- uses: actions/setup-python@v5
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
with:
python-version: '3.11'
python-version: '3.12'

- name: Install dependencies
run: python -m pip install --upgrade coverage[toml]

- name: Download data
uses: actions/download-artifact@v3
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: coverage-data
pattern: coverage-data-*
merge-multiple: true

- name: Combine coverage, create reports and fail if less than threshold.
run: |
Expand All @@ -85,7 +86,7 @@ jobs:
- name: Upload HTML report
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: html-report
path: .htmlcov
28 changes: 17 additions & 11 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Publish Python Package
# Publishes to
# - PyPI on releases created in GitHub UI
# - TestPyPI on new tags "v1.2.3" or "v1.2.3.something" on main branch
# - PyPI on releases created in GitHub UI

on:
push:
Expand All @@ -15,14 +15,16 @@ on:
jobs:
build:
name: Build Python 🐍 distributions 📦 for publishing
# Don't try to publish from forks
if: github.repository == 'nfid4cat/voc4cat-tool'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
with:
python-version: 3.11
python-version: 3.12

- name: Install hatch
run: pipx install hatch
Expand All @@ -31,13 +33,13 @@ jobs:
run: hatch build

- name: Store built distribution
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: distribution-files
path: dist/

pypi-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
name: Build and publish Python 🐍 package 📦 to PyPI and TestPyPI
needs: build
runs-on: ubuntu-latest
environment:
Expand All @@ -47,21 +49,25 @@ jobs:
id-token: write # this permission is mandatory for trusted publishing
steps:
- name: Download built distribution
uses: actions/download-artifact@v3
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: distribution-files
path: dist

# version pinned by dependabot of action [2]
- name: Publish distribution 📦 to Test PyPI
- name: Publish package 📦 to Test PyPI
if: github.event_name == 'push'
uses: pypa/gh-action-pypi-publish@8a08d616893759ef8e1aa1f2785787c0b97e20d6
with:
repository-url: https://test.pypi.org/legacy/

- name: Publish distribution 📦 to PyPI
- name: Publish package 📦 to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@8a08d616893759ef8e1aa1f2785787c0b97e20d6

# [1] https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
# [2] https://github.com/pypa/gh-action-pypi-publish/
# Used actions: (updates managed by dependabot)
# - https://github.com/actions/checkout
# - https://github.com/actions/setup-python
# - https://github.com/actions/upload-artifact
# - https://github.com/actions/download-artifact
# - https://github.com/pypa/gh-action-pypi-publish/

0 comments on commit 7245aad

Please sign in to comment.