Skip to content

Commit 8abfcad

Browse files
Merge pull request #5 from WecoAI/feat-user-auth
feat: Implement User Authentication and Session Ownership
2 parents 48fddce + c6d67f9 commit 8abfcad

File tree

9 files changed

+777
-378
lines changed

9 files changed

+777
-378
lines changed

.github/workflows/release.yml

Lines changed: 124 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,97 @@
1-
name: Publish Python Package
1+
name: Release
22

33
on:
4+
# Fires when the *Lint and Format Code* workflow that was
5+
# started by a push to main has finished (any conclusion)
46
workflow_run:
57
workflows: ["Lint and Format Code"]
6-
types:
7-
- completed
8-
9-
release:
10-
types: [published]
8+
branches: [main]
9+
types: [completed]
1110

1211
jobs:
12+
# ────────────────────────────────────────────────────────────────────
13+
# 1) Pre-check — decide whether we really need to release
14+
# ────────────────────────────────────────────────────────────────────
15+
pre-check:
16+
name: Detect new version
17+
if: ${{ github.event.workflow_run.conclusion == 'success' }} # gate #1
18+
runs-on: ubuntu-latest
19+
outputs:
20+
release_needed: ${{ steps.version_diff.outputs.release_needed }}
21+
version: ${{ steps.version_diff.outputs.version }}
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ github.event.workflow_run.head_sha }}
28+
fetch-depth: 0 # we need history to read the previous commit
29+
30+
- name: Compare versions
31+
id: version_diff
32+
shell: bash
33+
# gate #2 happens here → sets release_needed=true/false
34+
run: |
35+
# version in current pyproject.toml
36+
NEW_VERSION=$(grep -Po '(?<=^version = ")[^"]+' pyproject.toml)
37+
# version in the previous commit's pyproject.toml (if the file existed)
38+
BASE_COMMIT=$(git rev-parse "$GITHUB_SHA"^)
39+
if git cat-file -e "$BASE_COMMIT":pyproject.toml 2>/dev/null; then
40+
OLD_VERSION=$(git show "$BASE_COMMIT":pyproject.toml \
41+
| grep -Po '(?<=^version = ")[^"]+' || true)
42+
else
43+
OLD_VERSION=""
44+
fi
45+
46+
echo "Previous version: $OLD_VERSION"
47+
echo "Current version: $NEW_VERSION"
48+
49+
if [[ "$NEW_VERSION" != "$OLD_VERSION" ]]; then
50+
echo "release_needed=true" >>"$GITHUB_OUTPUT"
51+
else
52+
echo "release_needed=false" >>"$GITHUB_OUTPUT"
53+
fi
54+
echo "version=$NEW_VERSION" >>"$GITHUB_OUTPUT"
55+
56+
# ────────────────────────────────────────────────────────────────────
57+
# 2) Build
58+
# ────────────────────────────────────────────────────────────────────
1359
build:
1460
name: Build distribution 📦
61+
needs: pre-check
62+
if: ${{ needs.pre-check.outputs.release_needed == 'true' }} # gate #3
1563
runs-on: ubuntu-latest
1664

1765
steps:
18-
- name: Checkout code
19-
uses: actions/checkout@v4
20-
with:
21-
ref: ${{ github.head_ref }}
22-
23-
- name: Set up Python
24-
uses: actions/setup-python@v5
25-
with:
26-
python-version: "3.12"
27-
28-
- name: Install build dependencies
29-
run: >-
30-
python3 -m pip install build --user
31-
32-
- name: Build a source distribution and a wheel
33-
run: python3 -m build
34-
35-
- name: Store the distribution packages
36-
uses: actions/upload-artifact@v4
37-
with:
38-
name: python-package-distributions
39-
path: dist/
40-
66+
- name: Checkout code
67+
uses: actions/checkout@v4
68+
with:
69+
ref: ${{ github.event.workflow_run.head_sha }}
70+
71+
- name: Set up Python
72+
uses: actions/setup-python@v5
73+
with:
74+
python-version: "3.12"
75+
76+
- name: Install build dependencies
77+
run: python3 -m pip install --user build
78+
79+
- name: Build sdist & wheel
80+
run: python3 -m build
81+
82+
- name: Store the distribution packages
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: python-package-distributions
86+
path: dist/
87+
88+
# ────────────────────────────────────────────────────────────────────
89+
# 3) Publish to PyPI
90+
# ────────────────────────────────────────────────────────────────────
4191
publish-to-pypi:
42-
name: >-
43-
Publish Python 🐍 distribution PyPI
44-
needs:
45-
- build
92+
name: Publish Python 🐍 distribution to PyPI
93+
needs: [pre-check, build]
94+
if: ${{ needs.pre-check.outputs.release_needed == 'true' }}
4695
runs-on: ubuntu-latest
4796
environment:
4897
name: release
@@ -51,56 +100,52 @@ jobs:
51100
id-token: write
52101

53102
steps:
54-
- name: Download the dists
55-
uses: actions/download-artifact@v4
56-
with:
57-
name: python-package-distributions
58-
path: dist/
59-
60-
- name: Publish to PyPI
61-
uses: pypa/gh-action-pypi-publish@release/v1
62-
103+
- name: Download the dists
104+
uses: actions/download-artifact@v4
105+
with:
106+
name: python-package-distributions
107+
path: dist/
108+
109+
- name: Publish to PyPI
110+
uses: pypa/gh-action-pypi-publish@release/v1
111+
112+
# ────────────────────────────────────────────────────────────────────
113+
# 4) GitHub Release
114+
# ────────────────────────────────────────────────────────────────────
63115
github-release:
64-
name: >-
65-
Create GitHub Release
66-
needs:
67-
- publish-to-pypi
116+
name: Create GitHub Release
117+
needs: [pre-check, publish-to-pypi]
118+
if: ${{ needs.pre-check.outputs.release_needed == 'true' }}
68119
runs-on: ubuntu-latest
69-
70120
permissions:
71121
contents: write
72122
id-token: write
73123

74124
steps:
75-
- name: Download dists
76-
uses: actions/download-artifact@v4
77-
with:
78-
name: python-package-distributions
79-
path: dist/
80-
81-
- name: Sign dists with Sigstore
82-
uses: sigstore/gh-action-sigstore-python@v3.0.0
83-
with:
84-
inputs: >-
85-
./dist/*.tar.gz
86-
./dist/*.whl
87-
88-
- name: Create GitHub Release
89-
env:
90-
GITHUB_TOKEN: ${{ github.token }}
91-
run: >-
92-
gh release create
93-
'v0.2.12'
94-
--repo '${{ github.repository }}'
95-
--notes ""
96-
97-
- name: Upload artifact signatures to GitHub Release
98-
env:
99-
GITHUB_TOKEN: ${{ github.token }}
100-
# Upload to GitHub Release using the `gh` CLI.
101-
# `dist/` contains the built packages, and the
102-
# sigstore-produced signatures and certificates.
103-
run: >-
104-
gh release upload
105-
'v0.2.12' dist/**
106-
--repo '${{ github.repository }}'
125+
- name: Download the dists
126+
uses: actions/download-artifact@v4
127+
with:
128+
name: python-package-distributions
129+
path: dist/
130+
131+
- name: Sign dists with Sigstore
132+
uses: sigstore/gh-action-sigstore-python@v3.0.0
133+
with:
134+
inputs: |
135+
./dist/*.tar.gz
136+
./dist/*.whl
137+
138+
- name: Create GitHub Release
139+
env:
140+
GITHUB_TOKEN: ${{ github.token }}
141+
run: |
142+
gh release create "v${{ needs.pre-check.outputs.version }}" \
143+
--repo "${{ github.repository }}" \
144+
--notes ""
145+
146+
- name: Upload artefacts to Release
147+
env:
148+
GITHUB_TOKEN: ${{ github.token }}
149+
run: |
150+
gh release upload "v${{ needs.pre-check.outputs.version }}" dist/** \
151+
--repo "${{ github.repository }}"

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,7 @@ etc/
7070
digest.txt
7171
.runs/
7272

73-
*.pyc
73+
*.pyc
74+
75+
# Repomix
76+
repomix-output.*

.repomixignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
examples/
2+
LICENSE
3+
.gitignore
4+
.repomixignore

0 commit comments

Comments
 (0)