Background

Having grown up with the rise of entertainment software I have a pretty long history with gaming. As part of that, I’ve flirted off and on with making games. This takes the form of some general messing around. I’ll do that until something else catches my scattered attention.

I’ve been thinking since the beginning of the year that I want to try to cobble something together. I’d be a good reason for me to blog and gives me a nice excuse to continue messing around with Go and SDL2. Why Go? Because it’s portable, I can compile to Windows, macOS, and Linux with ease.


The Plan

I’m planning on trying to release something at the end of every month. It will not be a complete game. Only little bits and pieces that we can put together into a whole at some point.

Each piece will get its own page over at itch.io.

As part of this, I want to first tackle a release process. I’ve decided to do using a makefile. Each project will have the same base layout so I’ll write a small helper script (in Go) to help with that.

I imagine I’ll end up with something very like the following. It’s pretty close to what I already have. macOS and Windows will need to separate build but the Linux build can happen in Docker. That won’t come until the second (or third) release. If I do add it, new builds of older releases get updated.

The layout will look a bit like the following.

sdl2-test00
│   main.go
|   makefile
│   README.md
|
└───assets
│   │   background.png
└───buildfiles
|   │   README.md
|
└───macos_buildfiles
|   │   Info.plist
|
└───windows_buildfiles
    |   SDL2.dll

makefile

Below you can see an example of my current makefile. It’s not quite done but it’s getting close enough. I need to do some tweaking to pull the main BINARY_NAME from the current directory. To keep this post short I’ve trimmed out a bit and only left the macOS related.

GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
ITCH_ACCOUNT=$(HANDLE)
ITCH_GAME_URI=$(notdir $(shell pwd))
BINARY_VER ?= $(shell git tag)
BINARY_NAME=sdl2-test00
BINARY_DARWIN=$(BINARY_NAME)
RELEASE_DARWIN=release-darwin

all: clean deps build

build:
  @echo 💻 Building
  @$(GOBUILD) -o $(BINARY_NAME) -v

clean:
  @echo 🧹 Cleaning up
  @$(GOCLEAN)
  @echo ⚠️ Removing binaries
  @rm -f $(BINARY_NAME)
  @rm -f $(BINARY_LINUX)
  @rm -f $(BINARY_WIN)
# Danger ;)
  @echo ⚠️ Removing release directories
  @rm -rf ./$(RELEASE_WIN)
  @rm -rf ./$(RELEASE_LINUX)
  @rm -rf ./$(RELEASE_DARWIN)
  @echo 🧹 Done cleaning

release-darwin:
  @echo 💻 Creating $(RELEASE_DARWIN)/$(BINARY_DARWIN)-$(BINARY_VER).app folders
  @mkdir -p $(RELEASE_DARWIN)/$(BINARY_DARWIN)-$(BINARY_VER).app/Contents/MacOS
  @mkdir -p $(RELEASE_DARWIN)/$(BINARY_DARWIN)-$(BINARY_VER).app/Contents/PlugIns
  @mkdir -p $(RELEASE_DARWIN)/$(BINARY_DARWIN)-$(BINARY_VER).app/Contents/Resources

  @echo 💻 Building $(RELEASE_DARWIN)/$(BINARY_DARWIN)-$(BINARY_VER)
  @GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags="-s -w" -o $(RELEASE_DARWIN)/$(BINARY_DARWIN)-$(BINARY_VER).app/Contents/MacOS/$(BINARY_DARWIN)-$(BINARY_VER) -v

  @echo 💻 Copying assets
  @cp -r ./assets $(RELEASE_DARWIN)/$(BINARY_DARWIN)-$(BINARY_VER).app/Contents/MacOS/
  @cp ./macos_buildfiles/Info.plist $(RELEASE_DARWIN)/$(BINARY_DARWIN)-$(BINARY_VER).app/
  @# cp -r ./macos_buildfiles/icons.icns $(RELEASE_DARWIN)/$(BINARY_DARWIN)-$(BINARY_VER).app/Contents/Resources/$(BINARY_DARWIN)-$(BINARY_VER)

  @echo 💻 Uploading to itch.io
  @butler push $(RELEASE_DARWIN) $(ITCH_ACCOUNT)/$(ITCH_GAME_URI):mac

The idea is to make building and releasing easier up front. To that end, I’ve worked on building out putting together a .app package which can then be immediately released to itch.io. I did my test release last night. It can be found over on itch.io.


Enjoy this post?
How about buying me a coffee?