From 8f2d1eff9b679ef14798e2c6ef11652078095481 Mon Sep 17 00:00:00 2001 From: Justin Harms Date: Tue, 21 Jan 2025 13:18:21 -0600 Subject: [PATCH] refactor: remove commented build steps and add checksum script for binaries --- .gitea/workflows/tag-release.yaml | 20 ----------- .goreleaser.checksum.sh | 12 +++++++ .goreleaser.yaml | 59 +++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 20 deletions(-) create mode 100644 .goreleaser.checksum.sh create mode 100644 .goreleaser.yaml diff --git a/.gitea/workflows/tag-release.yaml b/.gitea/workflows/tag-release.yaml index 65a8905..6ec5b3d 100644 --- a/.gitea/workflows/tag-release.yaml +++ b/.gitea/workflows/tag-release.yaml @@ -33,26 +33,6 @@ jobs: - name: Test run: go test -race -v -shuffle=on ./... - # - name: Build for linux - # run: | - # go build -o bin/SteamCache2-${VERSION#v}-${BUILD}-${GOOS}-${GOARCH} main.go - # env: - # VERSION: ${{github.ref_name}} - # BUILD: ${{github.run_number}} - # GOOS: linux - # GOARCH: amd64 - # EXE: "" - - # - name: Build for windows - # run: | - # go build -o bin/SteamCache2-${VERSION#v}-${BUILD}-${GOOS}-${GOARCH} main.go - # env: - # VERSION: ${{github.ref_name}} - # BUILD: ${{github.run_number}} - # GOOS: windows - # GOARCH: amd64 - # EXE: ".exe" - - name: Release binaries uses: goreleaser/goreleaser-action@v6 with: diff --git a/.goreleaser.checksum.sh b/.goreleaser.checksum.sh new file mode 100644 index 0000000..a11b71d --- /dev/null +++ b/.goreleaser.checksum.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +if [ -z "$1" ]; then + echo "usage: $0 " + exit 1 +fi + +SUM=$(shasum -a 256 "$1" | cut -d' ' -f1) +BASENAME=$(basename "$1") +echo -n "${SUM} ${BASENAME}" > "$1".sha256 \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..940a3b6 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,59 @@ +before: + hooks: + - go mod tidy + +builds: +- env: + - CGO_ENABLED=0 + goos: + - linux + - windows + goarch: + - amd64 + flags: + - -trimpath + ldflags: + - -s -w -X main.Version={{ .Version }} + binary: >- + {{ .ProjectName }}- + {{- .Version }}- + {{- .Os }}- + {{- if eq .Arch "amd64" }}amd64 + {{- else if eq .Arch "amd64_v1" }}amd64 + {{- else if eq .Arch "386" }}386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}-{{ .Arm }}{{ end }} + no_unique_dist_dir: true + hooks: + post: + - cmd: xz -k -9 {{ .Path }} + dir: ./dist/ + - cmd: sh .goreleaser.checksum.sh {{ .Path }} + - cmd: sh .goreleaser.checksum.sh {{ .Path }}.xz + +archives: + - format: binary + name_template: "{{ .Binary }}" + allow_different_binary_count: true + +checksum: + name_template: 'checksums.txt' + extra_files: + - glob: ./**.xz + +force_token: gitea + +snapshot: + name_template: "{{ .Branch }}-devel" + +nightly: + name_template: "{{ .Branch }}" + +gitea_urls: + api: https://gitea.s1d3sw1ped.com/api/v1 + download: https://gitea.s1d3sw1ped.com + +release: + extra_files: + - glob: ./**.xz + - glob: ./**.xz.sha256 \ No newline at end of file