Skip to content
24 changes: 11 additions & 13 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Linux
on: [push, pull_request, release]
name: 🐧 Linux

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
Expand All @@ -9,20 +15,12 @@ jobs:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu g++",
os: ubuntu-latest,
compiler: "g++"
}
- {
name: "Ubuntu clang++",
os: ubuntu-latest,
compiler: "clang++"
}
- { name: "Ubuntu g++", os: ubuntu-latest, compiler: "g++" }
- { name: "Ubuntu clang++", os: ubuntu-latest, compiler: "clang++" }

steps:
- name: Checkout atta
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install dependencies
run: |
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: MacOS
on: [push, pull_request, release]
name: 🍎 MacOS

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
Expand All @@ -9,15 +15,11 @@ jobs:
fail-fast: false
matrix:
config:
- {
name: "MacOS Latest",
os: macos-latest,
build_type: "Release"
}
- { name: "MacOS Latest", os: macos-latest, build_type: "Release" }

steps:
- name: Checkout atta
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install dependencies on macos
if: startsWith(matrix.config.os, 'macos')
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/updateReadmeButtons.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update readme buttons
name: 📄 Update README

on:
project_card:
Expand Down
136 changes: 136 additions & 0 deletions .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: 🏷️ Auto Versioning

on:
pull_request:
types:
- labeled # Runs when labels are added to the PR

jobs:
versioning:
name: Auto Versioning
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history to enable merging

- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Get PR Labels
id: labels
uses: actions/github-script@v7
with:
script: |
const labels = context.payload.pull_request.labels.map(label => label.name);
console.log("PR Labels:", labels);
return labels;

- name: Check if Version Label Exists
id: check_version_label
run: |
if echo "${{ steps.labels.outputs.result }}" | grep -Eq "version:(major|minor|patch)"; then
echo "run_versioning=true" >> $GITHUB_ENV
else
echo "::notice::No versioning label found. Skipping workflow."
exit 0
fi

- name: Merge `dev` into PR Branch
if: env.run_versioning == 'true'
run: |
git fetch origin dev
git checkout ${{ github.head_ref }}
if git merge --no-edit origin/dev; then
echo "Merge successful."
else
echo "::error::Merge conflict detected! Resolve conflicts manually."
exit 1
fi
continue-on-error: false

- name: Get Current Version from `dev`
if: env.run_versioning == 'true'
run: |
git checkout origin/dev -- CMakeLists.txt
VERSION=$(sed -nE 's/project\(atta VERSION ([0-9]+\.[0-9]+\.[0-9]+).*/\1/p' CMakeLists.txt)

if [[ -z "$VERSION" ]]; then
echo "::error::Failed to extract version from CMakeLists.txt"
exit 1
fi

echo "::notice::Current Version (from dev): $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Determine Version Increment
if: env.run_versioning == 'true'
run: |
echo "::notice::PR Labels Found: ${{ steps.labels.outputs.result }}"
if echo "${{ steps.labels.outputs.result }}" | grep -q "version:major"; then
echo "increment=major" >> $GITHUB_ENV
echo "::notice::Version Increment: major"
elif echo "${{ steps.labels.outputs.result }}" | grep -q "version:minor"; then
echo "increment=minor" >> $GITHUB_ENV
echo "::notice::Version Increment: minor"
else
echo "increment=patch" >> $GITHUB_ENV
echo "::notice::Version Increment: patch"
fi

- name: Increment Version
if: env.run_versioning == 'true'
run: |
IFS='.' read -r major minor patch <<< "$VERSION"

case "$increment" in
major) major=$((major + 1)); minor=0; patch=0 ;;
minor) minor=$((minor + 1)); patch=0 ;;
patch) patch=$((patch + 1)) ;;
esac

NEW_VERSION="$major.$minor.$patch"
echo "::notice::New Version: $NEW_VERSION"

sed -i -E "s/(project\(atta VERSION) [0-9]+\.[0-9]+\.[0-9]+/\1 $NEW_VERSION/" CMakeLists.txt
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV

- name: Commit Updated Version (If Changed)
if: env.run_versioning == 'true'
run: |
git add CMakeLists.txt
if git diff --staged --quiet; then
echo "No changes to commit."
else
git commit -m "Chore: Bump version to $NEW_VERSION"
git push origin ${{ github.head_ref }}
fi

- name: Delete Old Tag (If Exists)
if: env.run_versioning == 'true'
run: |
if git rev-parse "v$NEW_VERSION" >/dev/null 2>&1; then
git push --delete origin "v$NEW_VERSION"
git tag -d "v$NEW_VERSION"
echo "Deleted existing tag v$NEW_VERSION."
else
echo "No existing tag v$NEW_VERSION found."
fi

- name: Create and Push New Git Tag
if: env.run_versioning == 'true'
run: |
# Fetch the PR title from GitHub event payload
PR_TITLE="${{ github.event.pull_request.title }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
echo "::notice::PR Title: $PR_TITLE"
echo "::notice::PR Number: $PR_NUMBER"

# Create an annotated tag with the PR title as the description
git tag -a "v$NEW_VERSION" -m "PR #$PR_NUMBER - $PR_TITLE"

# Push the tag to the remote repository
git push origin "v$NEW_VERSION"
18 changes: 10 additions & 8 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Web
on: [push, pull_request, release]
name: 🕸️ Web

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
Expand All @@ -9,17 +15,13 @@ jobs:
fail-fast: false
matrix:
config:
- {
name: "Web Latest",
os: ubuntu-latest,
build_type: "Release"
}
- { name: "Web Latest", os: ubuntu-latest, build_type: "Release" }

steps:
- uses: mymindstorm/setup-emsdk@v13

- name: Checkout atta
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Configure
run: |
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Windows
on: [push, pull_request, release]
name: 🪟 Windows

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
Expand All @@ -9,15 +15,11 @@ jobs:
fail-fast: false
matrix:
config:
- {
name: "Windows Latest",
os: windows-latest,
build_type: "Release"
}
- { name: "Windows Latest", os: windows-latest, build_type: "Release" }

steps:
- name: Checkout atta
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.14)

project(atta VERSION 0.3.2 LANGUAGES CXX C)
project(atta VERSION 0.3.3 LANGUAGES CXX C)

OPTION(ATTA_BUILD_TESTS
"Set to ON to build also the test executables"
Expand Down
Loading