|
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - main |
| 7 | + - testdarwin2 |
7 | 8 | tags: |
8 | 9 | - '**' |
9 | | - paths-ignore: |
10 | | - - README.md |
11 | | - pull_request: |
12 | | - paths-ignore: |
13 | | - - README.md |
| 10 | + # paths-ignore: |
| 11 | + # - README.md |
| 12 | + # pull_request: |
| 13 | + # paths-ignore: |
| 14 | + # - README.md |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write # needed to write releases |
| 18 | + packages: write # needed for ghcr access |
| 19 | + |
14 | 20 | jobs: |
| 21 | + |
| 22 | + mac-build: |
| 23 | + # This job builds and releases "universal libraries" that are |
| 24 | + # supported by both darwin-amd64 and darwin-arm64. |
| 25 | + # |
| 26 | + # First builds in amd64, then cross-compile in arm64. Later combining |
| 27 | + # both outcomes onto a single binary for each static library. |
| 28 | + # |
| 29 | + # `macos-11` has been picked as support for arm64 was only added on Xcode 12. |
| 30 | + # Although some minor versions of Catalina 10.15 can support it, at the time |
| 31 | + # of testing, GitHub's macos-10.15 did not seem to. |
| 32 | + # Cross-compiling to arm64 on that runner consistently failed. |
| 33 | + runs-on: macos-11 |
| 34 | + steps: |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v2 |
| 37 | + - name: Build universal static libraries for Darwin |
| 38 | + run: | |
| 39 | + TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64 \ |
| 40 | + BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/amd \ |
| 41 | + ./hack/static.sh all |
| 42 | + |
| 43 | + TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64 \ |
| 44 | + BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/arm \ |
| 45 | + TARGET_ARCH=arm64 \ |
| 46 | + CMAKE_APPLE_SILICON_PROCESSOR=arm64 \ |
| 47 | + ./hack/static.sh all |
| 48 | +
|
| 49 | + mkdir -p ./libgit2-darwin/lib |
| 50 | + mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/include ./libgit2-darwin/ |
| 51 | + mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/share ./libgit2-darwin/ |
| 52 | + mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/cmake ./libgit2-darwin/lib/ |
| 53 | + mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/engines-3 ./libgit2-darwin/lib/ |
| 54 | + mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/ossl-modules ./libgit2-darwin/lib/ |
| 55 | + mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/pkgconfig ./libgit2-darwin/lib/ |
| 56 | +
|
| 57 | + libtool -static -o ./libgit2-darwin/lib/libcrypto.a \ |
| 58 | + ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libcrypto.a \ |
| 59 | + ${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libcrypto.a |
| 60 | + libtool -static -o ./libgit2-darwin/lib/libgit2.a \ |
| 61 | + ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libgit2.a \ |
| 62 | + ${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libgit2.a |
| 63 | + libtool -static -o ./libgit2-darwin/lib/libssh2.a \ |
| 64 | + ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libssh2.a \ |
| 65 | + ${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libssh2.a |
| 66 | + libtool -static -o ./libgit2-darwin/lib/libssl.a \ |
| 67 | + ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libssl.a \ |
| 68 | + ${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libssl.a |
| 69 | + libtool -static -o ./libgit2-darwin/lib/libz.a \ |
| 70 | + ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libz.a \ |
| 71 | + ${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libz.a |
| 72 | +
|
| 73 | + tar -zcvf darwin-libs.tar.gz ./libgit2-darwin |
| 74 | + env: |
| 75 | + MACOSX_DEPLOYMENT_TARGET: 10.15 |
| 76 | + |
| 77 | + - name: Create Release |
| 78 | + if: github.event_name != 'pull_request' |
| 79 | + id: create_release |
| 80 | + uses: actions/create-release@v1 |
| 81 | + env: |
| 82 | + GITHUB_TOKEN: ${{ github.token }} |
| 83 | + with: |
| 84 | + release_name: ${{ github.ref }} |
| 85 | + tag_name: ${{ github.ref }} |
| 86 | + draft: false |
| 87 | + prerelease: true |
| 88 | + - name: Upload Release Asset |
| 89 | + if: github.event_name != 'pull_request' |
| 90 | + id: upload-release-asset |
| 91 | + uses: actions/upload-release-asset@v1 |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ github.token }} |
| 94 | + with: |
| 95 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 96 | + asset_path: ./darwin-libs.tar.gz |
| 97 | + asset_name: darwin-libs.tar.gz |
| 98 | + asset_content_type: application/gzip |
| 99 | + |
15 | 100 | build: |
16 | 101 | runs-on: ubuntu-latest |
17 | 102 | env: |
|
55 | 140 | key: ${{ runner.os }}-buildx-ghcache-${{ github.sha }} |
56 | 141 | restore-keys: | |
57 | 142 | ${{ runner.os }}-buildx-ghcache- |
58 | | - - run: cat ./hack/Makefile |
| 143 | + - run: cat ./hack/static.sh |
59 | 144 | - name: Build candidate image |
60 | 145 | id: build_candidate |
61 | 146 | uses: docker/build-push-action@v2 |
|
0 commit comments