Skip to content

Commit

Permalink
release workflow (#74)
Browse files Browse the repository at this point in the history
* feat: release workflow

* fix: sed expr, shellcheck errors, correct branch
  • Loading branch information
winny- authored Sep 12, 2024
1 parent d78acac commit 94345e4
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 2 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Each release is automatically published to [bismuthsoft.github.io/super_rogue][w

### Pre-built for Linux, Windows

See our [releases page](https://github.com/bismuthsoft/super_rogue/releases) for downloads targeting Windows, Linux, and more!
See our [releases page][releases] for downloads targeting Windows, Linux, and
more!

*(Mac users, please consider downloading the `.love` file or playing [the web version][web].)*

Expand Down Expand Up @@ -73,3 +74,12 @@ To run tests and run the desktop version of the game upon code change, try this
```
find src | entr -r sh -c 'nix run .#super_rogue.test && nix run .#super_rogue.desktop'
```
### Release checklist

1. Run `./scripts/release`. Fill out the blanks.
2. Verify the [Release GitHub Action][github release action] completed.
3. Update the newly crafted [release entry][releases] with a description of changes.

[github release action]: https://github.com/bismuthsoft/super_rogue/actions/workflows/release.yml

[releases]: https://github.com/bismuthsoft/super_rogue/releases
84 changes: 84 additions & 0 deletions scripts/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
set -eu -o pipefail

# TODO: Work without admin / bypass push rules

DEFAULT_BRANCH=master

matchver() {
# shellcheck disable=SC2319
[[ $1 =~ v([0-9]+)\.([0-9]+)\.([0-9]+) ]] || return $?
patch=${BASH_REMATCH[3]}
minor=${BASH_REMATCH[2]}
major=${BASH_REMATCH[1]}
}

fmtver() {
local maj min pat
maj=$1
min=$2
pat=$3
printf 'v%s.%s.%s' "$maj" "$min" "$pat"
}

prompt() {
read -re -p "$* "
echo "$REPLY"
}

panic() {
printf 'ERR %s\n' >&2 "$*"
exit 1
}

################################################################

if [[ $(git status -s) ]]; then
panic 'Dirty work tree'
fi

if [[ $(git branch --show-current) != "$DEFAULT_BRANCH" ]]; then
panic "Please run git switch $DEFAULT_BRANCH"
fi

if ! latest=$(git describe --tags --match="v[0-9]*" --abbrev=0 HEAD); then
panic 'Could not detect a recent version tag!'
fi

if ! matchver "$latest"; then
panic 'Could not extract version components'
fi

if ! ver=$(prompt 'Latest version is' "$(fmtver "$major" "$minor" "$patch")." ' Next version?'); then
panic 'Could not get next version'
fi

if ! matchver "$ver"; then
panic 'Invalid version inputted.'
fi


if ! [[ $latest < $ver ]]; then
panic "$ver < $latest! Need a version that lexicographically sorts after $latest."
fi

if ! name=$(prompt '(Nick)name for this release. Make it fun!'); then
panic 'Could not get name'
fi

sed -i''\
-e "s,:version \".*\",:version \"$ver\"," \
-e "s,:name \".*\",:name \"$name\"," \
src/version.fnl

git add src/version.fnl
git commit -m "release: $ver - $name"
git tag "$ver"

prompt 'Everything look right? Type Control-c to cancel.'

git push origin "$DEFAULT_BRANCH"
git push origin "$ver"

echo 'Check https://github.com/bismuthsoft/super_rogue/actions/workflows/release.yml'
echo "Then edit https://github.com/bismuthsoft/super_rogue/releases/tag/$ver"
3 changes: 2 additions & 1 deletion src/scenes/menu.fnl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(import-macros {: vec2-op} :geom-macros)
(local version (require :version))
(local geom (require :geom))
(local util (require :util))
(local draw (require :draw))
Expand All @@ -20,7 +21,7 @@

(fn menu.draw [s]
(love.graphics.setColor [1 1 1 1])
(love.graphics.print "Super Rogue 0.1.0 - JamFix" 300 100)
(love.graphics.print (string.format "Super Rogue %s - %s" version.version version.name) 300 100)
(love.graphics.setColor [.7 .7 .7 1])
(love.graphics.print "By 44100hz & winny" 300 150)
(when (not= 0 (% (lume.round s.time) 5))
Expand Down
2 changes: 2 additions & 0 deletions src/version.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{:version "0.1.0"
:name "JamFix"}

0 comments on commit 94345e4

Please sign in to comment.