Skip to content

Commit d40392a

Browse files
Merge pull request #16 from Autodesk/Rasheedat/cicd
Rasheedat/cicd
2 parents 5787a55 + f6a8655 commit d40392a

File tree

2 files changed

+137
-108
lines changed

2 files changed

+137
-108
lines changed

.github/workflows/appVeyor.yml

Lines changed: 88 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -2,117 +2,114 @@ name: Build and Deploy SyDEVS
22

33
on:
44
push:
5+
tags:
6+
- 'v*'
57
pull_request:
68
branches:
7-
- Rasheedat/ci
8-
9+
- main
10+
workflow_dispatch:
11+
912
jobs:
1013
build:
11-
runs-on: ${{ matrix.os }}
12-
1314
strategy:
1415
matrix:
15-
os: [ macos-latest]
16-
vs_version: ['2019', '2022']
17-
configuration: ['Release', 'Debug']
18-
19-
env:
20-
MY_VS_VERSION: ${{ matrix.vs_version }} # Visual Studio version for matrix
16+
os: [windows-latest, ubuntu-latest]
17+
runs-on: ${{ matrix.os }}
2118

2219
steps:
20+
# Step 1: Checkout repository
2321
- name: Checkout Repository
24-
uses: actions/checkout@v3 # Latest version
25-
26-
# Install dependencies on Linux (Ubuntu)
27-
- name: Install CMake (Ubuntu/Linux)
28-
if: runner.os == 'Linux'
29-
run: |
30-
sudo apt-get update
31-
sudo apt-get install -y cmake # Install CMake using apt-get
32-
cmake --version # Verify CMake installation
22+
uses: actions/checkout@v3
3323

34-
# Install Visual Studio Build Tools for Windows
35-
- name: Install Visual Studio Build Tools (Windows)
24+
# Step 2: Setup build tools based on OS
25+
- name: Setup Build Tools on Windows
3626
if: runner.os == 'Windows'
37-
run: |
38-
# Install Visual Studio 2019 Build Tools if not installed
39-
if (-Not (Test-Path "$env:ProgramFiles(x86)\Microsoft Visual Studio\2019\BuildTools")) {
40-
Write-Host "Installing Visual Studio Build Tools 2019"
41-
choco install visualstudio2019buildtools --yes
42-
}
43-
44-
# Install Visual Studio 2022 Build Tools (latest version)
45-
if (-Not (Test-Path "$env:ProgramFiles(x86)\Microsoft Visual Studio\2022\BuildTools")) {
46-
Write-Host "Installing Visual Studio Build Tools 2022"
47-
choco install visualstudio2022buildtools --yes
48-
}
49-
50-
# Verify Visual Studio Installation (Windows)
51-
- name: Verify Visual Studio Installation (Windows)
52-
if: runner.os == 'Windows'
53-
run: |
54-
# Check if Visual Studio is installed using vswhere
55-
vswhere -products * -requires Microsoft.Component.MSBuild -property installationPath
56-
57-
# Set up Visual Studio (Windows only)
58-
- name: Set up Visual Studio (Windows only)
59-
if: runner.os == 'Windows'
60-
uses: microsoft/setup-msbuild@v1 # Latest MSBuild setup for Windows
61-
62-
# Install Xcode Command Line Tools for macOS
63-
- name: Install Xcode Command Line Tools (macOS)
64-
if: runner.os == 'macos'
65-
run: |
66-
xcode-select --install || true # Install Command Line Tools
67-
68-
# Verify CMake and Xcode for macOS
69-
- name: Verify CMake and Xcode (macOS)
70-
if: runner.os == 'macos'
71-
run: |
72-
echo "Verifying Xcode installation"
73-
xcode-select -p # Verify Xcode installation
74-
cmake --version # Verify CMake installation
75-
xcodebuild -version # Verify Xcode version
27+
run: choco install visualstudio2022buildtools --yes
28+
shell: powershell
29+
- name: Install Dependencies (Ubuntu)
30+
if: runner.os == 'Linux'
31+
run: sudo apt-get update && sudo apt-get install -y build-essential cmake
7632

77-
# Create build directory
78-
- name: Create build directory
79-
run: mkdir build
33+
# Step 3: Configure Build Environment
34+
- name: Configure Build
35+
run: cmake -S . -B build
36+
shell: bash
8037

81-
# Update CMakeLists.txt to remove unused variable warning
82-
- name: Update CMakeLists to remove unused variable warning
83-
run: |
84-
echo "Updating CMakeLists.txt to disable unused variable warning"
85-
sed -i '' '/set(CMAKE_CXX_FLAGS/ s/$/ -Wno-unused-but-set-variable/' CMakeLists.txt
86-
cat CMakeLists.txt # Optional: to verify the changes
38+
# Step 4: Build Project
39+
- name: Build Project
40+
run: cmake --build build --config Release --parallel
41+
shell: bash
8742

88-
# Archive Artifacts
89-
- name: Archive Artifacts
43+
# Step 5: Prepare Artifacts
44+
- name: Prepare Artifacts
9045
run: |
91-
mkdir -p artifacts/lib artifacts/include/sydevs/core artifacts/include/sydevs/systems artifacts/include/sydevs/time
92-
if [ -d src/sydevs/core ]; then
46+
if [[ "$RUNNER_OS" == "Linux" ]]; then
47+
# Linux-specific commands (Bash)
48+
mkdir -p artifacts/lib artifacts/include/sydevs/core artifacts/include/sydevs/systems artifacts/include/sydevs/time
9349
cp src/sydevs/core/*.h artifacts/include/sydevs/core || true
94-
fi
95-
if [ -d src/sydevs/systems ]; then
9650
cp src/sydevs/systems/*.h artifacts/include/sydevs/systems || true
97-
fi
98-
if [ -d src/sydevs/time ]; then
9951
cp src/sydevs/time/*.h artifacts/include/sydevs/time || true
52+
cp build/lib*.so artifacts/lib || cp build/Release/SyDEVS.lib artifacts/lib || true
53+
zip -r artifacts_linux.zip artifacts
54+
elif [[ "$RUNNER_OS" == "Windows" ]]; then
55+
# Windows-specific commands (PowerShell)
56+
pwsh -Command "
57+
New-Item -ItemType Directory -Force -Path artifacts\\lib, artifacts\\include\\sydevs\\core, artifacts\\include\\sydevs\\systems, artifacts\\include\\sydevs\\time;
58+
Copy-Item -Path src\\sydevs\\core\\*.h -Destination artifacts\\include\\sydevs\\core -Force;
59+
Copy-Item -Path src\\sydevs\\systems\\*.h -Destination artifacts\\include\\sydevs\\systems -Force;
60+
Copy-Item -Path src\\sydevs\\time\\*.h -Destination artifacts\\include\\sydevs\\time -Force;
61+
Copy-Item -Path build\\lib*.so -Destination artifacts\\lib -Force;
62+
Copy-Item -Path build\\Release\\SyDEVS.lib -Destination artifacts\\lib -Force;
63+
Compress-Archive -Path artifacts\\* -DestinationPath artifacts_windows.zip
64+
"
10065
fi
101-
zip -r artifacts.zip artifacts
66+
shell: bash
10267

103-
# Upload Artifacts
68+
# Step 6: Upload Artifacts for Debugging
10469
- name: Upload Artifacts
105-
uses: actions/upload-artifact@v3 # Latest version for uploading artifacts
70+
uses: actions/upload-artifact@v3
10671
with:
107-
name: artifact # The name of the artifact
108-
path: artifacts.zip # Path to the archived artifacts.zip
72+
name: build-artifacts
73+
path: |
74+
artifacts_linux.zip
75+
artifacts_windows.zip
10976
110-
# Deploy to Release
111-
- name: Deploy to Release
112-
if: startsWith(github.ref, 'refs/tags/')
113-
run: |
114-
TAG_NAME=$(echo $GITHUB_REF | sed 's/refs\/tags\///')
115-
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
116-
-X POST \
117-
-d '{"tag_name": "$TAG_NAME", "target_commitish": "main", "name": "Release $TAG_NAME", "body": "Release for version $TAG_NAME", "draft": false, "prerelease": false}' \
118-
https://api.github.com/repos/${{ github.repository }}/releases
77+
deploy:
78+
runs-on: ubuntu-latest
79+
needs: build
80+
if: startsWith(github.ref, 'refs/tags/')
81+
82+
steps:
83+
# Step 1: Checkout Repository
84+
- name: Checkout Repository
85+
uses: actions/checkout@v3
86+
87+
# Step 2: Download Build Artifacts
88+
- name: Download Build Artifacts
89+
uses: actions/download-artifact@v3
90+
with:
91+
name: build-artifacts
92+
path: ./
93+
94+
# Step 3: Create GitHub Release
95+
- name: Create GitHub Release
96+
uses: svenstaro/upload-release-action@v2
97+
with:
98+
repo_token: ${{ secrets.GITHUB_TOKEN }}
99+
# Upload the artifact for Ubuntu
100+
file: artifacts_linux.zip
101+
asset_name: SyDEVS_Release_${{ github.ref_name }}_ubuntu.zip
102+
tag: ${{ github.ref_name }}
103+
overwrite: false
104+
body: "Release for SyDEVS version ${{ github.ref_name }} (Ubuntu build)"
105+
106+
- name: Create GitHub Release for Windows
107+
uses: svenstaro/upload-release-action@v2
108+
with:
109+
repo_token: ${{ secrets.GITHUB_TOKEN }}
110+
# Upload the artifact for Windows
111+
file: artifacts_windows.zip
112+
asset_name: SyDEVS_Release_${{ github.ref_name }}_windows.zip
113+
tag: ${{ github.ref_name }}
114+
overwrite: false
115+
body: "Release for SyDEVS version ${{ github.ref_name }} (Windows build)"

.github/workflows/travis.yml

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ name: Build and Deploy
22

33
on:
44
push:
5+
tags:
6+
- 'v*' # Ensure only tags trigger this workflow
57
pull_request:
68
branches:
79
- main
810
workflow_dispatch:
11+
912
jobs:
1013
build:
1114
runs-on: ubuntu-latest
1215

1316
strategy:
1417
matrix:
15-
cc: [gcc-12, clang-14] # Use supported versions available in Ubuntu repositories.
18+
cc: [gcc-12, clang-14] # Supported compilers in Ubuntu repositories.
1619

1720
steps:
1821
- name: Checkout repository
@@ -22,7 +25,6 @@ jobs:
2225
run: |
2326
sudo apt-get update
2427
sudo apt-get install -y software-properties-common
25-
# Install compilers based on the matrix
2628
if [[ "${{ matrix.cc }}" == "gcc-12" ]]; then
2729
sudo apt-get install -y g++-12
2830
export CC=gcc-12
@@ -32,8 +34,7 @@ jobs:
3234
export CC=clang-14
3335
export CXX=clang++-14
3436
fi
35-
# Install CMake
36-
sudo apt-get install -y cmake
37+
sudo apt-get install -y cmake doxygen graphviz
3738
3839
- name: Configure with CMake
3940
run: |
@@ -46,16 +47,47 @@ jobs:
4647
cd build
4748
make
4849
49-
- name: Archive artifacts
50-
run: |
51-
mkdir -p artifacts/lib artifacts/include/sydevs/core artifacts/include/sydevs/systems artifacts/include/sydevs/time
52-
if [[ -d src/sydevs/core ]]; then
53-
cp src/sydevs/core/*.h artifacts/include/sydevs/core || true
54-
fi
55-
if [[ -d src/sydevs/systems ]]; then
56-
cp src/sydevs/systems/*.h artifacts/include/sydevs/systems || true
57-
fi
58-
if [[ -d src/sydevs/time ]]; then
59-
cp src/sydevs/time/*.h artifacts/include/sydevs/time || true
60-
fi
61-
zip -r artifacts.zip artifacts
50+
- name: Generate Documentation
51+
if: github.event_name == 'push' || github.ref == 'refs/tags/*'
52+
run: |
53+
if [ -f doxygen.config ]; then
54+
(cat doxygen.config; echo "PROJECT_NUMBER=${{ github.ref_name }}") | doxygen -
55+
fi
56+
57+
- name: Archive Artifacts
58+
run: |
59+
mkdir -p artifacts/lib artifacts/include/sydevs/core artifacts/include/sydevs/systems artifacts/include/sydevs/time
60+
if [[ -d src/sydevs/core ]]; then
61+
cp src/sydevs/core/*.h artifacts/include/sydevs/core || true
62+
fi
63+
if [[ -d src/sydevs/systems ]]; then
64+
cp src/sydevs/systems/*.h artifacts/include/sydevs/systems || true
65+
fi
66+
if [[ -d src/sydevs/time ]]; then
67+
cp src/sydevs/time/*.h artifacts/include/sydevs/time || true
68+
fi
69+
if [[ -d build ]]; then
70+
cp build/libSyDEVS* artifacts/lib || true
71+
fi
72+
zip -r "SyDEVS-${{ github.ref_name }}-${{ matrix.cc }}.zip" artifacts
73+
74+
- name: Package Documentation
75+
if: github.event_name == 'push' || github.ref == 'refs/tags/*'
76+
run: |
77+
if [ -d doc/html ]; then
78+
zip -r "SyDEVS-${{ github.ref_name }}_api-reference.zip" doc/html
79+
fi
80+
81+
- name: Create GitHub Release (Compiler-specific)
82+
uses: svenstaro/upload-release-action@v2
83+
with:
84+
repo_token: ${{ secrets.GITHUB_TOKEN }}
85+
file: "SyDEVS-${{ github.ref_name }}-${{ matrix.cc }}.zip"
86+
asset_name: "SyDEVS-${{ github.ref_name }}-${{ matrix.cc }}.zip"
87+
tag: ${{ github.ref_name }} # Use cleaned tag name
88+
overwrite: false
89+
body: "Release for SyDEVS version ${{ github.ref_name }} using compiler ${{ matrix.cc }}"
90+
91+
- name: Deploy Documentation
92+
if: github.event_name == 'push' || github.ref == 'refs/tags/*'
93+
run: bash scripts/deploy_docs.sh

0 commit comments

Comments
 (0)