From 7c1093f5bd511829b8cde796eac9d70ccb391188 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 30 Nov 2024 12:31:20 +0100 Subject: [PATCH] CI: Remove remains of old publishing Signed-off-by: Knut Ahlers --- .github/workflows/test-and-build.yml | 30 ++++--------- Makefile | 4 +- ci/build.sh | 63 ++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 25 deletions(-) create mode 100644 ci/build.sh diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index 6b5afe0..8ce3c4c 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -16,7 +16,7 @@ jobs: shell: bash container: - image: luzifer/archlinux + image: luzifer/gh-arch-env env: CGO_ENABLED: 0 GOPATH: /go @@ -24,32 +24,18 @@ jobs: runs-on: ubuntu-latest steps: - - name: Enable custom AUR package repo - run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf - - - name: Install required packages - run: | - pacman -Syy --noconfirm \ - awk \ - git \ - go \ - golangci-lint-bin \ - make \ - tar \ - zip - - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Marking workdir safe run: git config --global --add safe.directory /__w/staticmap/staticmap + - name: 'Lint and test code' + run: | + go test -cover -v ./... + golangci-lint run ./... + - name: Build release - run: make publish - env: - FORCE_SKIP_UPLOAD: 'true' - MOD_MODE: readonly - NO_TESTS: 'true' - PACKAGES: '.' + run: bash ci/build.sh - name: Extract changelog run: 'awk "/^#/ && ++c==2{exit}; /^#/f" "History.md" | tail -n +2 >release_changelog.md' diff --git a/Makefile b/Makefile index dc8b43e..e277a49 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,4 @@ -publish: - curl -sSLo golang.sh https://raw.githubusercontent.com/Luzifer/github-publish/master/golang.sh - bash golang.sh +default: update_example_post: curl -X POST --data-binary @example/postmap.json -o example/postmap.png localhost:5000/map.png diff --git a/ci/build.sh b/ci/build.sh new file mode 100644 index 0000000..f2ae461 --- /dev/null +++ b/ci/build.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +set -euo pipefail + +osarch=( + darwin/amd64 + darwin/arm64 + linux/amd64 + linux/arm + linux/arm64 + windows/amd64 +) + +function go_package() { + cd "${4}" + + local outname="${3}" + [[ $1 == windows ]] && outname="${3}.exe" + + log "=> Building ${3} for ${1}/${2}..." + CGO_ENABLED=0 GOARCH=$2 GOOS=$1 go build \ + -ldflags "-s -w -X main.version=${version}" \ + -mod=readonly \ + -trimpath \ + -o "${outname}" + + if [[ $1 == linux ]]; then + log "=> Packging ${3} as ${3}_${1}_${2}.tgz..." + tar -czf "${builddir}/${3}_${1}_${2}.tgz" "${outname}" + else + log "=> Packging ${3} as ${3}_${1}_${2}.zip..." + zip "${builddir}/${3}_${1}_${2}.zip" "${outname}" + fi + + rm "${outname}" +} + +function go_package_all() { + for oa in "${osarch[@]}"; do + local os=$(cut -d / -f 1 <<<"${oa}") + local arch=$(cut -d / -f 2 <<<"${oa}") + (go_package "${os}" "${arch}" "${1}" "${2}") + done +} + +function log() { + echo "[$(date +%H:%M:%S)] $@" >&2 +} + +root=$(pwd) +builddir="${root}/.build" +version="$(git describe --tags --always || echo dev)" + +log "Building version ${version}..." + +log "Resetting output directory..." +rm -rf "${builddir}" +mkdir -p "${builddir}" + +log "Building Server..." +go_package_all "staticmap" "." + +log "Generating SHA256SUMS file..." +(cd "${builddir}" && sha256sum * | tee SHA256SUMS)