ci: fix host-mode docker go invocation
All checks were successful
CI / Test, vet, build (push) Successful in 51s
All checks were successful
CI / Test, vet, build (push) Successful in 51s
This commit is contained in:
parent
4ab64d501e
commit
71c0d89102
3 changed files with 39 additions and 60 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
# Host-mode runner: Go via official image.
|
|
||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
|
@ -22,20 +21,11 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
case "$GITHUB_WORKSPACE" in
|
case "$GITHUB_WORKSPACE" in
|
||||||
/data/*) HOST_WORKSPACE="/opt/forgejo-runner/data${GITHUB_WORKSPACE#/data}" ;;
|
/data/*) HOST_WS="/opt/forgejo-runner/data${GITHUB_WORKSPACE#/data}" ;;
|
||||||
*) HOST_WORKSPACE="$GITHUB_WORKSPACE" ;;
|
*) HOST_WS="$GITHUB_WORKSPACE" ;;
|
||||||
esac
|
esac
|
||||||
test -f "$GITHUB_WORKSPACE/go.mod"
|
test -f "$GITHUB_WORKSPACE/go.mod"
|
||||||
docker run --rm --network host \
|
docker run --rm --network host \
|
||||||
--volume "$HOST_WORKSPACE:/src" \
|
-v "${HOST_WS}:/src" -w /src -e CGO_ENABLED=0 \
|
||||||
--workdir /src \
|
|
||||||
-e CGO_ENABLED=0 \
|
|
||||||
golang:1.25-bookworm \
|
golang:1.25-bookworm \
|
||||||
bash -lc '
|
sh -c "go version && go test -count=1 ./... && go vet ./... && make build && ls -la bin/tarakan"
|
||||||
set -euo pipefail
|
|
||||||
go version
|
|
||||||
go test -count=1 ./...
|
|
||||||
go vet ./...
|
|
||||||
make build
|
|
||||||
ls -la bin/tarakan
|
|
||||||
'
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
# Multi-arch binaries + Forgejo release on tags v*.
|
|
||||||
name: Release
|
name: Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
|
@ -22,56 +21,17 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
case "$GITHUB_WORKSPACE" in
|
case "$GITHUB_WORKSPACE" in
|
||||||
/data/*) HOST_WORKSPACE="/opt/forgejo-runner/data${GITHUB_WORKSPACE#/data}" ;;
|
/data/*) HOST_WS="/opt/forgejo-runner/data${GITHUB_WORKSPACE#/data}" ;;
|
||||||
*) HOST_WORKSPACE="$GITHUB_WORKSPACE" ;;
|
*) HOST_WS="$GITHUB_WORKSPACE" ;;
|
||||||
esac
|
esac
|
||||||
version="${GITHUB_REF_NAME//\//-}"
|
version="${GITHUB_REF_NAME//\//-}"
|
||||||
|
chmod +x scripts/ci-release.sh
|
||||||
docker run --rm --network host \
|
docker run --rm --network host \
|
||||||
--volume "$HOST_WORKSPACE:/src" \
|
-v "${HOST_WS}:/src" -w /src \
|
||||||
--workdir /src \
|
|
||||||
-e CGO_ENABLED=0 \
|
-e CGO_ENABLED=0 \
|
||||||
-e VERSION="$version" \
|
-e VERSION="$version" \
|
||||||
golang:1.25-bookworm \
|
golang:1.25-bookworm \
|
||||||
bash -lc '
|
sh -c "apt-get update -qq && apt-get install -y -qq zip >/dev/null && go test -count=1 ./... && go vet ./... && ./scripts/ci-release.sh"
|
||||||
set -euo pipefail
|
|
||||||
apt-get update -qq
|
|
||||||
apt-get install -y -qq zip >/dev/null
|
|
||||||
go test -count=1 ./...
|
|
||||||
go vet ./...
|
|
||||||
|
|
||||||
version="${VERSION}"
|
|
||||||
mkdir -p dist staging
|
|
||||||
targets=(
|
|
||||||
"linux amd64"
|
|
||||||
"linux arm64"
|
|
||||||
"darwin amd64"
|
|
||||||
"darwin arm64"
|
|
||||||
"windows amd64"
|
|
||||||
"windows arm64"
|
|
||||||
)
|
|
||||||
for target in "${targets[@]}"; do
|
|
||||||
read -r goos goarch <<< "${target}"
|
|
||||||
archive="tarakan_${version}_${goos}_${goarch}"
|
|
||||||
package="staging/${archive}"
|
|
||||||
mkdir -p "${package}"
|
|
||||||
binary="tarakan"
|
|
||||||
if [[ "${goos}" == "windows" ]]; then
|
|
||||||
binary="tarakan.exe"
|
|
||||||
fi
|
|
||||||
version_ld="${version#v}"
|
|
||||||
CGO_ENABLED=0 GOOS="${goos}" GOARCH="${goarch}" \
|
|
||||||
go build -trimpath -ldflags="-s -w -X main.version=${version_ld}" \
|
|
||||||
-o "${package}/${binary}" ./cmd/tarakan
|
|
||||||
cp LICENSE "${package}/"
|
|
||||||
if [[ "${goos}" == "windows" ]]; then
|
|
||||||
(cd staging && zip -q -r "../dist/${archive}.zip" "${archive}")
|
|
||||||
else
|
|
||||||
tar -C staging -czf "dist/${archive}.tar.gz" "${archive}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
(cd dist && sha256sum tarakan_* > checksums.txt)
|
|
||||||
ls -la dist/
|
|
||||||
'
|
|
||||||
|
|
||||||
- name: Publish Forgejo release
|
- name: Publish Forgejo release
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
|
@ -88,7 +48,7 @@ jobs:
|
||||||
-d "$body" "$api" || true)
|
-d "$body" "$api" || true)
|
||||||
code=$(printf '%s' "$resp" | tail -n1)
|
code=$(printf '%s' "$resp" | tail -n1)
|
||||||
payload=$(printf '%s' "$resp" | sed '$d')
|
payload=$(printf '%s' "$resp" | sed '$d')
|
||||||
if [[ "$code" != "201" && "$code" != "200" ]]; then
|
if [ "$code" != "201" ] && [ "$code" != "200" ]; then
|
||||||
payload=$(curl -sS -H "Authorization: token ${TOKEN}" \
|
payload=$(curl -sS -H "Authorization: token ${TOKEN}" \
|
||||||
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/tags/${tag}")
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/tags/${tag}")
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
29
scripts/ci-release.sh
Executable file
29
scripts/ci-release.sh
Executable file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Build multi-arch release archives for tarakan-client. Used by Forgejo Actions.
|
||||||
|
set -eu
|
||||||
|
version="${VERSION:-dev}"
|
||||||
|
mkdir -p dist staging
|
||||||
|
targets="linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64"
|
||||||
|
for target in $targets; do
|
||||||
|
goos=${target%/*}
|
||||||
|
goarch=${target#*/}
|
||||||
|
archive="tarakan_${version}_${goos}_${goarch}"
|
||||||
|
package="staging/${archive}"
|
||||||
|
mkdir -p "${package}"
|
||||||
|
binary="tarakan"
|
||||||
|
if [ "$goos" = "windows" ]; then
|
||||||
|
binary="tarakan.exe"
|
||||||
|
fi
|
||||||
|
version_ld=${version#v}
|
||||||
|
CGO_ENABLED=0 GOOS="$goos" GOARCH="$goarch" \
|
||||||
|
go build -trimpath -ldflags="-s -w -X main.version=${version_ld}" \
|
||||||
|
-o "${package}/${binary}" ./cmd/tarakan
|
||||||
|
cp LICENSE "${package}/"
|
||||||
|
if [ "$goos" = "windows" ]; then
|
||||||
|
(cd staging && zip -q -r "../dist/${archive}.zip" "${archive}")
|
||||||
|
else
|
||||||
|
tar -C staging -czf "dist/${archive}.tar.gz" "${archive}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
(cd dist && sha256sum tarakan_* > checksums.txt)
|
||||||
|
ls -la dist/
|
||||||
Loading…
Add table
Add a link
Reference in a new issue