|
| 1 | +name: macOS |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + paths: |
| 7 | + - '**' |
| 8 | + - 'examples/**' |
| 9 | + - '.github/workflows/macos.yml' |
| 10 | + pull_request: |
| 11 | + paths: |
| 12 | + - '**' |
| 13 | + - 'examples/**' |
| 14 | + - '.github/workflows/macos.yml' |
| 15 | + release: |
| 16 | + types: [published] |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + permissions: |
| 24 | + contents: write # for actions/upload-release-asset to upload release asset |
| 25 | + runs-on: macos-latest |
| 26 | + |
| 27 | + env: |
| 28 | + RELEASE_NAME: RGFW-Python-dev_macos |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@master |
| 33 | + |
| 34 | + - name: Setup Release Version |
| 35 | + run: | |
| 36 | + echo "RELEASE_NAME=RGFW-Python-${{ github.event.release.tag_name }}_macos" >> $GITHUB_ENV |
| 37 | + shell: bash |
| 38 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 39 | + |
| 40 | + - name: Setup Environment |
| 41 | + run: | |
| 42 | + mkdir build |
| 43 | + cd build |
| 44 | + mkdir ${{ env.RELEASE_NAME }} |
| 45 | + cd ${{ env.RELEASE_NAME }} |
| 46 | + mkdir include |
| 47 | + mkdir lib |
| 48 | + cd ../.. |
| 49 | + |
| 50 | + # Generating static + shared library, note that i386 architecture is deprecated |
| 51 | + # Defining GL_SILENCE_DEPRECATION because OpenGL is deprecated on macOS |
| 52 | + - name: Build Library |
| 53 | + run: | |
| 54 | + clang --version |
| 55 | + |
| 56 | + # Extract version numbers from Makefile |
| 57 | + brew install grep |
| 58 | + |
| 59 | + # Build RGFW x86_64 dynamic |
| 60 | + make libRGFW.dylib CUSTOM_CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION" |
| 61 | + mv libRGFW.dylib /tmp/libRGFW_x86_64.dylib |
| 62 | + rm -f RGFW.o |
| 63 | + |
| 64 | + # Build RGFW arm64 dynamic |
| 65 | + make libRGFW.dylib CUSTOM_CFLAGS="-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION" |
| 66 | + mv libRGFW.dylib /tmp/libRGFW_arm64.dylib |
| 67 | + |
| 68 | + # Join x86_64 and arm64 dynamic |
| 69 | + rm -f ./build/lib/* |
| 70 | + lipo -create -output libRGFW.dylib /tmp/libRGFW_x86_64.dylib /tmp/libRGFW_arm64.dylib |
| 71 | + ln -sv libRGFW.dylib build/${{ env.RELEASE_NAME }}/lib/libRGFW.dylib |
| 72 | + |
| 73 | + - name: Generate Artifacts |
| 74 | + run: | |
| 75 | + cp -v ./RGFW.h ./build/${{ env.RELEASE_NAME }}/include |
| 76 | + cp -v ./RGFW.py ./build/${{ env.RELEASE_NAME }}/lib |
| 77 | + cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md |
| 78 | + cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE |
| 79 | + cd build |
| 80 | + tar -czvf ${{ env.RELEASE_NAME }}.tar.gz ${{ env.RELEASE_NAME }} |
| 81 | + |
| 82 | + - name: Upload Artifacts |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: ${{ env.RELEASE_NAME }}.tar.gz |
| 86 | + path: ./build/${{ env.RELEASE_NAME }}.tar.gz |
| 87 | + |
| 88 | + - name: Upload Artifact to Release |
| 89 | + uses: softprops/action-gh-release@v1 |
| 90 | + with: |
| 91 | + files: ./build/${{ env.RELEASE_NAME }}.tar.gz |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + if: github.event_name == 'release' && github.event.action == 'published' |
0 commit comments