|
| 1 | +on: |
| 2 | + workflow_dispatch: |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + pull-requests: write |
| 6 | +name: Build and Release Google.Cloud.SpannerLib.Native |
| 7 | +jobs: |
| 8 | + build-linux-x64: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Install Go |
| 12 | + uses: actions/setup-go@v5 |
| 13 | + with: |
| 14 | + go-version: 1.24 |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v4 |
| 17 | + - name: Build shared library |
| 18 | + working-directory: spannerlib |
| 19 | + run: go build -o spannerlib.so -buildmode=c-shared shared_lib.go |
| 20 | + - name: Build gRPC server |
| 21 | + working-directory: spannerlib |
| 22 | + run: go build grpc_server.go |
| 23 | + - name: Upload linux-x64 shared lib |
| 24 | + uses: actions/upload-artifact@v4 |
| 25 | + with: |
| 26 | + name: spannerlib-linux-x64 |
| 27 | + path: spannerlib/spannerlib.so |
| 28 | + - name: Upload linux-x64 gRPC server |
| 29 | + uses: actions/upload-artifact@v4 |
| 30 | + with: |
| 31 | + name: spannerlib-server-linux-x64 |
| 32 | + path: spannerlib/grpc_server |
| 33 | + build-osx-arm64: |
| 34 | + runs-on: macos-latest |
| 35 | + steps: |
| 36 | + - name: Install Go |
| 37 | + uses: actions/setup-go@v5 |
| 38 | + with: |
| 39 | + go-version: 1.24 |
| 40 | + - name: Checkout code |
| 41 | + uses: actions/checkout@v4 |
| 42 | + - name: Build shared library |
| 43 | + working-directory: spannerlib |
| 44 | + run: go build -o spannerlib.dylib -buildmode=c-shared shared_lib.go |
| 45 | + - name: Build gRPC server |
| 46 | + working-directory: spannerlib |
| 47 | + run: go build grpc_server.go |
| 48 | + - name: Upload osx-arm64 shared lib |
| 49 | + uses: actions/upload-artifact@v4 |
| 50 | + with: |
| 51 | + name: spannerlib-osx-arm64 |
| 52 | + path: spannerlib/spannerlib.dylib |
| 53 | + - name: Upload osx-arm64 gRPC server |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: spannerlib-server-osx-arm64 |
| 57 | + path: spannerlib/grpc_server |
| 58 | + build-and-package: |
| 59 | + needs: [build-linux-x64, build-osx-arm64] |
| 60 | + runs-on: ubuntu-latest |
| 61 | + steps: |
| 62 | + - name: Checkout code |
| 63 | + uses: actions/checkout@v4 |
| 64 | + - name: Download and copy linux-x64 shared lib |
| 65 | + uses: actions/download-artifact@v4 |
| 66 | + with: |
| 67 | + name: spannerlib-linux-x64 |
| 68 | + path: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Native/libraries/linux-x64/ |
| 69 | + - name: Download and copy linux-x64 gRPC server |
| 70 | + uses: actions/download-artifact@v4 |
| 71 | + with: |
| 72 | + name: spannerlib-server-linux-x64 |
| 73 | + path: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Grpc/binaries/linux-x64/ |
| 74 | + - name: Add execute permission to linux-x64 gRPC server |
| 75 | + run: chmod +x spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Grpc/binaries/linux-x64/grpc_server |
| 76 | + - name: Download and copy osx-arm64 |
| 77 | + uses: actions/download-artifact@v4 |
| 78 | + with: |
| 79 | + name: spannerlib-osx-arm64 |
| 80 | + path: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Native/libraries/osx-arm64/ |
| 81 | + - name: Download and copy osx-arm64 gRPC server |
| 82 | + uses: actions/download-artifact@v4 |
| 83 | + with: |
| 84 | + name: spannerlib-server-osx-arm64 |
| 85 | + path: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Grpc/binaries/osx-arm64/ |
| 86 | + - name: Add execute permission to osx-arm64 gRPC server |
| 87 | + run: chmod +x spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Grpc/binaries/osx-arm64/grpc_server |
| 88 | + - name: Install dotnet |
| 89 | + uses: actions/setup-dotnet@v4 |
| 90 | + with: |
| 91 | + dotnet-version: '9.0.x' |
| 92 | + - name: dotnet version |
| 93 | + run: dotnet --version |
| 94 | + - name: Build native library package |
| 95 | + run: dotnet pack |
| 96 | + working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Native |
| 97 | + - name: Build gRPC server package |
| 98 | + run: dotnet pack |
| 99 | + working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Grpc |
| 100 | + - name: Add package source for native library |
| 101 | + run: dotnet nuget add source "$PWD"/bin/Release --name local |
| 102 | + working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Native |
| 103 | + - name: Restore dependencies |
| 104 | + run: dotnet restore |
| 105 | + working-directory: spannerlib/dotnet-spannerlib |
| 106 | + - name: Build |
| 107 | + run: dotnet build --no-restore |
| 108 | + working-directory: spannerlib/dotnet-spannerlib |
| 109 | + - name: Publish SpannerLib.Native to nuget |
| 110 | + run: dotnet nuget push bin/Release/Experimental.SpannerLib.Native.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json |
| 111 | + working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Native |
| 112 | + - name: Publish SpannerLib.Grpc to nuget |
| 113 | + run: dotnet nuget push bin/Release/Experimental.SpannerLib.Grpc.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json |
| 114 | + working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Grpc |
0 commit comments