Goreleaser fix (#1003)

* use zig for goreleaser

* added test workflow

* Revert "added test workflow"

This reverts commit 9c55c5fd9e.

* added goreleaser test

* autorun goreleaser tests

* add pseudo tag for goreleaser

* added test

* added arm test

* arch test

* missing qemu setup?

* test alternate run

* test rework

* path fix?

* 18 won't run

* another test

* permission fix

* amd64 matrix

* added macos

* added windows test

* consolidate unix tests

* fix path

* fix path2

* matrix consolidation

* +x fails on macos

* fix runner

* windows fix

* Update .github/workflows/goreleaser-test.yml

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>

* Update .github/workflows/goreleaser-test.yml

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>

* Update .github/workflows/goreleaser-test.yml

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>

* Update .github/workflows/goreleaser-test.yml

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>

* auto test binaries on release

---------

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>
This commit is contained in:
Kwitsch 2023-04-26 08:57:22 +02:00 committed by GitHub
parent ed00064988
commit 1d25cca4e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 153 additions and 1 deletions

139
.github/workflows/goreleaser-test.yml vendored Normal file
View File

@ -0,0 +1,139 @@
name: GoReleaser Test
on:
push:
tags:
- v*
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build binaries with goreleaser
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
- name: Run GoReleaser check
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: check
- name: Run GoReleaser build
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: build --clean --snapshot
- name: Upload dist folder
uses: actions/upload-artifact@v3
with:
name: dist_folder
path: dist
retention-days: 1
tests:
name: Test binaries
runs-on: ${{matrix.runner}}
needs: build
strategy:
matrix:
distro: [ubuntu16.04, ubuntu18.04, ubuntu20.04, ubuntu22.04, bullseye, buster, stretch]
arch: [armv7,aarch64]
os: [linux]
runner: [ubuntu-latest]
include:
- distro: stretch
runner: ubuntu-latest
arch: armv6
os: linux
- distro: buster
runner: ubuntu-latest
arch: armv6
os: linux
- distro: bullseye
runner: ubuntu-latest
arch: armv6
os: linux
- distro: ubuntu20.04
runner: ubuntu-20.04
arch: amd64
os: linux
- distro: ubuntu22.04
runner: ubuntu-22.04
arch: amd64
os: linux
- distro: macos
runner: macos-11
arch: amd64
os: darwin
- distro: macos
runner: macos-12
arch: amd64
os: darwin
- distro: windows
runner: windows-latest
arch: amd64
os: windows
steps:
- name: Download dist folder
id: download
uses: actions/download-artifact@v3
with:
name: dist_folder
- name: Get binary path
id: get_path
if: matrix.os != 'windows'
shell: bash
run: |
archs=(["aarch64"]="arm64" ["armv6"]="arm_6" ["armv7"]="arm_7" ["amd64"]="amd64_v1")
BINPATH="${{steps.download.outputs.download-path}}/blocky_${{ matrix.os }}_${archs[ ${{ matrix.arch }} ]}/blocky"
echo "bin=${BINPATH}" >> "$GITHUB_OUTPUT"
echo "Binary path: ${BINPATH}"
- name: Enable execution
if: matrix.os != 'windows'
shell: bash
run: |
chmod +x '${{ steps.get_path.outputs.bin }}'
- name: Test binary on ${{ matrix.arch }}
if: matrix.arch != 'amd64'
uses: uraimo/run-on-arch-action@v2
with:
distro: ${{ matrix.distro }}
arch: ${{ matrix.arch }}
dockerRunArgs: |
--volume "${{steps.download.outputs.download-path}}:${{steps.download.outputs.download-path}}"
shell: /bin/sh
run: |
'${{ steps.get_path.outputs.bin }}' version
- name: Test binary on amd64
if: matrix.arch == 'amd64' && matrix.os != 'windows'
shell: bash
run: |
'${{ steps.get_path.outputs.bin }}' version
- name: Test windows binary
if: matrix.os == 'windows'
shell: cmd
run: |
${{steps.download.outputs.download-path}}\blocky_windows_amd64_v1\blocky.exe version

View File

@ -80,6 +80,9 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:

View File

@ -3,6 +3,8 @@ project_name: blocky
before:
hooks:
- go mod tidy
- go install github.com/dosgo/zigtool/zigcc@latest
- go install github.com/dosgo/zigtool/zigcpp@latest
builds:
- goos:
- linux
@ -24,7 +26,15 @@ builds:
- goos: windows
goarch: arm64
ldflags:
- -w -s -X github.com/0xERR0R/blocky/util.Version=v{{.Version}} -X github.com/0xERR0R/blocky/util.BuildTime={{time "20060102-150405"}}
- -w
- -s
- -X github.com/0xERR0R/blocky/util.Version=v{{.Version}}
- -X github.com/0xERR0R/blocky/util.BuildTime={{time "20060102-150405"}}
- -X github.com/0xERR0R/blocky/util.Architecture={{.Arch}}{{.Arm}}
env:
- CGO_ENABLED=0
- CC=zigcc
- CXX=zigcpp
release:
draft: true
archives: