Skip to content

Commit cdc2445

Browse files
committed
feat: ci configuration
1 parent 2cfc146 commit cdc2445

File tree

7 files changed

+608
-0
lines changed

7 files changed

+608
-0
lines changed

.github/workflows/bump-package.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Bump Package Version
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
package_name:
7+
required: true
8+
type: string
9+
description: "Name of the package to bump (e.g., keycardai-oauth)"
10+
package_dir:
11+
required: true
12+
type: string
13+
description: "Directory of the package (e.g., packages/oauth)"
14+
15+
jobs:
16+
bump:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Setup Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.12"
23+
24+
- name: Checkout Repository
25+
uses: actions/checkout@v4
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
fetch-depth: 0
29+
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v4
32+
33+
- name: Install commitizen
34+
run: uv tool install commitizen
35+
36+
- name: Configure git
37+
run: |
38+
git config --local user.email "[email protected]"
39+
git config --local user.name "GitHub Action"
40+
41+
- name: Create bump and changelog for ${{ inputs.package_name }}
42+
run: |
43+
cd ${{ inputs.package_dir }}
44+
echo "Bumping version for ${{ inputs.package_name }} package..."
45+
uv run cz bump --changelog --yes
46+
47+
# Push changes
48+
git push origin main --follow-tags

.github/workflows/main.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Merge to Main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: main
10+
cancel-in-progress: true
11+
12+
jobs:
13+
detect-changes:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
changed-packages: ${{ steps.changes.outputs.changed-packages }}
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.12"
27+
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v4
30+
31+
- name: Detect package changes
32+
id: changes
33+
run: |
34+
PACKAGES=$(just detect-changes)
35+
echo "changed-packages=$PACKAGES" >> $GITHUB_OUTPUT
36+
37+
bump-packages:
38+
if: needs.detect-changes.outputs.changed-packages != '[]' && !startsWith(github.event.head_commit.message, 'bump:')
39+
needs: detect-changes
40+
strategy:
41+
matrix:
42+
package: ${{ fromJson(needs.detect-changes.outputs.changed-packages) }}
43+
uses: ./.github/workflows/bump-package.yml
44+
with:
45+
package_name: ${{ matrix.package.package_name }}
46+
package_dir: ${{ matrix.package.package_dir }}

.github/workflows/pr.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Pull Request Validation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
validate-commits:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Setup Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v4
24+
25+
- name: Install just
26+
uses: extractions/setup-just@v2
27+
28+
- name: Validate commit messages
29+
run: just validate-commits
30+
31+
lint-and-test:
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- name: Checkout Repository
36+
uses: actions/checkout@v4
37+
38+
- name: Setup Python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.12"
42+
43+
- name: Install uv
44+
uses: astral-sh/setup-uv@v4
45+
46+
- name: Install just
47+
uses: extractions/setup-just@v2
48+
49+
- name: Install dependencies
50+
run: uv sync --all-extras
51+
52+
- name: Run linting and formatting checks
53+
run: just check
54+
55+
- name: Run tests
56+
run: just test

.github/workflows/release.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Release Packages
2+
3+
on:
4+
push:
5+
tags:
6+
- '*-keycardai-oauth'
7+
- '*-keycardai-mcp'
8+
- '*-keycardai-mcp-fastmcp'
9+
10+
jobs:
11+
detect-package:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
package: ${{ steps.detect.outputs.package }}
15+
version: ${{ steps.detect.outputs.version }}
16+
package-dir: ${{ steps.detect.outputs.package-dir }}
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.12"
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v4
28+
29+
- name: Detect package from tag
30+
id: detect
31+
run: |
32+
TAG_NAME=${GITHUB_REF#refs/tags/}
33+
echo "Tag: $TAG_NAME"
34+
35+
# Use the changelog.py script to extract package information
36+
PACKAGE_INFO=$(uv run python scripts/changelog.py package "$TAG_NAME" --output-format github)
37+
38+
# Parse the JSON output
39+
PACKAGE=$(echo "$PACKAGE_INFO" | jq -r '.package_name')
40+
VERSION=$(echo "$PACKAGE_INFO" | jq -r '.version')
41+
PACKAGE_DIR=$(echo "$PACKAGE_INFO" | jq -r '.package_dir')
42+
43+
echo "package=$PACKAGE" >> $GITHUB_OUTPUT
44+
echo "version=$VERSION" >> $GITHUB_OUTPUT
45+
echo "package-dir=$PACKAGE_DIR" >> $GITHUB_OUTPUT
46+
47+
echo "Detected package: $PACKAGE"
48+
echo "Version: $VERSION"
49+
echo "Package directory: $PACKAGE_DIR"
50+
51+
build-and-publish:
52+
runs-on: ubuntu-latest
53+
needs: [detect-package]
54+
environment: release
55+
steps:
56+
- name: Checkout Repository
57+
uses: actions/checkout@v4
58+
59+
- name: Setup Python
60+
uses: actions/setup-python@v5
61+
with:
62+
python-version: "3.12"
63+
64+
- name: Install uv
65+
uses: astral-sh/setup-uv@v4
66+
67+
- name: Install dependencies
68+
run: uv sync --all-extras
69+
70+
- name: Build package
71+
run: |
72+
cd packages/${{ needs.detect-package.outputs.package-dir }}
73+
uv build
74+
75+
- name: Publish to PyPI
76+
env:
77+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
78+
run: |
79+
cd packages/${{ needs.detect-package.outputs.package-dir }}
80+
uv publish

justfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,19 @@ sdk-ref-oauth:
4040
# Clean up API reference documentation
4141
sdk-ref-clean:
4242
rm -rf docs/sdk
43+
44+
# Validate commit messages for PR
45+
validate-commits BASE_BRANCH="origin/main":
46+
uv run python scripts/changelog.py validate {{BASE_BRANCH}}
47+
48+
# Preview changelog changes for each package
49+
preview-changelog BASE_BRANCH="origin/main":
50+
uv run python scripts/changelog.py preview {{BASE_BRANCH}}
51+
52+
# Detect packages with unreleased changes
53+
detect-changes:
54+
uv run python scripts/changelog.py changes --output-format github
55+
56+
# Extract package information from GitHub tag
57+
extract-package TAG:
58+
uv run python scripts/changelog.py package {{TAG}} --output-format json

0 commit comments

Comments
 (0)