Skip to content

Commit

Permalink
*: implement goreleaser
Browse files Browse the repository at this point in the history
Define goreleaser rules and Github Action to cross compile charon archives for macOS and Linux, both amd64 and arm64.
  • Loading branch information
gsora committed Feb 21, 2024
1 parent 0dd2712 commit 1e80a7b
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 4 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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@v4
with:
go-version: "1.21.5"

- name: OSXCross for CGO Support
run: |
git clone https://github.com/plentico/osxcross-target.git /osxcross/target
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --snapshot --clean
60 changes: 56 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,74 @@
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
#
# To test on macOS, one needs a Linux-compatible toolchain:
# https://github.com/messense/homebrew-macos-cross-toolchains

version: 1

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
upx:
- # Whether to enable it or not.
#
# Templates: allowed (since v1.21)
enabled: true
# compress: best

# for reproducible builds, we need the replace directive to be removed
# gomod:
# proxy: true

# # If proxy is true, use these environment variables when running `go mod`
# # commands (namely, `go mod tidy`).
# #
# # Default: `os.Environ()` merged with what you set the root `env` section.
# env:
# - GOPROXY=https://proxy.golang.org,direct
# - GOSUMDB=sum.golang.org

builds:
- env:
- id: macos_m1
env:
- CGO_ENABLED=1
- CC=/osxcross/target/bin/o64-clang
- CXX=/osxcross/target/bin/o64-clang++
goos:
- linux
- darwin
goarch:
- amd64

- id: macos_intel
env:
- "CGO_ENABLED=1"
- CC=/home/runner/work/osxcross/target/bin/oa64-clang
- CXX=/home/runner/work/osxcross/target/bin/oa64-clang++
goos:
- darwin
goarch:
- arm64

- id: linux_arm64
goos:
- linux
goarch:
- arm64
env:
- CGO_ENABLED=1
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++

- id: linux_amd64
goos:
- linux
goarch:
- amd64
env:
- CC=x86_64-linux-gnu-gcc
- CXX=x86_64-linux-gnu-g++

archives:
- format: tar.gz
Expand Down

0 comments on commit 1e80a7b

Please sign in to comment.