-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (88 loc) · 3.22 KB
/
cmake-single-platform.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: CMake Build and Release
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
release:
types: [created]
env:
BUILD_TYPE: Release
ARTIFACT_DIR: release-artifacts
jobs:
build-and-release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
include:
- os: ubuntu-latest
arch: x86_64
install_prefix: /usr/local
compiler: clang
- os: macos-latest
arch: arm64
install_prefix: /opt/homebrew
compiler: clang
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
sudo apt-get update
sudo apt-get install -y clang build-essential
fi
- name: Configure CMake
run: |
mkdir build-${{ matrix.arch }} && cd build-${{ matrix.arch }}
cmake .. \
-DCMAKE_INSTALL_PREFIX=${{ matrix.install_prefix }} \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DCMAKE_C_COMPILER=${{ matrix.compiler }} \
-DCMAKE_C_FLAGS="-march=native -O3" \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DCMAKE_UNITY_BUILD=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
- name: Build
run: |
cd build-${{ matrix.arch }}
cmake --build . --config ${{env.BUILD_TYPE}} --parallel $(nproc 2>/dev/null || sysctl -n hw.ncpu)
# Rest of the workflow remains the same...
- name: Collect Artifacts
run: |
mkdir -p ${{env.ARTIFACT_DIR}}/${{ matrix.os }}-${{ matrix.arch }}
cd build-${{ matrix.arch }}
if [ -f "pHash_demo" ] || [ -f "phash_demo" ] || [ -f "libpHash.a" ] || [ -f "libphash.a" ]; then
[ -f "pHash_demo" ] && cp pHash_demo ../${{env.ARTIFACT_DIR}}/${{ matrix.os }}-${{ matrix.arch }}/
[ -f "phash_demo" ] && cp phash_demo ../${{env.ARTIFACT_DIR}}/${{ matrix.os }}-${{ matrix.arch }}/
[ -f "libpHash.a" ] && cp libpHash.a ../${{env.ARTIFACT_DIR}}/${{ matrix.os }}-${{ matrix.arch }}/
[ -f "libphash.a" ] && cp libphash.a ../${{env.ARTIFACT_DIR}}/${{ matrix.os }}-${{ matrix.arch }}/
else
echo "No artifacts found in $(pwd)"
exit 1
fi
- name: Create Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: ${{env.ARTIFACT_DIR}}/**/*
tag_name: ${{ github.ref_name }}
name: "pHASH ${{ github.ref_name }}"
body: |
### Multi-architecture Build
**Version:** ${{ github.ref_name }}
**Build Date:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')
**Supported Architectures:**
- x86_64 (Linux)
- arm64 (macOS)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Build Artifacts
if: always() && github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: phash-build-${{ matrix.os }}-${{ matrix.arch }}
path: ${{env.ARTIFACT_DIR}}/${{ matrix.os }}-${{ matrix.arch }}
retention-days: 1