Skip to content

Commit 631f348

Browse files
committed
Rename workflow to match PyPI Trusted Publisher configuration
1 parent fe4641f commit 631f348

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

.github/workflows/workflow.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
# Déclenchement par release
5+
release:
6+
types: [created, published]
7+
8+
# Déclenchement par tag sur la branche official
9+
push:
10+
branches:
11+
- official
12+
tags:
13+
- 'v*'
14+
15+
# Déclenchement manuel
16+
workflow_dispatch:
17+
inputs:
18+
version:
19+
description: 'Version to publish (leave empty to use current)'
20+
required: false
21+
default: ''
22+
23+
jobs:
24+
deploy:
25+
runs-on: ubuntu-latest
26+
27+
# Configuration pour Trusted Publishers
28+
environment: release
29+
permissions:
30+
id-token: write # IMPORTANT pour Trusted Publishers
31+
contents: read
32+
33+
steps:
34+
- name: Checkout official branch
35+
uses: actions/checkout@v4
36+
with:
37+
ref: official
38+
fetch-depth: 0
39+
40+
- name: Set up Python
41+
uses: actions/setup-python@v4
42+
with:
43+
python-version: '3.10'
44+
45+
- name: Install dependencies
46+
run: |
47+
python -m pip install --upgrade pip
48+
pip install build
49+
50+
- name: Get version info
51+
id: version
52+
run: |
53+
if [ "${{ github.event_name }}" = "release" ]; then
54+
echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
55+
echo "trigger=release" >> $GITHUB_OUTPUT
56+
elif [ "${{ github.event_name }}" = "push" ] && [[ "${{ github.ref }}" == refs/tags/* ]]; then
57+
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
58+
echo "trigger=tag" >> $GITHUB_OUTPUT
59+
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
60+
if [ -n "${{ inputs.version }}" ]; then
61+
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
62+
else
63+
echo "version=$(python -c "from src.mcp_server_grist.version import __version__; print(__version__)")" >> $GITHUB_OUTPUT
64+
fi
65+
echo "trigger=manual" >> $GITHUB_OUTPUT
66+
else
67+
echo "version=unknown" >> $GITHUB_OUTPUT
68+
echo "trigger=unknown" >> $GITHUB_OUTPUT
69+
fi
70+
71+
- name: Build package
72+
run: |
73+
echo "Building package from official branch..."
74+
echo "Version: ${{ steps.version.outputs.version }}"
75+
echo "Trigger: ${{ steps.version.outputs.trigger }}"
76+
python -m build
77+
78+
- name: List built files
79+
run: |
80+
echo "Built files:"
81+
ls -la dist/
82+
83+
- name: Publish to PyPI using Trusted Publishers
84+
uses: pypa/gh-action-pypi-publish@release/v1
85+
with:
86+
print: true # Affiche les informations de débogage
87+
88+
- name: Success notification
89+
run: |
90+
echo "✅ Successfully published mcp-server-grist version ${{ steps.version.outputs.version }} to PyPI!"
91+
echo "📦 Package should be available at: https://pypi.org/project/mcp-server-grist/"

0 commit comments

Comments
 (0)