Skip to content

Commit

Permalink
Windows executables from CI/CD?
Browse files Browse the repository at this point in the history
  • Loading branch information
Neale Pickett committed Dec 6, 2023
1 parent 4710b69 commit fa049db
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
__debug_bin
*.tar.gz
transpile
mothd
mothd
winmoth.*.zip
11 changes: 11 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
stages:
- test
- build
- push

Run unit tests:
Expand Down Expand Up @@ -37,6 +38,16 @@ Generage coverage XML:
coverage_format: cobertura
path: coverage.xml

build-win:
stage: build
image: *goimage
needs: ["Run unit tests"]
script:
- ./build/package/winbuild.sh
artifacts:
paths:
- build/package/winmoth.*.zip

push:
stage: push
needs: ["Run unit tests"]
Expand Down
3 changes: 2 additions & 1 deletion build/package/Containerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM golang:1 AS builder
ARG GO_VERSION=1.21-alpine
FROM docker.io/library/golang:${GO_VERSION} AS builder
COPY go.* /src/
COPY pkg /src/pkg/
COPY cmd /src/cmd/
Expand Down
39 changes: 27 additions & 12 deletions build/package/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,34 @@

set -e

cd $(dirname $0)/../..
cd $(dirname $0)
base=../..

PODMAN=$(command -v podman || echo docker)
VERSION=$(cat CHANGELOG.md | awk -F '[][]' '/^## \[/ {print $2; exit}')
VERSION=$(cat $base/CHANGELOG.md | awk -F '[][]' '/^## \[/ {print $2; exit}')
GO_VERSION=$(cat $base/go.mod | sed -n 's/^go //p')

for target in moth; do
tag=dirtbags/$target:$VERSION
echo "==== Building $tag"
$PODMAN build \
--build-arg http_proxy --build-arg https_proxy --build-arg no_proxy \
--tag $tag \
--target $target \
-f build/package/Containerfile .
done
(
zipfile=winmoth.$VERSION.zip
echo "=== Building $zipfile"
mkdir -p winmoth winmoth/state winmoth/puzzles winmoth/mothballs
echo devel > winmoth/state/teamids.txt
cp moth-devel.bat winmoth
cp -a $base/theme winmoth
(
cd winmoth
GOOS=windows GOARCH=amd64 go build ../$base/cmd/mothd/...
)
zip -r $zipfile winmoth

rm -rf winmoth
)

tag=dirtbags/moth:$VERSION
echo "==== Building $tag"
docker build \
--build-arg GO_VERSION=$GO_VERSION \
--build-arg http_proxy --build-arg https_proxy --build-arg no_proxy \
--tag $tag \
-f Containerfile $base

exit 0
1 change: 1 addition & 0 deletions build/package/moth-devel.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.\mothd.exe -puzzles puzzles
24 changes: 24 additions & 0 deletions build/package/winbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#! /bin/sh

set -e

cd $(dirname $0)
base=../..

VERSION=$(cat $base/CHANGELOG.md | awk -F '[][]' '/^## \[/ {print $2; exit}')

(
zipfile=winmoth.$VERSION.zip
echo "=== Building $zipfile"
mkdir -p winmoth winmoth/state winmoth/puzzles winmoth/mothballs
echo devel > winmoth/state/teamids.txt
cp moth-devel.bat winmoth
cp -a $base/theme winmoth
(
cd winmoth
GOOS=windows GOARCH=amd64 go build ../$base/cmd/mothd/...
)
zip -r $zipfile winmoth

rm -rf winmoth
)
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/dirtbags/moth/v4

go 1.13
go 1.21

require (
github.com/kr/text v0.2.0 // indirect
Expand Down

0 comments on commit fa049db

Please sign in to comment.