diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index d30f518..873f656 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -15,10 +15,15 @@ jobs: matrix: include: - name: linux-amd64 - os: ubuntu-latest + os: ubuntu-20.04 rust_target: x86_64-unknown-linux-gnu goreleaser_config: .goreleaser.linux.yaml cgo_lib_dir: cgo-lib/x86_64-unknown-linux-gnu + - name: linux-arm64 + os: ubuntu-20.04 + rust_target: aarch64-unknown-linux-gnu + goreleaser_config: .goreleaser.linux.arm64.yaml + cgo_lib_dir: cgo-lib/aarch64-unknown-linux-gnu - name: macos-arm64 os: macos-latest rust_target: aarch64-apple-darwin @@ -61,11 +66,21 @@ jobs: with: targets: ${{ matrix.rust_target }} + - name: Install Linux arm64 cross toolchain + if: runner.os == 'Linux' && matrix.name == 'linux-arm64' + shell: bash + run: | + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu + - name: Build libcoinset staticlib shell: bash if: runner.os != 'Windows' run: | if [ "${{ runner.os }}" = "macOS" ]; then export MACOSX_DEPLOYMENT_TARGET=12.0; fi + if [ "${{ matrix.rust_target }}" = "aarch64-unknown-linux-gnu" ]; then + export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc + 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 }}/" @@ -78,15 +93,21 @@ jobs: 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' + - name: Run GoReleaser (Build linux amd64) + if: runner.os == 'Linux' && matrix.name == 'linux-amd64' + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: ~> v1 + args: build --clean --skip=validate -f ${{ matrix.goreleaser_config }} + + - name: Run GoReleaser (Build linux arm64) + if: runner.os == 'Linux' && matrix.name == 'linux-arm64' 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' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 910ab16..0a17473 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,7 +74,7 @@ jobs: release_linux: needs: tag - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 environment: goreleaser steps: - name: Checkout tag @@ -110,7 +110,7 @@ jobs: CGO_LDFLAGS: -L${{ github.workspace }}/cgo-lib/x86_64-unknown-linux-gnu release_macos: - needs: [tag, release_linux] + needs: [tag, release_linux_arm64] runs-on: macos-latest environment: goreleaser steps: @@ -198,3 +198,198 @@ jobs: GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }} CGO_LDFLAGS: -L${{ github.workspace }}/cgo-lib/x86_64-pc-windows-gnu CC: gcc + + release_linux_arm64: + needs: [tag, release_linux] + runs-on: ubuntu-20.04 + 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: Install Linux arm64 cross toolchain + run: | + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: aarch64-unknown-linux-gnu + + - name: Build coinset-inspect staticlib (arm64) + run: | + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ + cargo build --release -p coinset-ffi --target aarch64-unknown-linux-gnu + mkdir -p cgo-lib/aarch64-unknown-linux-gnu + cp "target/aarch64-unknown-linux-gnu/release/libcoinset.a" cgo-lib/aarch64-unknown-linux-gnu/ + + - name: Run GoReleaser (linux arm64) + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: ~> v1 + args: release --clean -f .goreleaser.linux.arm64.yaml + env: + GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }} + CC: aarch64-linux-gnu-gcc + + update_homebrew_tap: + name: Update Homebrew tap + needs: [tag, release_linux, release_linux_arm64, release_macos, release_windows] + runs-on: ubuntu-latest + steps: + - name: Download release archives + shell: bash + env: + GH_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }} + TAG: ${{ needs.tag.outputs.new_version }} + run: | + set -euo pipefail + mkdir -p assets + gh release download "$TAG" --repo coinset-org/cli -p "coinset_*.tar.gz" -D assets + ls -la assets + + - name: Compute sha256 + id: sha + shell: bash + run: | + set -euo pipefail + shopt -s nullglob + mac=(assets/coinset_Darwin_arm64.tar.gz) + lin_amd=(assets/coinset_Linux_x86_64.tar.gz) + lin_arm=(assets/coinset_Linux_arm64.tar.gz) + + if [ ${#mac[@]} -eq 0 ] || [ ${#lin_amd[@]} -eq 0 ]; then + echo "missing required assets (need Darwin_arm64 + Linux_x86_64)" >&2 + exit 1 + fi + + mac_sha=$(sha256sum "${mac[0]}" | awk '{print $1}') + lin_amd_sha=$(sha256sum "${lin_amd[0]}" | awk '{print $1}') + + echo "mac_sha=$mac_sha" >> "$GITHUB_OUTPUT" + echo "lin_amd_sha=$lin_amd_sha" >> "$GITHUB_OUTPUT" + + if [ ${#lin_arm[@]} -ne 0 ]; then + lin_arm_sha=$(sha256sum "${lin_arm[0]}" | awk '{print $1}') + echo "lin_arm_sha=$lin_arm_sha" >> "$GITHUB_OUTPUT" + fi + + - name: Checkout tap repo + shell: bash + env: + GH_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }} + run: | + set -euo pipefail + gh repo clone coinset-org/homebrew-cli tap + + - name: Update formula + shell: bash + env: + TAG: ${{ needs.tag.outputs.new_version }} + MAC_SHA: ${{ steps.sha.outputs.mac_sha }} + LINUX_AMD_SHA: ${{ steps.sha.outputs.lin_amd_sha }} + LINUX_ARM_SHA: ${{ steps.sha.outputs.lin_arm_sha }} + run: | + set -euo pipefail + ver="${TAG#v}" + + cd tap + git fetch origin main + git checkout -B main origin/main + cd - + + install_block_mac=' def 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 + end' + + install_block_linux=' def 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 + end' + + linux_arm_block="" + if [ -n "${LINUX_ARM_SHA:-}" ]; then + linux_arm_block=$(cat < tap/coinset.rb <- - mingw-w64-x86_64-gcc - - - name: Add MinGW to PATH - if: ${{ inputs.upload_windows }} - shell: pwsh - run: | - "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - - - name: Setup Rust - if: ${{ inputs.upload_windows }} - uses: dtolnay/rust-toolchain@stable - with: - targets: x86_64-pc-windows-gnu - - - name: Build libcoinset staticlib - if: ${{ inputs.upload_windows }} - 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: Build artifacts (windows) - if: ${{ inputs.upload_windows }} - uses: goreleaser/goreleaser-action@v5 - with: - distribution: goreleaser - version: ~> v1 - args: build --clean --skip=validate -f .goreleaser.windows.yaml - env: - CGO_LDFLAGS: -L${{ github.workspace }}/cgo-lib/x86_64-pc-windows-gnu - CC: gcc - - - name: Upload windows archives to existing release - if: ${{ inputs.upload_windows }} - shell: bash - env: - GH_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }} - TAG: ${{ inputs.tag }} - run: | - set -euo pipefail - ls -la dist || true - # GoReleaser may place archives in dist/ subdirectories. - zips="$(ls -1 dist/*.zip dist/*/*.zip dist/*/*/*.zip 2>/dev/null || true)" - if [ -z "$zips" ]; then - echo "no zip archives found under dist/" - exit 1 - fi - echo "$zips" - gh release upload "$TAG" $zips --clobber - - recompute_checksums: - if: ${{ inputs.recompute_checksums }} - needs: [upload_windows] - runs-on: ubuntu-latest - steps: - - name: Download release assets - env: - GH_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }} - TAG: ${{ inputs.tag }} - run: | - set -euo pipefail - mkdir -p assets - cd assets - gh release download "$TAG" - ls -la - - - name: Recompute and upload checksums (clobber) - env: - GH_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }} - TAG: ${{ inputs.tag }} - run: | - set -euo pipefail - ver="${TAG#v}" - cd assets - # Only checksum the packaged archives, not the checksum file itself. - rm -f "coinset_${ver}_checksums.txt" - sha256sum *.tar.gz *.zip > "coinset_${ver}_checksums.txt" - cat "coinset_${ver}_checksums.txt" - gh release upload "$TAG" "coinset_${ver}_checksums.txt" --clobber - diff --git a/.goreleaser.darwin.yaml b/.goreleaser.darwin.yaml index 2dd5f15..b165ca2 100644 --- a/.goreleaser.darwin.yaml +++ b/.goreleaser.darwin.yaml @@ -31,6 +31,8 @@ archives: {{- else if eq .Arch "386" }}i386 {{- else }}{{ .Arch }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }} + files: + - SKILL.md checksum: name_template: >- @@ -47,21 +49,3 @@ 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 diff --git a/.goreleaser.linux.arm64.yaml b/.goreleaser.linux.arm64.yaml new file mode 100644 index 0000000..12feba0 --- /dev/null +++ b/.goreleaser.linux.arm64.yaml @@ -0,0 +1,50 @@ +version: 1 + +project_name: coinset + +before: + hooks: + - go mod tidy + - go generate ./... + +builds: + - id: coinset-linux-arm64 + main: ./cmd/coinset + env: + - CGO_ENABLED=1 + - CC=aarch64-linux-gnu-gcc + goos: + - linux + 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 }} + files: + - SKILL.md + +checksum: + name_template: >- + {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}_checksums.txt + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + +release: + github: + owner: coinset-org + name: cli + diff --git a/.goreleaser.linux.yaml b/.goreleaser.linux.yaml index b774a91..14661c2 100644 --- a/.goreleaser.linux.yaml +++ b/.goreleaser.linux.yaml @@ -28,6 +28,8 @@ archives: {{- else if eq .Arch "386" }}i386 {{- else }}{{ .Arch }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }} + files: + - SKILL.md checksum: name_template: >- diff --git a/.goreleaser.windows.yaml b/.goreleaser.windows.yaml index 0515940..f7a0a9b 100644 --- a/.goreleaser.windows.yaml +++ b/.goreleaser.windows.yaml @@ -28,6 +28,8 @@ archives: {{- else if eq .Arch "386" }}i386 {{- else }}{{ .Arch }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }} + files: + - SKILL.md checksum: name_template: >- diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 24b2a73..068a79a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -37,6 +37,8 @@ archives: {{- else if eq .Arch "386" }}i386 {{- else }}{{ .Arch }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }} + files: + - SKILL.md checksum: name_template: >- diff --git a/internal/coinsetffi/coinsetffi.go b/internal/coinsetffi/coinsetffi.go index f5174f7..2df55e4 100644 --- a/internal/coinsetffi/coinsetffi.go +++ b/internal/coinsetffi/coinsetffi.go @@ -8,6 +8,7 @@ package coinsetffi #cgo darwin,arm64 LDFLAGS: -L${SRCDIR}/../../cgo-lib/aarch64-apple-darwin #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/../../cgo-lib/x86_64-unknown-linux-gnu +#cgo linux,arm64 LDFLAGS: -L${SRCDIR}/../../cgo-lib/aarch64-unknown-linux-gnu #cgo windows,amd64 LDFLAGS: -L${SRCDIR}/../../cgo-lib/x86_64-pc-windows-gnu #cgo LDFLAGS: -lcoinset #cgo linux LDFLAGS: -lm