Some checks failed
Build and Publish ray-serve-apps / build-and-publish (push) Failing after 14m11s
- 'major' in message -> increment major, reset minor/patch - 'minor' or 'feature' -> increment minor, reset patch - 'bug', 'chore', anything else -> increment patch - Release number from git rev-list commit count - Format: major.minor.patch+release
103 lines
3.3 KiB
YAML
103 lines
3.3 KiB
YAML
name: Build and Publish ray-serve-apps
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
NTFY_URL: http://ntfy.observability.svc.cluster.local:80
|
|
|
|
jobs:
|
|
build-and-publish:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # Full history for commit count
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install tools
|
|
run: pip install build twine ruff
|
|
|
|
- name: Lint with ruff
|
|
run: |
|
|
ruff check . || true
|
|
ruff format --check . || true
|
|
|
|
- name: Calculate version
|
|
id: version
|
|
run: |
|
|
# Get current version from pyproject.toml
|
|
CURRENT=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
|
|
MAJOR=$(echo $CURRENT | cut -d. -f1)
|
|
MINOR=$(echo $CURRENT | cut -d. -f2)
|
|
PATCH=$(echo $CURRENT | cut -d. -f3 | cut -d+ -f1)
|
|
|
|
# Get commit message
|
|
COMMIT_MSG=$(git log -1 --pretty=%B | tr '[:upper:]' '[:lower:]')
|
|
|
|
# Determine version bump based on commit message
|
|
if echo "$COMMIT_MSG" | grep -q "major"; then
|
|
MAJOR=$((MAJOR + 1))
|
|
MINOR=0
|
|
PATCH=0
|
|
elif echo "$COMMIT_MSG" | grep -qE "minor|feature"; then
|
|
MINOR=$((MINOR + 1))
|
|
PATCH=0
|
|
else
|
|
# bug, chore, or anything else
|
|
PATCH=$((PATCH + 1))
|
|
fi
|
|
|
|
# Release number from commit count
|
|
RELEASE=$(git rev-list --count HEAD)
|
|
|
|
VERSION="${MAJOR}.${MINOR}.${PATCH}+${RELEASE}"
|
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
echo "Calculated version: ${VERSION}"
|
|
|
|
- name: Update version in pyproject.toml
|
|
run: |
|
|
sed -i 's/^version = .*/version = "${{ steps.version.outputs.version }}"/' pyproject.toml
|
|
cat pyproject.toml | grep version
|
|
|
|
- name: Build package
|
|
run: python -m build
|
|
|
|
- name: Publish to Gitea PyPI
|
|
env:
|
|
TWINE_USERNAME: ${{ secrets.REGISTRY_USER }}
|
|
TWINE_PASSWORD: ${{ secrets.REGISTRY_TOKEN }}
|
|
TWINE_REPOSITORY_URL: http://gitea-http.gitea.svc.cluster.local:3000/api/packages/daviestechlabs/pypi
|
|
run: |
|
|
if [ -z "$TWINE_USERNAME" ] || [ -z "$TWINE_PASSWORD" ]; then
|
|
echo "ERROR: REGISTRY_USER or REGISTRY_TOKEN secrets not set"
|
|
exit 1
|
|
fi
|
|
python -m twine upload --verbose dist/*
|
|
|
|
- name: Notify on success
|
|
if: success()
|
|
run: |
|
|
curl -s -X POST "${{ env.NTFY_URL }}/gitea-ci" \
|
|
-H "Title: ray-serve-apps v${{ steps.version.outputs.version }} published" \
|
|
-H "Priority: default" \
|
|
-H "Tags: package,white_check_mark" \
|
|
-d "Published ray-serve-apps v${{ steps.version.outputs.version }} to Gitea PyPI"
|
|
|
|
- name: Notify on failure
|
|
if: failure()
|
|
run: |
|
|
curl -s -X POST "${{ env.NTFY_URL }}/gitea-ci" \
|
|
-H "Title: ray-serve-apps publish failed" \
|
|
-H "Priority: high" \
|
|
-H "Tags: package,x" \
|
|
-d "Failed to publish ray-serve-apps to Gitea PyPI"
|