diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 74333b3..820eb6c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -113,3 +113,14 @@ jobs: - uses: actions/download-artifact@v3 with: path: artifacts + + # Goreleaser + - name: Set up Go + uses: actions/setup-go@v4 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + # Run goreleaser and ignore non-committed files (downloaded artifacts) + args: release --clean --skip=validate diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..6cacdb5 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,26 @@ +project_name: wstunnel +builds: + - main: goreleaser.go + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + binary: example + ignore: + - goos: windows + goarch: arm64 + hooks: + post: + - ./.goreleaser_hook.sh {{ .Arch }} {{ .Os }} {{ .ProjectName }} +checksum: + name_template: "checksums.txt" +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + diff --git a/.goreleaser_hook.sh b/.goreleaser_hook.sh new file mode 100755 index 0000000..11ef8b6 --- /dev/null +++ b/.goreleaser_hook.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +go_arch=$1 +go_os=$2 +project_name=$3 + +# Make Go -> Rust arch/os mapping +case $go_arch in + amd64) rust_arch='x86_64' ;; + arm64) rust_arch='aarch64' ;; + *) echo "unknown arch: $go_arch" && exit 1 ;; +esac +case $go_os in + linux) rust_os='linux' ;; + darwin) rust_os='apple-darwin' ;; + windows) rust_os='windows' ;; + *) echo "unknown os: $go_os" && exit 1 ;; +esac + +# Find artifacts and uncompress in the corresponding directory +find artifacts -type f -name "*${rust_arch}*${rust_os}*" -exec unzip -d dist/${project_name}_${go_os}_${go_arch} {} \; + diff --git a/goreleaser.go b/goreleaser.go new file mode 100644 index 0000000..73c71de --- /dev/null +++ b/goreleaser.go @@ -0,0 +1,3 @@ +package main + func main() { +}