Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 91 additions & 6 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,109 @@ on:
pull_request:

permissions:
contents: write
contents: read

jobs:
goreleaser:
runs-on: ubuntu-latest
environment: goreleaser
goreleaser-build:
name: Build (${{ matrix.name }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-amd64
os: ubuntu-latest
rust_target: x86_64-unknown-linux-gnu
goreleaser_config: .goreleaser.linux.yaml
cgo_lib_dir: cgo-lib/x86_64-unknown-linux-gnu
- name: macos-arm64
os: macos-latest
rust_target: aarch64-apple-darwin
goreleaser_config: .goreleaser.darwin.yaml
cgo_lib_dir: cgo-lib/aarch64-apple-darwin
- name: windows-amd64
os: windows-latest
rust_target: x86_64-pc-windows-gnu
goreleaser_config: .goreleaser.windows.yaml
cgo_lib_dir: cgo-lib/x86_64-pc-windows-gnu

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Run GoReleaser (Build)

- name: Setup MSYS2 (mingw64)
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
mingw-w64-x86_64-gcc

- name: Add MinGW to PATH
if: runner.os == 'Windows'
shell: pwsh
run: |
"C:\\msys64\\mingw64\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_target }}

- name: Build libcoinset staticlib
shell: bash
if: runner.os != 'Windows'
run: |
if [ "${{ runner.os }}" = "macOS" ]; then export MACOSX_DEPLOYMENT_TARGET=12.0; fi
cargo build --release -p coinset-ffi --target "${{ matrix.rust_target }}"
mkdir -p "${{ matrix.cgo_lib_dir }}"
cp "target/${{ matrix.rust_target }}/release/libcoinset.a" "${{ matrix.cgo_lib_dir }}/"

- name: Build libcoinset staticlib (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cargo build --release -p coinset-ffi --target "${{ matrix.rust_target }}"
New-Item -ItemType Directory -Force -Path "${{ matrix.cgo_lib_dir }}" | Out-Null
Copy-Item "target\\${{ matrix.rust_target }}\\release\\libcoinset.a" "${{ matrix.cgo_lib_dir }}\\"

- name: Run GoReleaser (Build linux)
if: runner.os == 'Linux'
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: ~> v1
args: build --clean --skip=validate -f ${{ matrix.goreleaser_config }}
env:
CGO_LDFLAGS: -L${{ github.workspace }}/${{ matrix.cgo_lib_dir }}

- name: Run GoReleaser (Build macOS)
if: runner.os == 'macOS'
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: ~> v1
args: build --clean --skip=validate -f ${{ matrix.goreleaser_config }}
env:
MACOSX_DEPLOYMENT_TARGET: "12.0"
CGO_CFLAGS: -mmacosx-version-min=12.0
CGO_LDFLAGS: -mmacosx-version-min=12.0 -L${{ github.workspace }}/${{ matrix.cgo_lib_dir }}

- name: Run GoReleaser (Build windows)
if: runner.os == 'Windows'
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: ~> v1
args: build --clean --skip=validate
args: build --clean --skip=validate -f ${{ matrix.goreleaser_config }}
env:
CC: gcc
CGO_LDFLAGS: -L${{ github.workspace }}/${{ matrix.cgo_lib_dir }}
123 changes: 115 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
jobs:
tag:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.increment_version.outputs.new_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -51,38 +53,143 @@ jobs:

echo "New version: $new_version"

# Save the new version to the GitHub environment to be used in future steps
echo "new_version=$new_version" >> $GITHUB_ENV
echo "new_version=$new_version" >> "$GITHUB_OUTPUT"

- name: Create and push new tag
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
run: |
new_version=${{ env.new_version }}
new_version=${{ steps.increment_version.outputs.new_version }}

# Create a new tag
git tag "$new_version"

# Push the new tag to the remote repository
git push origin "$new_version"
release:

release_linux:
needs: tag
runs-on: ubuntu-latest
environment: goreleaser
steps:
- name: Checkout
- name: Checkout tag
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.tag.outputs.new_version }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu

- name: Build coinset-inspect staticlib
run: |
cargo build --release -p coinset-ffi --target x86_64-unknown-linux-gnu
mkdir -p cgo-lib/x86_64-unknown-linux-gnu
cp "target/x86_64-unknown-linux-gnu/release/libcoinset.a" cgo-lib/x86_64-unknown-linux-gnu/

- name: Run GoReleaser (linux)
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: ~> v1
args: release --clean -f .goreleaser.linux.yaml
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
CGO_LDFLAGS: -L${{ github.workspace }}/cgo-lib/x86_64-unknown-linux-gnu

release_macos:
needs: [tag, release_linux]
runs-on: macos-latest
environment: goreleaser
steps:
- name: Checkout tag
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.tag.outputs.new_version }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin

- name: Build coinset-inspect staticlib
run: |
MACOSX_DEPLOYMENT_TARGET=12.0 cargo build --release -p coinset-ffi --target aarch64-apple-darwin
mkdir -p cgo-lib/aarch64-apple-darwin
cp "target/aarch64-apple-darwin/release/libcoinset.a" cgo-lib/aarch64-apple-darwin/

- name: Run GoReleaser (darwin)
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: ~> v1
args: release --clean -f .goreleaser.darwin.yaml
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
CGO_CFLAGS: -mmacosx-version-min=12.0
CGO_LDFLAGS: -mmacosx-version-min=12.0 -L${{ github.workspace }}/cgo-lib/aarch64-apple-darwin
MACOSX_DEPLOYMENT_TARGET: "12.0"

release_windows:
needs: [tag, release_macos]
runs-on: windows-latest
environment: goreleaser
steps:
- name: Checkout tag
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.tag.outputs.new_version }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Run GoReleaser

- name: Setup MSYS2 (mingw64)
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
mingw-w64-x86_64-gcc
- name: Add MinGW to PATH
shell: pwsh
run: |
"C:\\msys64\\mingw64\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-gnu

- name: Build coinset-inspect staticlib
shell: msys2 {0}
run: |
cargo build --release -p coinset-ffi --target x86_64-pc-windows-gnu
mkdir -p cgo-lib/x86_64-pc-windows-gnu
cp "target/x86_64-pc-windows-gnu/release/libcoinset.a" cgo-lib/x86_64-pc-windows-gnu/

- name: Run GoReleaser (windows)
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: ~> v1
args: release --clean
args: release --clean -f .goreleaser.windows.yaml
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
CGO_LDFLAGS: -L${{ github.workspace }}/cgo-lib/x86_64-pc-windows-gnu
CC: gcc
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
dist/
.DS_Store
.DS_Store
target/
cgo-lib/
bin/
63 changes: 63 additions & 0 deletions .goreleaser.darwin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: 1

project_name: coinset

before:
hooks:
- go mod tidy
- go generate ./...

builds:
- id: coinset-darwin
main: ./cmd/coinset
env:
- CGO_ENABLED=1
- MACOSX_DEPLOYMENT_TARGET=12.0
- CGO_CFLAGS=-mmacosx-version-min=12.0
- CGO_LDFLAGS=-mmacosx-version-min=12.0
goos:
- darwin
goarch:
- arm64
ldflags:
- -s -w -X main.version={{ .Version }}

archives:
- format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

release:
github:
owner: coinset-org
name: cli

brews:
- commit_author:
name: Cameron Cooper
email: cameron@coinset.org
homepage: "https://www.coinset.org/"
description: "CLI for accessing the Chia blockchain."
license: "MIT"
repository:
owner: coinset-org
name: homebrew-cli
install: |
bin.install "coinset" => "coinset"
output = Utils.popen_read("SHELL=bash #{bin}/coinset completion bash")
(bash_completion/"coinset").write output
output = Utils.popen_read("SHELL=zsh #{bin}/coinset completion zsh")
(zsh_completion/"_coinset").write output
prefix.install_metafiles
42 changes: 42 additions & 0 deletions .goreleaser.linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: 1

project_name: coinset

before:
hooks:
- go mod tidy
- go generate ./...

builds:
- id: coinset-linux
main: ./cmd/coinset
env:
- CGO_ENABLED=1
goos:
- linux
goarch:
- amd64
ldflags:
- -s -w -X main.version={{ .Version }}

archives:
- format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

release:
github:
owner: coinset-org
name: cli
Loading