Skip to content

Merge pull request #11 from 954-Ivory/fix-usage-feat #26

Merge pull request #11 from 954-Ivory/fix-usage-feat

Merge pull request #11 from 954-Ivory/fix-usage-feat #26

name: Multi-Platform Build
on:
workflow_dispatch:
push:
branches: ["main"]
tags: ["v*"]
pull_request:
branches: ["main"]
permissions:
contents: read
jobs:
release-please:
name: Release Please
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- name: Run release-please
id: release
uses: googleapis/release-please-action@v4
with:
release-type: simple
package-name: tavily-proxy
build-web:
name: Build Web Assets
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
cache-dependency-path: web/package-lock.json
- name: Build frontend
working-directory: web
run: |
npm ci
npm run build
- name: Pack web assets
run: tar -C web -czf web-dist.tar.gz dist
- name: Upload web assets
uses: actions/upload-artifact@v4
with:
name: web-dist
path: web-dist.tar.gz
if-no-files-found: error
build-binary:
name: Build ${{ matrix.goos }}-${{ matrix.goarch }}
runs-on: ubuntu-latest
needs: build-web
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
binary_ext: ""
- goos: linux
goarch: arm64
binary_ext: ""
- goos: windows
goarch: amd64
binary_ext: ".exe"
- goos: windows
goarch: arm64
binary_ext: ".exe"
- goos: darwin
goarch: amd64
binary_ext: ""
- goos: darwin
goarch: arm64
binary_ext: ""
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Download web assets
uses: actions/download-artifact@v4
with:
name: web-dist
path: .
- name: Build binary
id: build
run: |
tar -xzf web-dist.tar.gz
mkdir -p server/public
rm -rf server/public/*
cp -R dist/. server/public/
mkdir -p build
binary_name="tavily-proxy-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.binary_ext }}"
archive_name="tavily-proxy-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz"
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
go build -trimpath -ldflags="-s -w" -o "build/${binary_name}" ./server
tar -C build -czf "build/${archive_name}" "${binary_name}"
echo "archive_path=build/${archive_name}" >> "$GITHUB_OUTPUT"
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: tavily-proxy-${{ matrix.goos }}-${{ matrix.goarch }}
path: ${{ steps.build.outputs.archive_path }}
if-no-files-found: error
publish-release-tag:
name: Publish Release Assets (Tag)
runs-on: ubuntu-latest
needs: build-binary
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download all binary artifacts
uses: actions/download-artifact@v4
with:
pattern: tavily-proxy-*
path: release-assets
merge-multiple: true
- name: Generate checksums
run: |
cd release-assets
sha256sum *.tar.gz > checksums.txt
- name: Publish to GitHub Releases
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
generate_release_notes: true
files: |
release-assets/*.tar.gz
release-assets/checksums.txt
fail_on_unmatched_files: true
publish-release-main:
name: Publish Release Assets (Main Auto)
runs-on: ubuntu-latest
needs:
- release-please
- build-binary
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.release-please.outputs.release_created == 'true'
permissions:
contents: write
steps:
- name: Download all binary artifacts
uses: actions/download-artifact@v4
with:
pattern: tavily-proxy-*
path: release-assets
merge-multiple: true
- name: Generate checksums
run: |
cd release-assets
sha256sum *.tar.gz > checksums.txt
- name: Publish to GitHub Releases
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release-please.outputs.tag_name }}
generate_release_notes: true
files: |
release-assets/*.tar.gz
release-assets/checksums.txt
fail_on_unmatched_files: true