name: Bridge release # Runs when bridge/ changes. PRs build all three binaries; pushes to main also publish a GitHub # release, which the in-app Download page links to via /releases/latest. on: push: branches: [main] paths: - "bridge/**" - ".github/workflows/bridge-release.yml" pull_request: branches: [main, develop] paths: - "bridge/**" - ".github/workflows/bridge-release.yml" workflow_dispatch: {} concurrency: group: bridge-release-${{ github.ref }} cancel-in-progress: true jobs: build-windows: # A main -> develop back-merge only brings release commits main already tested. if: github.head_ref != 'main' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version-file: bridge/go.mod - name: Test working-directory: bridge run: go test ./... - name: Build (cross-compiled, no cgo needed) working-directory: bridge env: CGO_ENABLED: 0 GOOS: windows GOARCH: amd64 run: go build -o dist/thingport-bridge-windows-amd64.exe ./cmd/thingport-bridge - uses: actions/upload-artifact@v4 with: name: bridge-windows-amd64 path: bridge/dist/thingport-bridge-windows-amd64.exe if-no-files-found: error build-linux: # A main -> develop back-merge only brings release commits main already tested. if: github.head_ref != 'main' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version-file: bridge/go.mod - name: Test working-directory: bridge run: go test ./... - name: Build (cross-compiled, no cgo needed) working-directory: bridge env: CGO_ENABLED: 0 GOOS: linux GOARCH: amd64 run: go build -o dist/thingport-bridge-linux-amd64 ./cmd/thingport-bridge - uses: actions/upload-artifact@v4 with: name: bridge-linux-amd64 path: bridge/dist/thingport-bridge-linux-amd64 if-no-files-found: error build-macos: # A main -> develop back-merge only brings release commits main already tested. if: github.head_ref != 'main' # macOS URL-scheme handling needs cgo and Cocoa, so it can't be cross-compiled. runs-on: macos-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version-file: bridge/go.mod - name: Test working-directory: bridge run: go test ./... - name: Build arm64 + amd64 working-directory: bridge env: CGO_ENABLED: 1 run: | GOARCH=arm64 go build -o dist/thingport-bridge-darwin-arm64 ./cmd/thingport-bridge GOARCH=amd64 go build -o dist/thingport-bridge-darwin-amd64 ./cmd/thingport-bridge - name: Combine into a universal binary working-directory: bridge run: lipo -create -output dist/thingport-bridge-macos dist/thingport-bridge-darwin-arm64 dist/thingport-bridge-darwin-amd64 - name: Re-sign universal binary working-directory: bridge run: codesign --force -s - dist/thingport-bridge-macos - uses: actions/upload-artifact@v4 with: name: bridge-macos path: bridge/dist/thingport-bridge-macos if-no-files-found: error release: if: github.event_name == 'push' && github.ref == 'refs/heads/main' needs: [build-windows, build-linux, build-macos] runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: path: dist - name: Flatten downloaded artifacts run: | mkdir -p release mv dist/bridge-windows-amd64/thingport-bridge-windows-amd64.exe release/ mv dist/bridge-linux-amd64/thingport-bridge-linux-amd64 release/ mv dist/bridge-macos/thingport-bridge-macos release/ chmod +x release/thingport-bridge-linux-amd64 release/thingport-bridge-macos - name: Compute release tag id: tag run: echo "tag=bridge-$(date +%Y%m%d)-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" - name: Publish release uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.tag.outputs.tag }} name: Thingport Bridge ${{ steps.tag.outputs.tag }} body: | Automated build of the Thingport slicer bridge (see `bridge/README.md`) from ${{ github.sha }}. - **Windows**: `thingport-bridge-windows-amd64.exe` — run it once (double-click is fine) to install. - **Linux**: `thingport-bridge-linux-amd64` — `chmod +x`, then run it once to install. - **macOS**: `thingport-bridge-macos` (universal) — `chmod +x`, remove the quarantine flag, then run with `--install`. See the README for the exact commands. make_latest: true files: | release/thingport-bridge-windows-amd64.exe release/thingport-bridge-linux-amd64 release/thingport-bridge-macos