Skip to content

Commit

Permalink
Update appVeyor.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
justdesewa authored Dec 18, 2024
1 parent 5787a55 commit f494150
Showing 1 changed file with 88 additions and 91 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)"

0 comments on commit f494150

Please sign in to comment.