-
-
Notifications
You must be signed in to change notification settings - Fork 9
132 lines (112 loc) · 5.09 KB
/
macos.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: macOS
on:
workflow_dispatch:
push:
paths:
- 'src/**'
- '.github/workflows/macos.yml'
release:
types: [published]
permissions:
contents: read
jobs:
build:
permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: macos-latest
env:
PROJECT_NAME: ${{ github.event.repository.name }}
PROJECT_BUILD_PATH: ${{ github.event.repository.name }}/src
PROJECT_RELEASE_PATH: ${{ github.event.repository.name }}_dev_macos
PROJECT_CUSTOM_FLAGS: ""
PROJECT_RESOURCES_PATH: src/template
steps:
- name: Checkout this repo
uses: actions/checkout@master
with:
path: ${{ env.PROJECT_NAME }}
- name: Checkout raylib repo
uses: actions/checkout@v4
with:
repository: raysan5/raylib
path: raylib
- name: Setup Release Paths
run: |
echo "PROJECT_RELEASE_PATH=${{ env.PROJECT_NAME }}_v${{ github.event.release.tag_name }}_macos" >> $GITHUB_ENV
shell: bash
if: github.event_name == 'release' && github.event.action == 'published'
- name: Setup Environment
run: |
mkdir ${{ env.PROJECT_RELEASE_PATH }}
cd ${{ env.PROJECT_RELEASE_PATH }}
mkdir ${{ env.PROJECT_NAME }}.app
cd ${{ env.PROJECT_NAME }}.app
mkdir Contents
cd Contents
mkdir MacOS
mkdir Resources
cd ../../..
ls
shell: bash
# Generating static library, note that i386 architecture is deprecated
# Defining GL_SILENCE_DEPRECATION because OpenGL is deprecated on macOS
- name: Build raylib Library
run: |
cd raylib/src
clang --version
# Extract version numbers from Makefile
brew install grep
RAYLIB_API_VERSION=`ggrep -Po 'RAYLIB_API_VERSION\s*=\s\K(.*)' Makefile`
RAYLIB_VERSION=`ggrep -Po 'RAYLIB_VERSION\s*=\s\K(.*)' Makefile`
# Build raylib x86_64 static
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC CUSTOM_CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION"
mv -v -f libraylib.a libraylib_x86_64.a
make clean
# Build raylib arm64 static
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC CUSTOM_CFLAGS="-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION" -B
mv -v -f libraylib.a libraylib_arm64.a
make clean
# Join x86_64 and arm64 static
lipo -create -output libraylib.a libraylib_x86_64.a libraylib_arm64.a
lipo libraylib.a -detailed_info
cd ../..
- name: Build Product
run: |
cd ${{ env.PROJECT_NAME }}/src
# Build project x86_64 binary
# TODO: Link with x86_64 raylib library: libraylib_x86_64.a
make PLATFORM=PLATFORM_DESKTOP BUILD_MODE=RELEASE PROJECT_CUSTOM_FLAGS=${{ env.PROJECT_CUSTOM_FLAGS }} PROJECT_BUILD_PATH=. RAYLIB_SRC_PATH=../../raylib/src PROJECT_CUSTOM_FLAGS="-target x86_64-apple-macos10.12"
mv -v -f ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_x86_64
make clean
# Build project arm64 binary
# TODO: Link with arm64 raylib library: libraylib_arm.a
make PLATFORM=PLATFORM_DESKTOP BUILD_MODE=RELEASE PROJECT_CUSTOM_FLAGS=${{ env.PROJECT_CUSTOM_FLAGS }} PROJECT_BUILD_PATH=. RAYLIB_SRC_PATH=../../raylib/src PROJECT_CUSTOM_FLAGS="-target arm64-apple-macos11"
mv -v -f ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_arm64
make clean
# Join x86_64 and arm64 binaries
lipo -create -output ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_x86_64 ${{ env.PROJECT_NAME }}_arm64
lipo ${{ env.PROJECT_NAME }} -detailed_info
cd ..
- name: Generate Artifacts
run: |
ls ${{ env.PROJECT_BUILD_PATH }}
cp ${{ env.PROJECT_BUILD_PATH }}/${{ env.PROJECT_NAME }} ${{ env.PROJECT_RELEASE_PATH }}/${{ env.PROJECT_NAME }}.app/Contents/MacOS
cp ${{ env.PROJECT_NAME }}/src/${{ env.PROJECT_NAME }}.icns ${{ env.PROJECT_RELEASE_PATH }}/${{ env.PROJECT_NAME }}.app/Contents/Resources
cp ${{ env.PROJECT_NAME }}/src/Info.plist ${{ env.PROJECT_RELEASE_PATH }}/${{ env.PROJECT_NAME }}.app/Contents
cp -r ${{ env.PROJECT_NAME }}/${{ env.PROJECT_RESOURCES_PATH }} ${{ env.PROJECT_RELEASE_PATH }}/${{ env.PROJECT_NAME }}.app/Contents
cp ${{ env.PROJECT_NAME }}/README.md ${{ env.PROJECT_RELEASE_PATH }}
cp ${{ env.PROJECT_NAME }}/LICENSE ${{ env.PROJECT_RELEASE_PATH }}
ls ${{ env.PROJECT_RELEASE_PATH }}
7z a ./${{ env.PROJECT_RELEASE_PATH }}.zip ./${{ env.PROJECT_RELEASE_PATH }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_RELEASE_PATH }}.zip
path: ./${{ env.PROJECT_RELEASE_PATH }}.zip
- name: Upload Artifact to Release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.PROJECT_RELEASE_PATH }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'release' && github.event.action == 'published'