mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 20:01:17 +00:00
Compare commits
2 commits
01390583b2
...
12f16db1ac
Author | SHA1 | Date | |
---|---|---|---|
12f16db1ac | |||
7da8b9ffa4 |
3 changed files with 73 additions and 11 deletions
18
.github/workflows/test-and-build.yml
vendored
18
.github/workflows/test-and-build.yml
vendored
|
@ -36,6 +36,7 @@ jobs:
|
||||||
curl \
|
curl \
|
||||||
diffutils \
|
diffutils \
|
||||||
git \
|
git \
|
||||||
|
git-lfs \
|
||||||
go \
|
go \
|
||||||
golangci-lint-bin \
|
golangci-lint-bin \
|
||||||
make \
|
make \
|
||||||
|
@ -47,22 +48,21 @@ jobs:
|
||||||
which \
|
which \
|
||||||
zip
|
zip
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
lfs: true
|
||||||
|
show-progress: false
|
||||||
|
|
||||||
- name: Marking workdir safe
|
- name: Marking workdir safe and fetch tags
|
||||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
run: |
|
||||||
|
git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||||
|
git fetch --tags
|
||||||
|
|
||||||
- name: Lint and test code
|
- name: Lint and test code
|
||||||
run: make lint test frontend_lint
|
run: make lint test frontend_lint
|
||||||
|
|
||||||
- name: Build release
|
- name: Build release
|
||||||
run: make publish
|
run: make publish
|
||||||
env:
|
|
||||||
FORCE_SKIP_UPLOAD: 'true'
|
|
||||||
MOD_MODE: readonly
|
|
||||||
NODE_ENV: production
|
|
||||||
NO_TESTS: 'true'
|
|
||||||
PACKAGES: '.'
|
|
||||||
|
|
||||||
- name: Execute Trivy scan
|
- name: Execute Trivy scan
|
||||||
run: make trivy
|
run: make trivy
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -13,8 +13,7 @@ lint:
|
||||||
golangci-lint run
|
golangci-lint run
|
||||||
|
|
||||||
publish: frontend_prod
|
publish: frontend_prod
|
||||||
curl -sSLo golang.sh https://raw.githubusercontent.com/Luzifer/github-publish/master/golang.sh
|
bash ./ci/build.sh
|
||||||
bash golang.sh
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test -cover -v ./...
|
go test -cover -v ./...
|
||||||
|
|
63
ci/build.sh
Normal file
63
ci/build.sh
Normal file
|
@ -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 Bot..."
|
||||||
|
go_package_all "twitch-bot" "."
|
||||||
|
|
||||||
|
log "Generating SHA256SUMS file..."
|
||||||
|
(cd "${builddir}" && sha256sum * | tee SHA256SUMS)
|
Loading…
Reference in a new issue