-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (134 loc) · 5.43 KB
/
Copy pathrelease.yml
File metadata and controls
155 lines (134 loc) · 5.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Release Pipeline — publish to PyPI and create GitHub Release
#
# Triggers:
# - Push a tag matching v*.*.* (e.g. v0.1.0, v0.2.0a1)
# - Manual dispatch with version input
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Version tag to release (e.g. v0.1.0)"
required: true
type: string
permissions:
contents: write
id-token: write
attestations: write
env:
PYTHON_VERSION: "3.12"
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
# ────────────────────────────────────────────────────────────
# 1. Quality gate
# ────────────────────────────────────────────────────────────
quality-gate:
name: Quality Gate
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
is_prerelease: ${{ steps.meta.outputs.is_prerelease }}
steps:
- uses: actions/checkout@v5
- name: Parse version
id: meta
run: |
TAG="${{ github.event.inputs.tag || github.ref_name }}"
VERSION="${TAG#v}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
if [[ "$VERSION" == *a* ]] || [[ "$VERSION" == *b* ]] || [[ "$VERSION" == *dev* ]] || [[ "$VERSION" == *rc* ]]; then
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install & lint
run: |
pip install -e . ruff black
ruff check src/
black --check src/
- name: Import check
run: python -c "from fluid_provider_sdk import BaseProvider, ApplyResult, ProviderError; print('OK')"
- name: Verify version matches tag
run: |
PKG_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
TAG_VERSION="${{ steps.meta.outputs.version }}"
TAG_BASE=$(echo "$TAG_VERSION" | sed 's/[ab].*//' | sed 's/\.dev.*//' | sed 's/rc.*//')
if [ "$PKG_VERSION" != "$TAG_BASE" ] && [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
echo "::error::Version mismatch: pyproject.toml=${PKG_VERSION}, tag=${TAG_VERSION}"
exit 1
fi
# ────────────────────────────────────────────────────────────
# 2. Build
# ────────────────────────────────────────────────────────────
build:
name: Build Package
needs: quality-gate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Build
run: |
pip install build twine
python -m build
twine check dist/*
- name: Smoke test
run: |
python -m venv /tmp/test-install
/tmp/test-install/bin/pip install dist/*.whl
/tmp/test-install/bin/python -c "from fluid_provider_sdk import BaseProvider; print('OK')"
- uses: actions/upload-artifact@v5
with:
name: dist
path: dist/
retention-days: 30
# ────────────────────────────────────────────────────────────
# 3. Publish to PyPI
# ────────────────────────────────────────────────────────────
publish-pypi:
name: Publish to PyPI
needs: [quality-gate, build]
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/p/fluid-provider-sdk
steps:
- uses: actions/download-artifact@v5
with:
name: dist
path: dist/
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
# ────────────────────────────────────────────────────────────
# 4. GitHub Release
# ────────────────────────────────────────────────────────────
github-release:
name: GitHub Release
needs: [quality-gate, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/download-artifact@v5
with:
name: dist
path: dist/
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
name: "fluid-provider-sdk ${{ needs.quality-gate.outputs.version }}"
prerelease: ${{ needs.quality-gate.outputs.is_prerelease == 'true' }}
generate_release_notes: true
files: dist/*