Skip to content

Commit 8fdbee1

Browse files
committed
Update CI and publish workflows for branch flexibility
Adds explicit 'shell: bash' to CI workflow steps for consistency. Updates publish workflow to allow TestPyPI publishing from any branch while restricting production PyPI publishing to the main branch, with improved branch validation and clearer messaging.
1 parent 9509291 commit 8fdbee1

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
cache-dependency-glob: "pyproject.toml"
3838

3939
- name: Install linting tools
40+
shell: bash
4041
run: |
4142
uv pip install --system ruff mypy
4243
@@ -74,11 +75,13 @@ jobs:
7475
cache-dependency-glob: "pyproject.toml"
7576

7677
- name: Install dependencies
78+
shell: bash
7779
run: |
7880
uv pip install --system -e .
7981
uv pip install --system pytest pytest-asyncio pytest-cov
8082
8183
- name: Run comprehensive test suite
84+
shell: bash
8285
run: |
8386
uv run pytest tests/ \
8487
--cov=src/TcpSocketMCP \

.github/workflows/publish.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,56 @@ on:
66
workflow_dispatch:
77
inputs:
88
test_pypi:
9-
description: 'Publish to TestPyPI instead of PyPI'
9+
description: 'Publish to TestPyPI (allowed from any branch) instead of PyPI (main branch only)'
1010
required: false
1111
default: false
1212
type: boolean
1313

14-
# Only allow publishing from main branch
14+
# Branch protection: Only production PyPI requires main branch
15+
# TestPyPI publishing allowed from any branch
1516
env:
1617
PUBLISH_BRANCH: main
1718

1819
jobs:
19-
# Block publishing from non-main branches
20+
# Branch validation: Enforce main for PyPI, allow any branch for TestPyPI
2021
check-branch:
2122
name: Check Branch Protection
2223
runs-on: ubuntu-latest
2324
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
2425
steps:
2526
- uses: actions/checkout@v4
2627

27-
- name: Verify main branch
28+
- name: Verify branch requirements
2829
run: |
2930
CURRENT_BRANCH=${GITHUB_REF#refs/heads/}
31+
IS_TEST_PYPI="${{ github.event.inputs.test_pypi || 'false' }}"
32+
IS_RELEASE="${{ github.event_name == 'release' }}"
33+
3034
echo "Current branch: $CURRENT_BRANCH"
31-
echo "Required branch: ${{ env.PUBLISH_BRANCH }}"
35+
echo "Required branch for PyPI: ${{ env.PUBLISH_BRANCH }}"
36+
echo "Publishing to TestPyPI: $IS_TEST_PYPI"
37+
echo "Release event: $IS_RELEASE"
38+
39+
# Allow TestPyPI publishing from any branch
40+
if [ "$IS_TEST_PYPI" = "true" ]; then
41+
echo "✅ TestPyPI publishing allowed from any branch ($CURRENT_BRANCH)"
42+
echo "✅ Branch check passed - proceeding with TestPyPI publish"
43+
exit 0
44+
fi
3245
46+
# For production PyPI, require main branch
3347
if [ "$CURRENT_BRANCH" != "${{ env.PUBLISH_BRANCH }}" ]; then
34-
echo "❌ ERROR: Publishing is only allowed from the '${{ env.PUBLISH_BRANCH }}' branch"
48+
echo "❌ ERROR: Production PyPI publishing is only allowed from the '${{ env.PUBLISH_BRANCH }}' branch"
3549
echo "Current branch is: $CURRENT_BRANCH"
36-
echo "Please create a release from the main branch or switch to main before manual publish"
50+
echo ""
51+
echo "Options:"
52+
echo "1. Switch to main branch for production PyPI publishing"
53+
echo "2. Use 'test_pypi: true' to publish to TestPyPI from this branch"
54+
echo "3. Create a release from the main branch"
3755
exit 1
3856
fi
3957
40-
echo "✅ Branch check passed - proceeding with publish"
58+
echo "✅ Production PyPI branch check passed - proceeding with PyPI publish"
4159
4260
# Ensure CI passes before allowing publish
4361
check-ci:

0 commit comments

Comments
 (0)