Skip to content

Commit 9f365ed

Browse files
committed
feat: v0.1.0
1 parent 72ef93f commit 9f365ed

File tree

5 files changed

+150
-0
lines changed

5 files changed

+150
-0
lines changed

.github/workflows/goreleaser.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: goreleaser
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags:
7+
- v*
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
- name: Set up zig 0.13.0
17+
uses: goto-bus-stop/setup-zig@v2
18+
with:
19+
version: 0.13.0
20+
# taken from https://github.com/goreleaser/goreleaser/blob/main/.github/workflows/release.yml
21+
- name: Run GoReleaser
22+
uses: goreleaser/goreleaser-action@v2
23+
with:
24+
distribution: goreleaser
25+
version: latest
26+
args: release --clean
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}

.goreleaser.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# .goreleaser.yml
2+
version: 2.0
3+
project_name: schnorr
4+
builds:
5+
# The Zig executable name (specified in build.zig)
6+
- binary: schnorr
7+
# We should be able to use this, no go-dummy, but it seems broken right now
8+
#builder: prebuilt
9+
gobinary: ./.goreleaser/go-dummy
10+
main: ./.goreleaser/dummy.go
11+
goos:
12+
- darwin
13+
- linux
14+
- windows
15+
goarch:
16+
- amd64
17+
- arm64
18+
goamd64:
19+
- v1
20+
hooks:
21+
# This is called for every architecture.
22+
# eg: ./build.sh linux_amd64 csv2json
23+
post: ./.goreleaser/build.sh "{{ .Os }}" "{{ .Arch }}" "{{ .ProjectName }}" "{{ .Arm }}"
24+
archives:
25+
- format: tar.gz
26+
# Additional static to bundle in the release.
27+
files:
28+
- README.md
29+
- LICENSE.md
30+
brews:
31+
- name: schnorr
32+
homepage: https://github.com/aidanaden/schnorr-zig
33+
description: |
34+
Schnorr Signing (via Ristretto255) CLI tool
35+
repository:
36+
owner: aidanaden
37+
name: homebrew-tools
38+
install: |-
39+
bin.install "schnorr"

.goreleaser/build.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/sh
2+
set -e
3+
set -u
4+
5+
# The args come from ./.goreleaser.yml
6+
# TODO: we may get these from the ENV already:
7+
# GOOS, GOARCH, GOARM, GOAMD64, etc
8+
my_goos="${1:-}"
9+
my_goarch="${2:-}"
10+
my_bin="${3:-}"
11+
12+
if [ -z "${my_goos}" ] || [ -z "${my_goarch}" ] || [ -z "${my_bin}" ]; then
13+
echo "Specify goreleaser os name, arch name, and binary name"
14+
exit 1
15+
fi
16+
17+
my_zig_os=""
18+
my_zig_arch=""
19+
my_go_dist="dist/${my_bin}_${my_goos}_${my_goarch}"
20+
21+
case "$my_goos" in
22+
darwin)
23+
my_zig_os="macos"
24+
25+
;;
26+
*)
27+
my_zig_os="$my_goos"
28+
;;
29+
esac
30+
31+
case "$my_goarch" in
32+
amd64)
33+
my_zig_arch="x86_64"
34+
my_go_dist="${my_go_dist}_v1"
35+
;;
36+
arm)
37+
my_zig_arch="armv7"
38+
my_go_dist="${my_go_dist}${GOARM:-7}"
39+
;;
40+
arm64)
41+
my_zig_arch="aarch64"
42+
;;
43+
mips64)
44+
my_go_dist="${my_go_dist}_v1"
45+
;;
46+
*)
47+
my_zig_arch="$my_goarch"
48+
;;
49+
esac
50+
51+
if [ -z "$my_zig_arch" ]; then
52+
echo "${GO_ARCH} not found in the build map"
53+
exit 1
54+
fi
55+
56+
my_zig_target="${my_zig_arch}-${my_zig_os}"
57+
echo "building ${my_goos}_${my_goarch} => ${my_zig_target}"
58+
59+
rm -rf "$my_go_dist"
60+
rm -rf zig-cache/
61+
rm -rf zig-out/
62+
63+
# Build.
64+
set -x
65+
zig build -Doptimize=ReleaseFast -Dtarget="${my_zig_target}"
66+
set +x
67+
68+
# Copy all results to goreleaser dist.
69+
mkdir -p "$my_go_dist"
70+
71+
echo "copying ./zig-out/bin/* => ${my_go_dist}"
72+
cp -RPp ./zig-out/bin/* "$my_go_dist"

.goreleaser/dummy.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package main
2+
3+
func main() {}

.goreleaser/go-dummy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
set -e
3+
set -u
4+
5+
echo "Go! (no Go):"
6+
echo "$@"
7+
8+
exit 0

0 commit comments

Comments
 (0)