diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a641cc6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,92 @@ +name: Release Binaries + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + release: + name: Build and Release + runs-on: ubuntu-latest + strategy: + matrix: + include: + - goos: linux + goarch: amd64 + suffix: linux-amd64 + - goos: linux + goarch: arm64 + suffix: linux-arm64 + - goos: darwin + goarch: amd64 + suffix: darwin-amd64 + - goos: darwin + goarch: arm64 + suffix: darwin-arm64 + - goos: windows + goarch: amd64 + suffix: windows-amd64 + ext: .exe + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.24' + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'pnpm' + cache-dependency-path: frontend/pnpm-lock.yaml + + - name: Install pnpm + run: npm install -g pnpm + + - name: Print build info + run: | + echo "Tag: ${{ github.ref_name }}" + echo "GoOS: ${{ matrix.goos }}" + echo "GoArch: ${{ matrix.goarch }}" + + - name: Build frontend + working-directory: frontend + run: | + pnpm install --registry=https://registry.npmmirror.com + pnpm run build + + - name: Copy frontend dist for embedding + run: | + mkdir -p internal/static/frontend + cp -r frontend/dist internal/static/frontend/ + + - name: Build binary + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + CGO_ENABLED: 0 + run: | + OUTPUT_NAME="ushare-${{ matrix.suffix }}${{ matrix.ext }}" + go build -ldflags '-s -w' -o "$OUTPUT_NAME" . + chmod +x "$OUTPUT_NAME" + + - name: Generate checksums + run: | + OUTPUT_NAME="ushare-${{ matrix.suffix }}${{ matrix.ext }}" + sha256sum "$OUTPUT_NAME" > "$OUTPUT_NAME.sha256" + + - name: Upload to release + uses: softprops/action-gh-release@v1 + with: + files: | + ushare-${{ matrix.suffix }}${{ matrix.ext }} + ushare-${{ matrix.suffix }}${{ matrix.ext }}.sha256 + draft: false + prerelease: false