|
| 1 | +name: provider-couchbase |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'provider-couchbase-v[0-9].[0-9]+.[0-9]+' |
| 7 | + pull_request: |
| 8 | + paths: |
| 9 | + - '.github/workflows/provider-couchbase.yml' |
| 10 | + - 'providers/couchbase/**' |
| 11 | + |
| 12 | +env: |
| 13 | + working_directory: providers/couchbase |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + platform: |
| 21 | + - os: linux |
| 22 | + arch: amd64 |
| 23 | + bin: linux_amd64.bin |
| 24 | + - os: linux |
| 25 | + arch: arm64 |
| 26 | + bin: linux_arm64.bin |
| 27 | + - os: darwin |
| 28 | + arch: amd64 |
| 29 | + bin: darwin_amd64.bin |
| 30 | + - os: darwin |
| 31 | + arch: arm64 |
| 32 | + bin: darwin_arm64.bin |
| 33 | + - os: windows |
| 34 | + arch: amd64 |
| 35 | + bin: windows_amd64.exe |
| 36 | + |
| 37 | + steps: |
| 38 | + # Checkout the repository with submodules |
| 39 | + - name: Checkout repository |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + submodules: recursive |
| 43 | + |
| 44 | + # Set up Go environment |
| 45 | + - name: Set up Go |
| 46 | + uses: actions/setup-go@v4 |
| 47 | + with: |
| 48 | + go-version: '1.24' |
| 49 | + |
| 50 | + # Install dependencies |
| 51 | + - name: Install dependencies |
| 52 | + working-directory: ${{ env.working_directory }} |
| 53 | + run: go mod tidy |
| 54 | + |
| 55 | + # Build Go binaries for multiple platforms |
| 56 | + - name: Build binary ${{ matrix.platform.os }}_${{ matrix.platform.arch }} |
| 57 | + env: |
| 58 | + GOOS: ${{ matrix.platform.os }} |
| 59 | + GOARCH: ${{ matrix.platform.arch }} |
| 60 | + working-directory: ${{ env.working_directory }} |
| 61 | + run: | |
| 62 | + echo "Building for $GOOS/$GOARCH to ${{ matrix.platform.bin }}" |
| 63 | + GOOS=$GOOS GOARCH=$GOARCH go build -o ${{ matrix.platform.bin }} |
| 64 | + - name: Upload binary |
| 65 | + uses: actions/upload-artifact@v4 |
| 66 | + with: |
| 67 | + name: ${{ matrix.platform.os }}_${{ matrix.platform.arch }} |
| 68 | + path: ${{ env.working_directory }}/${{ matrix.platform.bin }} |
| 69 | + |
| 70 | + archive: |
| 71 | + runs-on: ubuntu-latest |
| 72 | + needs: build |
| 73 | + steps: |
| 74 | + - name: Checkout repository |
| 75 | + uses: actions/checkout@v4 |
| 76 | + with: |
| 77 | + submodules: recursive |
| 78 | + # Install wash |
| 79 | + - uses: taiki-e/install-action@be7c31b6745feec79dec5eb79178466c0670bb2d # v2.49.49 |
| 80 | + with: |
| 81 | + tool: wash |
| 82 | + - name: Install wit-bindgen-wrpc |
| 83 | + run: | |
| 84 | + curl -fLO https://github.com/bytecodealliance/wrpc/releases/download/v0.14.0/wit-bindgen-wrpc-x86_64-unknown-linux-musl |
| 85 | + chmod +x wit-bindgen-wrpc-x86_64-unknown-linux-musl |
| 86 | + sudo mv wit-bindgen-wrpc-x86_64-unknown-linux-musl /usr/local/bin/wit-bindgen-wrpc |
| 87 | + - name: Download binary |
| 88 | + uses: actions/download-artifact@v4 |
| 89 | + with: |
| 90 | + path: ${{ env.working_directory }}/bin |
| 91 | + - name: Set version |
| 92 | + if: github.event_name == 'pull_request' |
| 93 | + run: echo "VERSION=canary" >> $GITHUB_ENV |
| 94 | + - name: Set version |
| 95 | + if: github.event_name == 'push' |
| 96 | + run: | |
| 97 | + echo "VERSION=${GITHUB_REF_NAME#couchbase-provider-v}" >> $GITHUB_ENV |
| 98 | + # Create provider archive |
| 99 | + - name: Provider archive |
| 100 | + working-directory: ${{ env.working_directory }} |
| 101 | + env: |
| 102 | + WASH_ISSUER_KEY: ${{ secrets.WASMCLOUD_ACCOUNT_OFFICIAL }} |
| 103 | + WASH_SUBJECT_KEY: ${{ secrets.WASMCLOUD_COUCHBASE }} |
| 104 | + run: | |
| 105 | + wash par create \ |
| 106 | + --binary "./bin/linux_amd64/linux_amd64.bin" \ |
| 107 | + --compress \ |
| 108 | + --destination "couchbase.par.gz" \ |
| 109 | + --name "couchbase-provider" \ |
| 110 | + --vendor "wasmcloud" \ |
| 111 | + --version "${VERSION}" |
| 112 | + # TODO: encode WIT in archive after merging |
| 113 | + wash par insert \ |
| 114 | + --arch aarch64-linux \ |
| 115 | + --binary "./bin/linux_arm64/linux_arm64.bin" \ |
| 116 | + couchbase.par.gz |
| 117 | + wash par insert \ |
| 118 | + --arch aarch64-macos \ |
| 119 | + --binary "./bin/darwin_arm64/darwin_arm64.bin" \ |
| 120 | + couchbase.par.gz |
| 121 | + wash par insert \ |
| 122 | + --arch x86_64-macos \ |
| 123 | + --binary "./bin/darwin_amd64/darwin_amd64.bin" \ |
| 124 | + couchbase.par.gz |
| 125 | + wash par insert \ |
| 126 | + --arch x86_64-windows \ |
| 127 | + --binary "./bin/windows_amd64/windows_amd64.exe" \ |
| 128 | + couchbase.par.gz |
| 129 | + wash par inspect couchbase.par.gz |
| 130 | + - name: Upload provider archive |
| 131 | + uses: actions/upload-artifact@v4 |
| 132 | + with: |
| 133 | + name: couchbase-provider-archive |
| 134 | + path: ${{ env.working_directory }}/couchbase.par.gz |
| 135 | + - name: Push provider archive |
| 136 | + # if: github.event_name == 'push' |
| 137 | + env: |
| 138 | + WASH_REG_USER: wasmCloud |
| 139 | + WASH_REG_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
| 140 | + run: | |
| 141 | + wash push ghcr.io/wasmcloud/contrib/providers/couchbase:$VERSION \ |
| 142 | + ${{ env.working_directory }}/couchbase.par.gz \ |
0 commit comments