From 2e1d9b33c1dbfb7833c200553647132c258f87b2 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Sat, 13 Jun 2026 17:27:39 +0800 Subject: [PATCH] Add binary build workflow --- .github/workflows/binaries.yml | 112 +++++++++++++++++++++++++++++++++ .gitignore | 1 + package.json | 1 + 3 files changed, 114 insertions(+) create mode 100644 .github/workflows/binaries.yml diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml new file mode 100644 index 0000000..b2a348b --- /dev/null +++ b/.github/workflows/binaries.yml @@ -0,0 +1,112 @@ +name: Binaries + +on: + push: + branches: + - master + tags: + - "v*" + pull_request: + branches: + - master + workflow_dispatch: + +permissions: + contents: write + +jobs: + verify: + name: Verify + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Type-check + run: bun run check + + - name: Test + run: bun test + + build: + name: Build ${{ matrix.name }} + needs: verify + strategy: + fail-fast: false + matrix: + include: + - name: linux-x64 + os: ubuntu-latest + ext: "" + - name: macos-arm64 + os: macos-latest + ext: "" + - name: windows-x64 + os: windows-latest + ext: ".exe" + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Compile CLI + shell: bash + run: | + mkdir -p dist/bin + bun build --compile --outfile "dist/bin/seal-home-${{ matrix.name }}${{ matrix.ext }}" src/cli.ts + + - name: Package artifact + shell: bash + run: | + cd dist/bin + if [[ "${{ matrix.os }}" == "windows-latest" ]]; then + 7z a "seal-home-${{ matrix.name }}.zip" "seal-home-${{ matrix.name }}${{ matrix.ext }}" + else + tar -czf "seal-home-${{ matrix.name }}.tar.gz" "seal-home-${{ matrix.name }}${{ matrix.ext }}" + fi + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: seal-home-${{ matrix.name }} + path: | + dist/bin/seal-home-${{ matrix.name }}.tar.gz + dist/bin/seal-home-${{ matrix.name }}.zip + if-no-files-found: error + + release: + name: Publish release assets + if: startsWith(github.ref, 'refs/tags/v') + needs: build + runs-on: ubuntu-latest + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: release-assets + pattern: seal-home-* + merge-multiple: true + + - name: Upload release assets + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1 || gh release create "${GITHUB_REF_NAME}" --title "${GITHUB_REF_NAME}" --notes "Automated binary release for ${GITHUB_REF_NAME}." + gh release upload "${GITHUB_REF_NAME}" release-assets/* --clobber diff --git a/.gitignore b/.gitignore index 609cdf0..edb010f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ node_modules/ .cache/ tmp/* !tmp/.gitkeep +dist/bin/ # Local enterprise configs can contain credentials. enterprises/*.json diff --git a/package.json b/package.json index 5268ff2..b1e595f 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "probe": "bun run src/probe.ts", "cli": "bun run src/cli.ts", "check": "tsc --noEmit", + "build:binary": "bun build --compile --outfile dist/bin/seal-home src/cli.ts", "openapi:bundle": "bun run scripts/bundle-openapi.ts", "test": "bun test" },