Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interest in providing pre-built binaries #29

Open
spwoodcock opened this issue Oct 15, 2024 · 1 comment · May be fixed by #30
Open

Interest in providing pre-built binaries #29

spwoodcock opened this issue Oct 15, 2024 · 1 comment · May be fixed by #30

Comments

@spwoodcock
Copy link

spwoodcock commented Oct 15, 2024

Pre-built binaries

  • Building pre-built binaries would be really nice to have.
  • This way users can just download the binary for their architecture and run something like tilepack [-flags] ....
  • There is a small hurdle that mattn/go-sqlite3 requires CGO, so we also need to compile the SQLite C library, but this can be overcome in two ways:
    • Tweak the build to compile SQLite and bundle it as a static binary.
    • Swap mattn/go-sqlite3 for modernc.org/sqlite, a pure Go rewrite of SQLite. This has a small caveat that is marginally slower than the C code, but it's really not a deal breaker (particularly as SQLite does not allow concurrent writes anyway).

Proposed build config

I'm more than happy to submit a PR for this, but first wanted to gauge interest.

The following code uses mattn/go-sqlite3 with CGO_ENABLED=1.
The config would be simplified greatly if modernc.org/sqlite was used instead.

.goreleaser.yaml

version: 2

env:
- CGO_ENABLED=1

builds:
  # MacOS AMD64
  - id: tilepack-darwin-amd64
    binary: tilepack
    main: cmd/build/main.go
    goarch:
      - amd64
    goos:
      - darwin
    env:
      - CC=o64-clang
      - CXX=o64-clang++
    flags:
      - -trimpath

  # MacOS ARM64
  - id: tilepack-darwin-arm64
    binary: tilepack
    main: cmd/build/main.go
    goarch:
      - arm64
    goos:
      - darwin
    env:
      - CC=oa64-clang
      - CXX=oa64-clang++
    flags:
      - -trimpath

  # Linux AMD64
  - id: tilepack-linux-amd64
    binary: tilepack
    main: cmd/build/main.go
    env:
      - CC=x86_64-linux-gnu-gcc
      - CXX=x86_64-linux-gnu-g++
    goarch:
      - amd64
    goos:
      - linux
    flags:
      - -trimpath
    ldflags:
      - -extldflags "-lc -lrt -lpthread --static"

  # Linux ARM64
  - id: tilepack-linux-arm64
    binary: tilepack
    main: cmd/build/main.go
    goarch:
      - arm64
    goos:
      - linux
    env:
      - CC=aarch64-linux-gnu-gcc
      - CXX=aarch64-linux-gnu-g++
    flags:
      - -trimpath
    ldflags:
      - -extldflags "-lc -lrt -lpthread --static"

  # Windows AMD64
  - id: tilepack-windows-amd64
    binary: tilepack
    main: cmd/build/main.go
    goarch:
      - amd64
    goos:
      - windows
    env:
      - CC=x86_64-w64-mingw32-gcc
      - CXX=x86_64-w64-mingw32-g++
    flags:
      - -trimpath
      - -buildmode=exe

  # Windows ARM64
  - id: tilepack-windows-arm64
    binary: tilepack
    main: cmd/build/main.go
    goarch:
      - arm64
    goos:
      - windows
    env:
      - CC=/llvm-mingw/bin/aarch64-w64-mingw32-gcc
      - CXX=/llvm-mingw/bin/aarch64-w64-mingw32-g++
    flags:
      - -trimpath
      - -buildmode=exe

archives:
  - name_template: "tilepack_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
    builds:
      - tilepack-darwin-amd64
      - tilepack-darwin-arm64
      - tilepack-linux-amd64
      - tilepack-linux-arm64
      - tilepack-windows-amd64
      - tilepack-windows-arm64
    wrap_in_directory: false
    format: tar.gz
    # use zip for windows archives
    format_overrides:
      - goos: windows
        format: zip
    files:
      - none*

checksum:
  name_template: 'checksums.txt'
gitlab_urls:
  use_package_registry: true
snapshot:
  version_template: '{{ .Tag }}-next'
changelog:
  sort: asc
  filters:
    exclude:
      - '^docs:'
      - '^test:'
      - '^.github:'
      - '^vendor:'

Github workflow

name: goreleaser

on:
  pull_request:
  push:

permissions:
  contents: write

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      -
        name: Set up Go
        uses: actions/setup-go@v5
      -
        name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v6
        with:
          distribution: goreleaser
          version: '~> v2'
          args: release --clean
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Note

This is only for the build CLI.
We could also package the serve CLI if desired, perhaps by wrapping in a higher level CLI?
e.g. tilepack build ... & tilepack serve ...

@iandees
Copy link
Member

iandees commented Oct 25, 2024

I think I would accept this, yes. I personally don't use binaries in this way, but can imagine others might.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants