Skip to content

Commit

Permalink
Merge pull request #16 from Autodesk/Rasheedat/cicd
Browse files Browse the repository at this point in the history
Rasheedat/cicd
  • Loading branch information
rhysgoldstein authored Dec 19, 2024
2 parents 5787a55 + f6a8655 commit d40392a
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 108 deletions.
179 changes: 88 additions & 91 deletions .github/workflows/appVeyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,117 +2,114 @@ name: Build and Deploy SyDEVS

on:
push:
tags:
- 'v*'
pull_request:
branches:
- Rasheedat/ci

- main
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ macos-latest]
vs_version: ['2019', '2022']
configuration: ['Release', 'Debug']

env:
MY_VS_VERSION: ${{ matrix.vs_version }} # Visual Studio version for matrix
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}

steps:
# Step 1: Checkout repository
- name: Checkout Repository
uses: actions/checkout@v3 # Latest version

# Install dependencies on Linux (Ubuntu)
- name: Install CMake (Ubuntu/Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y cmake # Install CMake using apt-get
cmake --version # Verify CMake installation
uses: actions/checkout@v3

# Install Visual Studio Build Tools for Windows
- name: Install Visual Studio Build Tools (Windows)
# Step 2: Setup build tools based on OS
- name: Setup Build Tools on Windows
if: runner.os == 'Windows'
run: |
# Install Visual Studio 2019 Build Tools if not installed
if (-Not (Test-Path "$env:ProgramFiles(x86)\Microsoft Visual Studio\2019\BuildTools")) {
Write-Host "Installing Visual Studio Build Tools 2019"
choco install visualstudio2019buildtools --yes
}
# Install Visual Studio 2022 Build Tools (latest version)
if (-Not (Test-Path "$env:ProgramFiles(x86)\Microsoft Visual Studio\2022\BuildTools")) {
Write-Host "Installing Visual Studio Build Tools 2022"
choco install visualstudio2022buildtools --yes
}
# Verify Visual Studio Installation (Windows)
- name: Verify Visual Studio Installation (Windows)
if: runner.os == 'Windows'
run: |
# Check if Visual Studio is installed using vswhere
vswhere -products * -requires Microsoft.Component.MSBuild -property installationPath
# Set up Visual Studio (Windows only)
- name: Set up Visual Studio (Windows only)
if: runner.os == 'Windows'
uses: microsoft/setup-msbuild@v1 # Latest MSBuild setup for Windows

# Install Xcode Command Line Tools for macOS
- name: Install Xcode Command Line Tools (macOS)
if: runner.os == 'macos'
run: |
xcode-select --install || true # Install Command Line Tools
# Verify CMake and Xcode for macOS
- name: Verify CMake and Xcode (macOS)
if: runner.os == 'macos'
run: |
echo "Verifying Xcode installation"
xcode-select -p # Verify Xcode installation
cmake --version # Verify CMake installation
xcodebuild -version # Verify Xcode version
run: choco install visualstudio2022buildtools --yes
shell: powershell
- name: Install Dependencies (Ubuntu)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y build-essential cmake

# Create build directory
- name: Create build directory
run: mkdir build
# Step 3: Configure Build Environment
- name: Configure Build
run: cmake -S . -B build
shell: bash

# Update CMakeLists.txt to remove unused variable warning
- name: Update CMakeLists to remove unused variable warning
run: |
echo "Updating CMakeLists.txt to disable unused variable warning"
sed -i '' '/set(CMAKE_CXX_FLAGS/ s/$/ -Wno-unused-but-set-variable/' CMakeLists.txt
cat CMakeLists.txt # Optional: to verify the changes
# Step 4: Build Project
- name: Build Project
run: cmake --build build --config Release --parallel
shell: bash

# Archive Artifacts
- name: Archive Artifacts
# Step 5: Prepare Artifacts
- name: Prepare Artifacts
run: |
mkdir -p artifacts/lib artifacts/include/sydevs/core artifacts/include/sydevs/systems artifacts/include/sydevs/time
if [ -d src/sydevs/core ]; then
if [[ "$RUNNER_OS" == "Linux" ]]; then
# Linux-specific commands (Bash)
mkdir -p artifacts/lib artifacts/include/sydevs/core artifacts/include/sydevs/systems artifacts/include/sydevs/time
cp src/sydevs/core/*.h artifacts/include/sydevs/core || true
fi
if [ -d src/sydevs/systems ]; then
cp src/sydevs/systems/*.h artifacts/include/sydevs/systems || true
fi
if [ -d src/sydevs/time ]; then
cp src/sydevs/time/*.h artifacts/include/sydevs/time || true
cp build/lib*.so artifacts/lib || cp build/Release/SyDEVS.lib artifacts/lib || true
zip -r artifacts_linux.zip artifacts
elif [[ "$RUNNER_OS" == "Windows" ]]; then
# Windows-specific commands (PowerShell)
pwsh -Command "
New-Item -ItemType Directory -Force -Path artifacts\\lib, artifacts\\include\\sydevs\\core, artifacts\\include\\sydevs\\systems, artifacts\\include\\sydevs\\time;
Copy-Item -Path src\\sydevs\\core\\*.h -Destination artifacts\\include\\sydevs\\core -Force;
Copy-Item -Path src\\sydevs\\systems\\*.h -Destination artifacts\\include\\sydevs\\systems -Force;
Copy-Item -Path src\\sydevs\\time\\*.h -Destination artifacts\\include\\sydevs\\time -Force;
Copy-Item -Path build\\lib*.so -Destination artifacts\\lib -Force;
Copy-Item -Path build\\Release\\SyDEVS.lib -Destination artifacts\\lib -Force;
Compress-Archive -Path artifacts\\* -DestinationPath artifacts_windows.zip
"
fi
zip -r artifacts.zip artifacts
shell: bash

# Upload Artifacts
# Step 6: Upload Artifacts for Debugging
- name: Upload Artifacts
uses: actions/upload-artifact@v3 # Latest version for uploading artifacts
uses: actions/upload-artifact@v3
with:
name: artifact # The name of the artifact
path: artifacts.zip # Path to the archived artifacts.zip
name: build-artifacts
path: |
artifacts_linux.zip
artifacts_windows.zip
# Deploy to Release
- name: Deploy to Release
if: startsWith(github.ref, 'refs/tags/')
run: |
TAG_NAME=$(echo $GITHUB_REF | sed 's/refs\/tags\///')
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-X POST \
-d '{"tag_name": "$TAG_NAME", "target_commitish": "main", "name": "Release $TAG_NAME", "body": "Release for version $TAG_NAME", "draft": false, "prerelease": false}' \
https://api.github.com/repos/${{ github.repository }}/releases
deploy:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')

steps:
# Step 1: Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3

# Step 2: Download Build Artifacts
- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
path: ./

# Step 3: Create GitHub Release
- name: Create GitHub Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
# Upload the artifact for Ubuntu
file: artifacts_linux.zip
asset_name: SyDEVS_Release_${{ github.ref_name }}_ubuntu.zip
tag: ${{ github.ref_name }}
overwrite: false
body: "Release for SyDEVS version ${{ github.ref_name }} (Ubuntu build)"

- name: Create GitHub Release for Windows
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
# Upload the artifact for Windows
file: artifacts_windows.zip
asset_name: SyDEVS_Release_${{ github.ref_name }}_windows.zip
tag: ${{ github.ref_name }}
overwrite: false
body: "Release for SyDEVS version ${{ github.ref_name }} (Windows build)"
66 changes: 49 additions & 17 deletions .github/workflows/travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ name: Build and Deploy

on:
push:
tags:
- 'v*' # Ensure only tags trigger this workflow
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
cc: [gcc-12, clang-14] # Use supported versions available in Ubuntu repositories.
cc: [gcc-12, clang-14] # Supported compilers in Ubuntu repositories.

steps:
- name: Checkout repository
Expand All @@ -22,7 +25,6 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common
# Install compilers based on the matrix
if [[ "${{ matrix.cc }}" == "gcc-12" ]]; then
sudo apt-get install -y g++-12
export CC=gcc-12
Expand All @@ -32,8 +34,7 @@ jobs:
export CC=clang-14
export CXX=clang++-14
fi
# Install CMake
sudo apt-get install -y cmake
sudo apt-get install -y cmake doxygen graphviz
- name: Configure with CMake
run: |
Expand All @@ -46,16 +47,47 @@ jobs:
cd build
make
- name: Archive artifacts
run: |
mkdir -p artifacts/lib artifacts/include/sydevs/core artifacts/include/sydevs/systems artifacts/include/sydevs/time
if [[ -d src/sydevs/core ]]; then
cp src/sydevs/core/*.h artifacts/include/sydevs/core || true
fi
if [[ -d src/sydevs/systems ]]; then
cp src/sydevs/systems/*.h artifacts/include/sydevs/systems || true
fi
if [[ -d src/sydevs/time ]]; then
cp src/sydevs/time/*.h artifacts/include/sydevs/time || true
fi
zip -r artifacts.zip artifacts
- name: Generate Documentation
if: github.event_name == 'push' || github.ref == 'refs/tags/*'
run: |
if [ -f doxygen.config ]; then
(cat doxygen.config; echo "PROJECT_NUMBER=${{ github.ref_name }}") | doxygen -
fi
- name: Archive Artifacts
run: |
mkdir -p artifacts/lib artifacts/include/sydevs/core artifacts/include/sydevs/systems artifacts/include/sydevs/time
if [[ -d src/sydevs/core ]]; then
cp src/sydevs/core/*.h artifacts/include/sydevs/core || true
fi
if [[ -d src/sydevs/systems ]]; then
cp src/sydevs/systems/*.h artifacts/include/sydevs/systems || true
fi
if [[ -d src/sydevs/time ]]; then
cp src/sydevs/time/*.h artifacts/include/sydevs/time || true
fi
if [[ -d build ]]; then
cp build/libSyDEVS* artifacts/lib || true
fi
zip -r "SyDEVS-${{ github.ref_name }}-${{ matrix.cc }}.zip" artifacts
- name: Package Documentation
if: github.event_name == 'push' || github.ref == 'refs/tags/*'
run: |
if [ -d doc/html ]; then
zip -r "SyDEVS-${{ github.ref_name }}_api-reference.zip" doc/html
fi
- name: Create GitHub Release (Compiler-specific)
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: "SyDEVS-${{ github.ref_name }}-${{ matrix.cc }}.zip"
asset_name: "SyDEVS-${{ github.ref_name }}-${{ matrix.cc }}.zip"
tag: ${{ github.ref_name }} # Use cleaned tag name
overwrite: false
body: "Release for SyDEVS version ${{ github.ref_name }} using compiler ${{ matrix.cc }}"

- name: Deploy Documentation
if: github.event_name == 'push' || github.ref == 'refs/tags/*'
run: bash scripts/deploy_docs.sh

0 comments on commit d40392a

Please sign in to comment.