-
Notifications
You must be signed in to change notification settings - Fork 42
Implement version check for beta indicator in publish workflow and adding release workflow #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| name: Publish Python SDK on Release | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v2 | ||
|
|
||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Install dev dependencies with uv | ||
| working-directory: python-sdk | ||
| run: | | ||
| uv sync --group dev | ||
|
|
||
| - name: Install python-sdk package (editable) | ||
| working-directory: python-sdk | ||
| run: | | ||
| uv pip install -e . | ||
|
|
||
| - name: Run tests with pytest and coverage | ||
| working-directory: python-sdk | ||
| run: | | ||
| uv run pytest --cov=exospherehost --cov-report=xml --cov-report=term-missing -v --junitxml=pytest-report.xml | ||
|
|
||
| - name: Upload coverage reports to Codecov | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| slug: exospherehost/exospherehost | ||
| files: python-sdk/coverage.xml | ||
| flags: python-sdk-unittests | ||
| name: python-sdk-coverage-report | ||
| fail_ci_if_error: true | ||
|
|
||
| - name: Upload test results | ||
| uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: python-sdk-test-results | ||
| path: python-sdk/pytest-report.xml | ||
| retention-days: 30 | ||
|
|
||
| publish: | ||
| runs-on: ubuntu-latest | ||
| needs: test | ||
| defaults: | ||
| run: | ||
| working-directory: python-sdk | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: astral-sh/setup-uv@v6 | ||
| name: Install uv | ||
|
|
||
| - run: uv python install | ||
|
|
||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - run: uv sync --locked --dev | ||
|
|
||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Update version to release tag | ||
| run: | | ||
| # Extract version from tag (remove 'v' or 'V' prefix if present) | ||
| RELEASE_VERSION="${{ github.ref_name }}" | ||
|
|
||
| # Handle empty or invalid tags | ||
| if [[ -z "$RELEASE_VERSION" ]]; then | ||
| echo "ERROR: Release tag is empty" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Remove 'v' or 'V' prefix (case insensitive) | ||
| if [[ $RELEASE_VERSION =~ ^[vV] ]]; then | ||
| RELEASE_VERSION="${RELEASE_VERSION#?}" # Remove first character | ||
| fi | ||
|
|
||
| # Validate the extracted version is not empty | ||
| if [[ -z "$RELEASE_VERSION" ]]; then | ||
| echo "ERROR: Invalid tag format - version part is empty" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Update the version file | ||
| echo "version = \"$RELEASE_VERSION\"" > exospherehost/_version.py | ||
|
|
||
| echo "Updated version to $RELEASE_VERSION for release" | ||
|
|
||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Verify version format | ||
| run: | | ||
| python -c " | ||
| import sys | ||
| sys.path.append('.') | ||
| from exospherehost._version import version | ||
| import re | ||
|
|
||
| # Check if version matches semantic versioning pattern | ||
| if not re.match(r'^\d+\.\d+\.\d+$', version): | ||
| print(f'ERROR: Version {version} does not match semantic versioning pattern (x.y.z)') | ||
| sys.exit(1) | ||
|
|
||
| # Ensure it's not a beta version (should not contain 'b') | ||
| if 'b' in version: | ||
| print(f'ERROR: Release version {version} contains beta indicator. Release versions should not be beta.') | ||
| sys.exit(1) | ||
|
|
||
| print(f'Version {version} is valid for release publishing') | ||
| " | ||
|
|
||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - run: uv build | ||
|
|
||
| - run: uv publish | ||
|
Comment on lines
+1
to
+126
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) General: consider provenance on PyPI and SBOMs for releases. For release artifacts, enabling provenance ( 🧰 Tools🪛 YAMLlint (1.37.1)[warning] 3-3: truthy value should be one of [false, true] (truthy) [error] 73-73: trailing spaces (trailing-spaces) [error] 80-80: trailing spaces (trailing-spaces) [error] 86-86: trailing spaces (trailing-spaces) [error] 91-91: trailing spaces (trailing-spaces) [error] 97-97: trailing spaces (trailing-spaces) [error] 100-100: trailing spaces (trailing-spaces) [error] 110-110: trailing spaces (trailing-spaces) [error] 115-115: trailing spaces (trailing-spaces) [error] 120-120: trailing spaces (trailing-spaces) [error] 126-126: no new line character at the end of file (new-line-at-end-of-file) [error] 126-126: trailing spaces (trailing-spaces) 🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai explain more, what is this?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NiveditJain Great question! Let me explain provenance and SBOMs in the context of software supply chain security: ProvenanceProvenance is cryptographic proof of how your software package was built. When you use
SBOM (Software Bill of Materials)An SBOM is like an "ingredient list" for your software package:
Why This Matters for Your SDK
ImplementationFor your workflow, it would look like: - run: uv publish --provenance # Adds cryptographic proof
- name: Generate SBOM
run: |
uv export --format=requirements-txt > requirements.txt
cyclonedx-py -r requirements.txt -o sbom.json
- name: Upload SBOM
uses: actions/upload-artifact@v4
with:
name: sbom
path: sbom.jsonThink of it as adding a "digital passport" and "ingredient list" to your software packages!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai lets add this in next cycle create an issue for this please!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainI'll create a GitHub issue to track this enhancement for the next development cycle! @NiveditJain Perfect! I've created a GitHub issue to track the implementation of provenance and SBOM support for your Python SDK release workflow. The issue includes:
This enhancement will significantly improve your SDK's supply chain security posture when you're ready to implement it in the next development cycle! 🚀 🏁 Script executed: Length of output: 1958 @NiveditJain Perfect! ✅ I've successfully created GitHub issue #265 to track the implementation of provenance and SBOM support for your Python SDK release workflow. The issue is now:
You can track progress on the issue and reference it in future PRs when implementing these security improvements! 🎯 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,9 +25,7 @@ jobs: | |
| python-version: '3.12' | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v2 | ||
| with: | ||
| cache: true | ||
| uses: astral-sh/setup-uv@v6 | ||
|
|
||
|
Comment on lines
27
to
29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Good upgrade to setup-uv v6; consider pinning to a commit SHA for supply-chain hardening. Pinning actions to a specific commit digest prevents unexpected changes when the action’s tag is moved. Example: - uses: astral-sh/setup-uv@v6
+ uses: astral-sh/setup-uv@<commit-sha>
# v6 ref: https://github.com/astral-sh/setup-uv/commits/v6🤖 Prompt for AI Agents |
||
| - name: Install dev dependencies with uv | ||
| working-directory: python-sdk | ||
|
|
@@ -79,6 +77,18 @@ jobs: | |
|
|
||
| - run: uv sync --locked --dev | ||
|
|
||
| - name: Check version for beta indicator | ||
| run: | | ||
| python -c " | ||
| import sys | ||
| sys.path.append('.') | ||
| from exospherehost._version import version | ||
| if 'b' not in version: | ||
| print(f'ERROR: Version {version} does not contain beta indicator (b). Major releases are only allowed through GitHub releases.') | ||
| sys.exit(1) | ||
| print(f'Version {version} is valid for PyPI publishing (contains beta indicator)') | ||
| " | ||
|
|
||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - run: uv build | ||
|
|
||
| - run: uv publish | ||
Uh oh!
There was an error while loading. Please reload this page.