diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..18b71854 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,100 @@ +name: Release Build + +on: + push: + branches: + - main + +permissions: + contents: write + +jobs: + build: + strategy: + matrix: + include: + - os: ubuntu-latest + goos: linux + goarch: amd64 + - os: ubuntu-latest + goos: linux + goarch: arm64 + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Build + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + run: | + go build -o duckgres-${{ matrix.goos }}-${{ matrix.goarch }} . + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: duckgres-${{ matrix.goos }}-${{ matrix.goarch }} + path: duckgres-${{ matrix.goos }}-${{ matrix.goarch }} + + release: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Get short SHA + id: sha + run: echo "short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + tag_name: build-${{ steps.sha.outputs.short }} + name: Build ${{ steps.sha.outputs.short }} + body: | + Automated build from commit ${{ github.sha }} + files: | + artifacts/duckgres-linux-amd64/duckgres-linux-amd64 + artifacts/duckgres-linux-arm64/duckgres-linux-arm64 + + - name: Delete existing latest release + run: gh release delete latest --yes || true + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Update latest tag + run: | + git tag -f latest + git push -f origin latest + + - name: Create latest release + uses: softprops/action-gh-release@v2 + with: + tag_name: latest + name: Latest Build + body: | + Latest build from commit ${{ github.sha }} + + For a stable URL, use: + ``` + https://github.com/PostHog/duckgres/releases/latest/download/duckgres-linux-amd64 + https://github.com/PostHog/duckgres/releases/latest/download/duckgres-linux-arm64 + ``` + files: | + artifacts/duckgres-linux-amd64/duckgres-linux-amd64 + artifacts/duckgres-linux-arm64/duckgres-linux-arm64