Skip to content

fix(tests): handle __STITCHED__ in package module for runtime mode de… #11

fix(tests): handle __STITCHED__ in package module for runtime mode de…

fix(tests): handle __STITCHED__ in package module for runtime mode de… #11

# .github/workflows/release.yml
name: Release on Github
on:
push:
branches:
- main
workflow_dispatch:
env:
PACKAGE_NAME: apathetic_utils
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # Required to create releases and tags
id-token: write # Required for PyPI publishing (if enabled)
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Install Poetry
uses: abatilo/actions-poetry@v4
with:
poetry-version: "latest"
- name: Install dependencies
run: poetry install --no-interaction
- name: Run checks
run: poetry run poe check
- name: Build stitched script
continue-on-error: true
run: poetry run poe build:stitched
- name: Build zipapp
continue-on-error: true
run: poetry run poe build:zipapp
- name: Semantic Release (Version & Tag)
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
output=$(poetry run semantic-release version 2>&1) || true
echo "$output"
# Check if a new version was created (looks for version number pattern)
if echo "$output" | grep -qE "^[0-9]+\.[0-9]+\.[0-9]+|next version is"; then
echo "released=true" >> $GITHUB_OUTPUT
else
echo "released=false" >> $GITHUB_OUTPUT
fi
- name: Semantic Release (Publish to GitHub)
if: steps.release.outputs.released == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Run semantic-release publish and capture exit code
if ! poetry run semantic-release publish; then
echo "::error::semantic-release publish failed"
exit 1
fi
- name: Upload custom release assets
if: steps.release.outputs.released == 'true'
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get the latest tag created by semantic-release
TAG=$(git describe --tags --abbrev=0)
if [ -z "$TAG" ]; then
echo "::warning::No tag found for release"
exit 0
fi
# Collect available assets
ASSETS=()
if [ -f "dist/${PACKAGE_NAME}.py" ]; then
ASSETS+=("dist/${PACKAGE_NAME}.py")
fi
if [ -f "dist/${PACKAGE_NAME}.pyz" ]; then
ASSETS+=("dist/${PACKAGE_NAME}.pyz")
fi
# Upload assets if any are available
if [ ${#ASSETS[@]} -eq 0 ]; then
echo "::notice::No build artifacts found to upload"
exit 0
fi
echo "Uploading ${#ASSETS[@]} asset(s): ${ASSETS[*]}"
if ! gh release upload "$TAG" "${ASSETS[@]}" --clobber; then
echo "::warning::Failed to upload release assets (non-fatal)"
exit 0
fi