Skip to content

Commit 5bde97a

Browse files
committed
ci: add CI and publish workflows with reusable setup action
1 parent d2c1493 commit 5bde97a

3 files changed

Lines changed: 112 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Setup FastAPI Cloudflow Environment
2+
description: Common environment setup for all FastAPI Cloudflow jobs
3+
4+
inputs:
5+
github-token:
6+
description: 'GitHub token for authentication'
7+
required: false
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Install uv
14+
uses: astral-sh/setup-uv@v4
15+
- name: Install Task
16+
uses: arduino/setup-task@v2
17+
with:
18+
version: 3.x
19+
repo-token: ${{ inputs.github-token }}
20+
- name: Install dependencies
21+
run: task install-dev
22+
shell: bash

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: ./.github/actions/setup-env
14+
with:
15+
github-token: ${{ secrets.GITHUB_TOKEN }}
16+
- name: Lint with Ruff and Ty
17+
run: task lint
18+
19+
test:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: ./.github/actions/setup-env
24+
with:
25+
github-token: ${{ secrets.GITHUB_TOKEN }}
26+
- name: Run tests
27+
run: task test
28+
- name: Report Coverage
29+
run: uv run coverage lcov
30+
- uses: qltysh/qlty-action/coverage@v1
31+
with:
32+
token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
33+
files: coverage.lcov
34+
35+
build:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: ./.github/actions/setup-env
40+
with:
41+
github-token: ${{ secrets.GITHUB_TOKEN }}
42+
- name: Build package
43+
run: task build

.github/workflows/publish.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Tag & Release Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
id-token: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: ./.github/actions/setup-env
17+
with:
18+
github-token: ${{ secrets.GITHUB_TOKEN }}
19+
- name: Detect version upgrade
20+
id: versioning
21+
run: |
22+
package_version=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
23+
echo "package_version=$package_version" >> $GITHUB_OUTPUT
24+
upgraded=$(git tag --list | grep -q "${package_version}$" && echo "false" || echo "true")
25+
echo "upgraded=$upgraded" >> $GITHUB_OUTPUT
26+
pre_release=$([[ $package_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo "false" || echo "true")
27+
echo "pre_release=$pre_release" >> $GITHUB_OUTPUT
28+
main_branch_release=$([[ $pre_release == "false" && $GITHUB_REF_NAME == "main" ]] && echo "true" || echo "false")
29+
alternative_branch_release=$([[ $pre_release == "true" && $GITHUB_REF_NAME != "main" ]] && echo "true" || echo "false")
30+
should_release=$([[ $upgraded == "true" && ($main_branch_release == "true" || $alternative_branch_release == "true") ]] && echo "true" || echo "false")
31+
echo "should_release=$should_release" >> $GITHUB_OUTPUT
32+
echo "upgraded=$upgraded"
33+
echo "pre_release=$pre_release"
34+
echo "git_ref=$GITHUB_REF_NAME"
35+
echo "main_branch_release=$main_branch_release"
36+
echo "alternative_branch_release=$alternative_branch_release"
37+
echo "should_release=$should_release"
38+
- name: Create Release
39+
if: ${{ steps.versioning.outputs.should_release == 'true' }}
40+
run: gh release create ${{ steps.versioning.outputs.package_version }} --generate-notes
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
- name: Build & Publish package
44+
if: ${{ steps.versioning.outputs.should_release == 'true' }}
45+
run: |
46+
task build
47+
uv publish

0 commit comments

Comments
 (0)