|
|
|
@@ -3,7 +3,7 @@ name: Rust Cross-Platform Build
|
|
|
|
|
on:
|
|
|
|
|
workflow_dispatch:
|
|
|
|
|
push:
|
|
|
|
|
branches: [ "development", "main", "feature/*", "bugfix/*", "enhancement/*" ]
|
|
|
|
|
branches: [ "development", "main", "staging" ]
|
|
|
|
|
tags: [ "v*.*.*" ]
|
|
|
|
|
|
|
|
|
|
env:
|
|
|
|
@@ -149,64 +149,57 @@ jobs:
|
|
|
|
|
path: |
|
|
|
|
|
${{ needs.detect-project.outputs.project-dir }}/target/${{ matrix.target }}/release/${{ needs.detect-project.outputs.project-name }}${{ matrix.os == 'windows' && '.exe' || '' }}
|
|
|
|
|
|
|
|
|
|
set-tag:
|
|
|
|
|
name: Set Tag Name
|
|
|
|
|
needs: [detect-project, build]
|
|
|
|
|
#if: ${{ !failure() && !cancelled() && github.event_name != 'pull_request' }}
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
outputs:
|
|
|
|
|
tag_name: ${{ steps.set_tag.outputs.tag_name }}
|
|
|
|
|
should_tag: ${{ steps.set_tag.outputs.should_tag }}
|
|
|
|
|
steps:
|
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
set-tag:
|
|
|
|
|
name: Set Tag Name
|
|
|
|
|
needs: [detect-project, build]
|
|
|
|
|
#if: ${{ !failure() && !cancelled() && github.event_name != 'pull_request' }}
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
outputs:
|
|
|
|
|
tag_name: ${{ steps.set_tag.outputs.tag_name }}
|
|
|
|
|
should_tag: ${{ steps.set_tag.outputs.should_tag }}
|
|
|
|
|
steps:
|
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
|
|
|
|
|
- name: Determine next semantic version tag
|
|
|
|
|
id: set_tag
|
|
|
|
|
run: |
|
|
|
|
|
git fetch --tags
|
|
|
|
|
- name: Determine next semantic version tag
|
|
|
|
|
id: set_tag
|
|
|
|
|
run: |
|
|
|
|
|
git fetch --tags
|
|
|
|
|
|
|
|
|
|
# Find latest tag matching vX.Y.Z
|
|
|
|
|
latest_tag=$(git tag --list 'v*.*.*' --sort=-v:refname | head -n 1)
|
|
|
|
|
if [[ -z "$latest_tag" ]]; then
|
|
|
|
|
major=0
|
|
|
|
|
minor=0
|
|
|
|
|
patch=0
|
|
|
|
|
else
|
|
|
|
|
version="${latest_tag#v}"
|
|
|
|
|
IFS='.' read -r major minor patch <<< "$version"
|
|
|
|
|
fi
|
|
|
|
|
# Find latest tag matching vX.Y.Z
|
|
|
|
|
latest_tag=$(git tag --list 'v*.*.*' --sort=-v:refname | head -n 1)
|
|
|
|
|
if [[ -z "$latest_tag" ]]; then
|
|
|
|
|
major=0
|
|
|
|
|
minor=0
|
|
|
|
|
patch=0
|
|
|
|
|
else
|
|
|
|
|
version="${latest_tag#v}"
|
|
|
|
|
IFS='.' read -r major minor patch <<< "$version"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
|
|
|
|
|
major=$((major + 1))
|
|
|
|
|
minor=0
|
|
|
|
|
patch=0
|
|
|
|
|
new_tag="v${major}.${minor}.${patch}"
|
|
|
|
|
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "should_tag=true" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "Creating new major version tag: ${new_tag}"
|
|
|
|
|
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
|
|
|
|
|
major=$((major + 1))
|
|
|
|
|
minor=0
|
|
|
|
|
patch=0
|
|
|
|
|
new_tag="v${major}.${minor}.${patch}"
|
|
|
|
|
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "should_tag=true" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "Creating new major version tag: ${new_tag}"
|
|
|
|
|
|
|
|
|
|
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
|
|
|
|
|
minor=$((minor + 1))
|
|
|
|
|
patch=0
|
|
|
|
|
new_tag="v${major}.${minor}.${patch}"
|
|
|
|
|
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "should_tag=true" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "Creating new minor version tag: ${new_tag}"
|
|
|
|
|
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
|
|
|
|
|
minor=$((minor + 1))
|
|
|
|
|
patch=0
|
|
|
|
|
new_tag="v${major}.${minor}.${patch}"
|
|
|
|
|
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "should_tag=true" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "Creating new minor version tag: ${new_tag}"
|
|
|
|
|
|
|
|
|
|
elif [[ "${GITHUB_REF}" == "refs/heads/staging" ]]; then
|
|
|
|
|
patch=$((patch + 1))
|
|
|
|
|
new_tag="v${major}.${minor}.${patch}"
|
|
|
|
|
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "should_tag=true" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "Creating new patch version tag: ${new_tag}"
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
echo "Not on main, development, or staging branch."
|
|
|
|
|
echo "Branch: ${GITHUB_REF}"
|
|
|
|
|
echo "Skipping tag creation and Docker build."
|
|
|
|
|
echo "should_tag=false" >> $GITHUB_OUTPUT
|
|
|
|
|
# Don't set tag_name output for non-release branches
|
|
|
|
|
fi
|
|
|
|
|
elif [[ "${GITHUB_REF}" == "refs/heads/staging" ]]; then
|
|
|
|
|
patch=$((patch + 1))
|
|
|
|
|
new_tag="v${major}.${minor}.${patch}"
|
|
|
|
|
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "should_tag=true" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "Creating new patch version tag: ${new_tag}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
docker-build:
|
|
|
|
|
name: Build and Push Docker Image
|
|
|
|
@@ -267,6 +260,7 @@ set-tag:
|
|
|
|
|
env:
|
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
run: |
|
|
|
|
|
echo "Creating new tag: ${{ needs.set-tag.outputs.tag_name }}"
|
|
|
|
|
git tag ${{ needs.set-tag.outputs.tag_name }}
|
|
|
|
|
git push origin ${{ needs.set-tag.outputs.tag_name }}
|
|
|
|
|
|