Skip to content

Commit f494150

Browse files
authored
Update appVeyor.yml
1 parent 5787a55 commit f494150

File tree

1 file changed

+88
-91
lines changed

1 file changed

+88
-91
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)"

0 commit comments

Comments
 (0)