Skip to content

Commit 0bfebc7

Browse files
committed
Replace github action workflows from glenn20/python-ci.
1 parent a3d4722 commit 0bfebc7

File tree

5 files changed

+111
-223
lines changed

5 files changed

+111
-223
lines changed

.github/workflows/build.yaml

Lines changed: 0 additions & 65 deletions
This file was deleted.

.github/workflows/ci-release.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish and Release
2+
3+
on:
4+
push:
5+
tags: ["v*"] # Publish on tags matching "v*", eg. "v1.0.0"
6+
workflow_dispatch:
7+
8+
jobs:
9+
tests:
10+
name: Tests
11+
uses: glenn20/python-ci/.github/workflows/test.yaml@main
12+
with:
13+
os: '["ubuntu-latest", "windows-latest", "macos-latest"]'
14+
python-version: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]'
15+
16+
publish-test:
17+
name: Publish to test.pypi
18+
uses: ./.github/workflows/publish.yaml
19+
with:
20+
pypi: test.pypi
21+
permissions:
22+
id-token: write # IMPORTANT: mandatory for trusted publishing!
23+
24+
publish-pypi:
25+
name: Publish to pypi
26+
if: false # Disabled for now
27+
uses: ./.github/workflows/publish.yaml
28+
with:
29+
pypi: pypi
30+
permissions:
31+
id-token: write # IMPORTANT: mandatory for trusted publishing!
32+
33+
github-release:
34+
name: Create GitHub release
35+
uses: glenn20/python-ci/.github/workflows/release.yaml@main
36+
needs: publish-test
37+
permissions:
38+
contents: write # IMPORTANT: mandatory for github release
39+
id-token: write # IMPORTANT: mandatory for github release

.github/workflows/ci-tests.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Test and Build
2+
3+
# Run the code checks and CI pytest workflow on
4+
# - push to `main` or `dev` branches, or
5+
# - manually triggered from github Actions tab.
6+
7+
# Build and publish to test.pypi on
8+
# - push to `main` branch.
9+
10+
on:
11+
push:
12+
branches: [main, dev]
13+
workflow_dispatch:
14+
15+
jobs:
16+
tests:
17+
name: CI tests
18+
uses: glenn20/python-ci/.github/workflows/test.yaml@main
19+
with: # A short test matrix for fast testing of commits
20+
os: '["ubuntu-latest"]'
21+
python-version: '["3.9", "3.13"]'
22+
23+
publish-test:
24+
name: Publish to test.pypi
25+
needs: tests
26+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
27+
uses: ./.github/workflows/publish.yaml
28+
with:
29+
pypi: test.pypi
30+
permissions:
31+
id-token: write # IMPORTANT: mandatory for trusted publishing!

.github/workflows/publish.yaml

Lines changed: 41 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,55 @@
1-
name: Publish and Release
1+
name: Publish python package
2+
3+
# description: |- A github reusable workflow to publish a python package to
4+
# pypi.org or test.pypi.org.
5+
#
6+
# Input options:
7+
# - `pypi: test.pypi`: Publish to test.pypi.org (default).
8+
# - `pypi: pypi`: Publish to pypi.org.
9+
#
10+
# The workflow invokes the github composite action
11+
# `glenn20/python-ci/publish@v1` to publish the package.
12+
#
13+
# Requirements:
14+
# 1. For trusted publishing, the publishing workflow must be in the project
15+
# repository, so copy this workflow file to
16+
# `.github/workflows/publish.yaml` in your repository.
17+
# 2. Create the `publish-test.pypi` and `publish-pypi` Environments in your
18+
# github repository (Settings->Environments->New Environment).
19+
# 3. Add this workflow as a "trusted publisher" on your pypi and test.pypi
20+
# project pages (add the name of the relevant Environment for additional
21+
# access control).
22+
# 4. Call this workflow from a parent workflow with the `pypi` input set to
23+
# "pypi" or "test.pypi" (default).
24+
#
25+
# Invoke with `uses: ./.github/workflows/publish@v1`
226

327
on:
4-
release:
5-
types: [published]
28+
workflow_call:
29+
inputs:
30+
pypi:
31+
description: 'Set to "pypi" or "test.pypi" (default).'
32+
default: 'test.pypi'
33+
required: false
34+
type: string
635

736
jobs:
837
build:
9-
name: Build distribution
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: Checkout repository
13-
uses: actions/checkout@v4
14-
with:
15-
fetch-depth: 0 # Fetch all history for tags for versioning
16-
17-
18-
- name: Install uv
19-
uses: astral-sh/setup-uv@v3
20-
with:
21-
enable-cache: true
22-
cache-dependency-glob: "uv.lock"
23-
24-
- name: Set up Python
25-
uses: actions/setup-python@v5
26-
with:
27-
python-version-file: "pyproject.toml"
28-
29-
- name: Install dependencies
30-
run: uv sync --no-sources --all-extras --dev
31-
32-
- name: Build
33-
run: uv build --no-sources
34-
35-
- name: Store the distribution packages
36-
uses: actions/upload-artifact@v4
37-
with:
38-
name: python-package-distributions
39-
path: dist/
38+
name: Build
39+
uses: glenn20/python-ci/.github/workflows/build.yaml@main
40+
permissions:
41+
id-token: none
4042

4143
publish:
42-
name: Publish distribution
44+
name: Publish to ${{ inputs.pypi }}
4345
needs: build
4446
runs-on: ubuntu-latest
45-
4647
environment:
47-
name: release
48-
url: https://pypi.org/p/mp-image-tool-esp32
48+
name: publish-${{ inputs.pypi }}
49+
url: https://${{ inputs.pypi }}.org/p/${{ needs.build.outputs.package-name }}
4950
permissions:
5051
id-token: write # IMPORTANT: mandatory for trusted publishing
51-
52-
steps:
53-
- name: Download all the dists
54-
uses: actions/download-artifact@v4
55-
with:
56-
name: python-package-distributions
57-
path: dist/
58-
59-
- name: Publish distribution to PyPI
60-
uses: pypa/gh-action-pypi-publish@release/v1
61-
62-
63-
github-release:
64-
name: Sign the distribution and upload to GitHub Release
65-
needs: publish
66-
runs-on: ubuntu-latest
67-
68-
permissions:
69-
contents: write # IMPORTANT: mandatory for making GitHub Releases
70-
id-token: write # IMPORTANT: mandatory for sigstore
71-
7252
steps:
73-
- name: Download all the dists
74-
uses: actions/download-artifact@v4
53+
- uses: glenn20/python-ci/publish@main
7554
with:
76-
name: python-package-distributions
77-
path: dist/
78-
79-
- name: Sign the dists with Sigstore
80-
uses: sigstore/[email protected]
81-
with:
82-
inputs: >-
83-
./dist/*.tar.gz
84-
./dist/*.whl
85-
86-
- name: Create GitHub Release
87-
env:
88-
GITHUB_TOKEN: ${{ github.token }}
89-
run: >-
90-
gh release create
91-
'${{ github.ref_name }}'
92-
--repo '${{ github.repository }}'
93-
--notes ""
94-
95-
- name: Upload artifact signatures to GitHub Release
96-
env:
97-
GITHUB_TOKEN: ${{ github.token }}
98-
# Upload to GitHub Release using the `gh` CLI.
99-
# `dist/` contains the built packages, and the
100-
# sigstore-produced signatures and certificates.
101-
run: >-
102-
gh release upload
103-
'${{ github.ref_name }}' dist/**
104-
--repo '${{ github.repository }}'
55+
pypi: ${{ inputs.pypi }}

.github/workflows/tests.yaml

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)