Skip to content

Commit

Permalink
ci: misc improvements (#1024)
Browse files Browse the repository at this point in the history
* ci: pre-commit cache + uv cache everywhere

* ci(release): dry-run more things

* ci(release): use `github.ref_name` for tag
  • Loading branch information
mkniewallner authored Jan 12, 2025
1 parent f3d8c31 commit 819b67b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 13 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install Python
uses: actions/setup-python@v5
Expand All @@ -40,8 +42,14 @@ jobs:
- name: Setup Rust toolchain
run: rustup component add clippy rustfmt

- name: Load pre-commit cache
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ env.PYTHON_VERSION }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Run pre-commit
run: uvx pre-commit@${PRE_COMMIT_VERSION} run -a --show-diff-on-failure
run: uvx pre-commit@${PRE_COMMIT_VERSION} run --all-files --show-diff-on-failure
env:
# renovate: datasource=pypi depName=pre-commit
PRE_COMMIT_VERSION: '4.0.1'
Expand Down Expand Up @@ -73,7 +81,8 @@ jobs:
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: 'true'
enable-cache: true
cache-dependency-glob: "uv.lock"
cache-suffix: ${{ matrix.python-version }}

- name: Install Python
Expand Down Expand Up @@ -112,6 +121,8 @@ jobs:
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install Python
uses: actions/setup-python@v5
Expand Down
32 changes: 22 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@ jobs:
with:
persist-credentials: false

- name: Export tag
id: vars
run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
if: ${{ github.event_name == 'release' }}

- name: Update project version
if: ${{ github.event_name == 'release' }}
run: |
sed -i "s/^version = \".*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
if: ${{ github.event_name == 'release' }}
RELEASE_VERSION: ${{ github.ref_name }}

- name: Upload updated pyproject.toml
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -187,8 +182,11 @@ jobs:
publish:
name: Publish
runs-on: ubuntu-24.04
needs: [linux, windows, macos, sdist]
if: ${{ github.event_name == 'release' }}
needs:
- linux
- windows
- macos
- sdist
steps:
- uses: actions/download-artifact@v4

Expand All @@ -198,19 +196,26 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}

- name: Publish to PyPI
if: ${{ github.event_name == 'release' }}
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*

- name: '[dry-run] Publish to PyPI'
if: ${{ github.event_name != 'release' }}
uses: PyO3/maturin-action@v1
with:
command: upload
args: --help

publish-docs:
runs-on: ubuntu-24.04
needs: publish
permissions:
contents: write
if: ${{ github.event_name == 'release' }}
steps:
- name: Check out
uses: actions/checkout@v4
Expand All @@ -219,11 +224,18 @@ jobs:
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Deploy documentation
if: ${{ github.event_name == 'release' }}
run: uv run --only-group docs mkdocs gh-deploy --force

- name: '[dry-run] Deploy documentation'
if: ${{ github.event_name != 'release' }}
run: uv run --only-group docs mkdocs gh-deploy --help
2 changes: 1 addition & 1 deletion zizmor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ rules:
artipacked:
ignore:
# Required for publishing documentation to `gh-pages` branch.
- release.yml:215
- release.yml:220

0 comments on commit 819b67b

Please sign in to comment.