feat: Add semantic versioning based on commit message prefixes
Some checks failed
Build and Push Images / determine-version (push) Successful in 55s
Build and Push Images / build-nvidia (push) Failing after 1h52m48s
Build and Push Images / build-rdna2 (push) Failing after 3h14m40s
Build and Push Images / build-strixhalo (push) Failing after 1h52m42s
Build and Push Images / build-intel (push) Failing after 3h14m39s
Build and Push Images / Release (push) Has been cancelled
Build and Push Images / Notify (push) Has been cancelled
Some checks failed
Build and Push Images / determine-version (push) Successful in 55s
Build and Push Images / build-nvidia (push) Failing after 1h52m48s
Build and Push Images / build-rdna2 (push) Failing after 3h14m40s
Build and Push Images / build-strixhalo (push) Failing after 1h52m42s
Build and Push Images / build-intel (push) Failing after 3h14m39s
Build and Push Images / Release (push) Has been cancelled
Build and Push Images / Notify (push) Has been cancelled
- Added determine-version job that runs BEFORE builds - Version bump based on commit message: - major: or BREAKING CHANGE → major bump - minor:, feat:, or feature: → minor bump - everything else → patch bump - All build jobs now depend on determine-version - Images tagged with calculated version (e.g. v1.2.3) + latest - Release job creates git tag after successful builds - Notify job includes version info in notifications - PRs get tagged with pr-<number> - Manual tag pushes use tag directly (no version recalculation)
This commit is contained in:
@@ -29,7 +29,65 @@ env:
|
||||
NTFY_URL: http://ntfy.observability.svc.cluster.local:80
|
||||
|
||||
jobs:
|
||||
# Determine semantic version BEFORE building images
|
||||
determine-version:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
bump: ${{ steps.version.outputs.bump }}
|
||||
should_release: ${{ steps.version.outputs.should_release }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Calculate semantic version
|
||||
id: version
|
||||
run: |
|
||||
# Skip version calculation for PRs and tag pushes
|
||||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||
echo "version=pr-${{ github.event.number }}" >> $GITHUB_OUTPUT
|
||||
echo "bump=none" >> $GITHUB_OUTPUT
|
||||
echo "should_release=false" >> $GITHUB_OUTPUT
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# For tag pushes, use the tag directly
|
||||
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
|
||||
VERSION="${{ github.ref_name }}"
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "bump=tag" >> $GITHUB_OUTPUT
|
||||
echo "should_release=false" >> $GITHUB_OUTPUT
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Get latest tag or default to v0.0.0
|
||||
LATEST=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
VERSION=${LATEST#v}
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
|
||||
|
||||
# Check commit message for version bump keywords
|
||||
MSG="${{ github.event.head_commit.message }}"
|
||||
if echo "$MSG" | grep -qiE "^major:|BREAKING CHANGE"; then
|
||||
MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0
|
||||
BUMP="major"
|
||||
elif echo "$MSG" | grep -qiE "^(minor:|feat:|feature:)"; then
|
||||
MINOR=$((MINOR + 1)); PATCH=0
|
||||
BUMP="minor"
|
||||
else
|
||||
PATCH=$((PATCH + 1))
|
||||
BUMP="patch"
|
||||
fi
|
||||
|
||||
NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}"
|
||||
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "bump=$BUMP" >> $GITHUB_OUTPUT
|
||||
echo "should_release=true" >> $GITHUB_OUTPUT
|
||||
echo "📦 Version: $LATEST → $NEW_VERSION ($BUMP bump)"
|
||||
|
||||
build-nvidia:
|
||||
needs: [determine-version]
|
||||
# Skip if commit message contains [skip images] or [ray-serve only]
|
||||
if: |
|
||||
!contains(github.event.head_commit.message, '[skip images]') &&
|
||||
@@ -69,10 +127,7 @@ jobs:
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/ray-worker-nvidia
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=${{ needs.determine-version.outputs.version }}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push
|
||||
@@ -87,6 +142,7 @@ jobs:
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
build-rdna2:
|
||||
needs: [determine-version]
|
||||
if: |
|
||||
!contains(github.event.head_commit.message, '[skip images]') &&
|
||||
!contains(github.event.head_commit.message, '[ray-serve only]') &&
|
||||
@@ -122,10 +178,7 @@ jobs:
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/ray-worker-rdna2
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=${{ needs.determine-version.outputs.version }}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push
|
||||
@@ -140,6 +193,7 @@ jobs:
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
build-strixhalo:
|
||||
needs: [determine-version]
|
||||
if: |
|
||||
!contains(github.event.head_commit.message, '[skip images]') &&
|
||||
!contains(github.event.head_commit.message, '[ray-serve only]') &&
|
||||
@@ -175,10 +229,7 @@ jobs:
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/ray-worker-strixhalo
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=${{ needs.determine-version.outputs.version }}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push
|
||||
@@ -193,6 +244,7 @@ jobs:
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
build-intel:
|
||||
needs: [determine-version]
|
||||
if: |
|
||||
!contains(github.event.head_commit.message, '[skip images]') &&
|
||||
!contains(github.event.head_commit.message, '[ray-serve only]') &&
|
||||
@@ -228,10 +280,7 @@ jobs:
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/ray-worker-intel
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=${{ needs.determine-version.outputs.version }}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push
|
||||
@@ -248,51 +297,28 @@ jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-nvidia, build-rdna2, build-strixhalo, build-intel]
|
||||
if: gitea.ref == 'refs/heads/main' && gitea.event_name == 'push'
|
||||
needs: [determine-version, build-nvidia, build-rdna2, build-strixhalo, build-intel]
|
||||
if: needs.determine-version.outputs.should_release == 'true' && gitea.ref == 'refs/heads/main' && gitea.event_name == 'push'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Determine version bump
|
||||
id: version
|
||||
run: |
|
||||
# Get latest tag or default to v0.0.0
|
||||
LATEST=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
VERSION=${LATEST#v}
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
|
||||
|
||||
# Check commit message for keywords
|
||||
MSG="${{ gitea.event.head_commit.message }}"
|
||||
if echo "$MSG" | grep -qiE "^major:|BREAKING CHANGE"; then
|
||||
MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0
|
||||
BUMP="major"
|
||||
elif echo "$MSG" | grep -qiE "^(minor:|feat:)"; then
|
||||
MINOR=$((MINOR + 1)); PATCH=0
|
||||
BUMP="minor"
|
||||
else
|
||||
PATCH=$((PATCH + 1))
|
||||
BUMP="patch"
|
||||
fi
|
||||
|
||||
NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}"
|
||||
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "bump=$BUMP" >> $GITHUB_OUTPUT
|
||||
echo "Bumping $LATEST → $NEW_VERSION ($BUMP)"
|
||||
|
||||
- name: Create and push tag
|
||||
run: |
|
||||
VERSION="${{ needs.determine-version.outputs.version }}"
|
||||
BUMP="${{ needs.determine-version.outputs.bump }}"
|
||||
echo "📦 Creating release tag: $VERSION ($BUMP bump)"
|
||||
git config user.name "gitea-actions[bot]"
|
||||
git config user.email "actions@git.daviestechlabs.io"
|
||||
git tag -a ${{ steps.version.outputs.version }} -m "Release ${{ steps.version.outputs.version }}"
|
||||
git push origin ${{ steps.version.outputs.version }}
|
||||
git tag -a "$VERSION" -m "Release $VERSION ($BUMP)"
|
||||
git push origin "$VERSION"
|
||||
|
||||
notify:
|
||||
name: Notify
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-nvidia, build-rdna2, build-strixhalo, build-intel, release]
|
||||
needs: [determine-version, build-nvidia, build-rdna2, build-strixhalo, build-intel, release]
|
||||
if: always()
|
||||
steps:
|
||||
- name: Notify on success
|
||||
@@ -308,6 +334,7 @@ jobs:
|
||||
-H "Tags: white_check_mark,docker" \
|
||||
-H "Click: ${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}" \
|
||||
-d "Branch: ${{ gitea.ref_name }}
|
||||
Version: ${{ needs.determine-version.outputs.version }} (${{ needs.determine-version.outputs.bump }})
|
||||
nvidia: ${{ needs.build-nvidia.result }}
|
||||
rdna2: ${{ needs.build-rdna2.result }}
|
||||
strixhalo: ${{ needs.build-strixhalo.result }}
|
||||
@@ -328,6 +355,7 @@ jobs:
|
||||
-H "Tags: x,docker" \
|
||||
-H "Click: ${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}" \
|
||||
-d "Branch: ${{ gitea.ref_name }}
|
||||
Version: ${{ needs.determine-version.outputs.version }}
|
||||
nvidia: ${{ needs.build-nvidia.result }}
|
||||
rdna2: ${{ needs.build-rdna2.result }}
|
||||
strixhalo: ${{ needs.build-strixhalo.result }}
|
||||
|
||||
Reference in New Issue
Block a user