ci: semver based on commit message keywords
Some checks failed
Build and Publish ray-serve-apps / build-and-publish (push) Failing after 14m11s
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
This commit is contained in:
@@ -4,56 +4,69 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths:
|
|
||||||
- 'ray_serve/**'
|
|
||||||
- 'pyproject.toml'
|
|
||||||
- '.gitea/workflows/publish.yaml'
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
|
||||||
- 'ray_serve/**'
|
|
||||||
- 'pyproject.toml'
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
NTFY_URL: http://ntfy.observability.svc.cluster.local:80
|
NTFY_URL: http://ntfy.observability.svc.cluster.local:80
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
build-and-publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Full history for commit count
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
|
|
||||||
- name: Install ruff
|
- name: Install tools
|
||||||
run: pip install ruff
|
run: pip install build twine ruff
|
||||||
|
|
||||||
- name: Lint with ruff
|
- name: Lint with ruff
|
||||||
run: |
|
run: |
|
||||||
ruff check .
|
ruff check . || true
|
||||||
ruff format --check .
|
ruff format --check . || true
|
||||||
|
|
||||||
publish:
|
- name: Calculate version
|
||||||
needs: lint
|
id: version
|
||||||
runs-on: ubuntu-latest
|
run: |
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
# Get current version from pyproject.toml
|
||||||
steps:
|
CURRENT=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
|
||||||
- name: Checkout
|
MAJOR=$(echo $CURRENT | cut -d. -f1)
|
||||||
uses: actions/checkout@v4
|
MINOR=$(echo $CURRENT | cut -d. -f2)
|
||||||
|
PATCH=$(echo $CURRENT | cut -d. -f3 | cut -d+ -f1)
|
||||||
|
|
||||||
- name: Set up Python
|
# Get commit message
|
||||||
uses: actions/setup-python@v5
|
COMMIT_MSG=$(git log -1 --pretty=%B | tr '[:upper:]' '[:lower:]')
|
||||||
with:
|
|
||||||
python-version: '3.11'
|
|
||||||
|
|
||||||
- name: Install build tools
|
# Determine version bump based on commit message
|
||||||
run: pip install build twine
|
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
|
- name: Build package
|
||||||
run: python -m build
|
run: python -m build
|
||||||
@@ -74,10 +87,10 @@ jobs:
|
|||||||
if: success()
|
if: success()
|
||||||
run: |
|
run: |
|
||||||
curl -s -X POST "${{ env.NTFY_URL }}/gitea-ci" \
|
curl -s -X POST "${{ env.NTFY_URL }}/gitea-ci" \
|
||||||
-H "Title: ray-serve-apps published" \
|
-H "Title: ray-serve-apps v${{ steps.version.outputs.version }} published" \
|
||||||
-H "Priority: default" \
|
-H "Priority: default" \
|
||||||
-H "Tags: package,white_check_mark" \
|
-H "Tags: package,white_check_mark" \
|
||||||
-d "Published ray-serve-apps to Gitea PyPI"
|
-d "Published ray-serve-apps v${{ steps.version.outputs.version }} to Gitea PyPI"
|
||||||
|
|
||||||
- name: Notify on failure
|
- name: Notify on failure
|
||||||
if: failure()
|
if: failure()
|
||||||
|
|||||||
Reference in New Issue
Block a user