Skip to content

Commit

Permalink
Merge pull request #15 from startersclan/chore/release-1.8.0
Browse files Browse the repository at this point in the history
Chore: Release 1.8.0
  • Loading branch information
leojonathanoh committed Oct 30, 2023
2 parents 7a022e5 + 473d7ad commit c8526ea
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 4 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,31 @@ a PHP frontend.
`web` image (See [./web/config.php](./web/config.php) for supported environment variables):

```sh
docker run --rm -it -e DB_ADDR=db -e DB_NAME=hlstatsxce -e DB_USER=hlstatsxce -e DB_PASS=hlstatsxce -p 80:80 startersclan/hlstatsx-community-edition:1.7.0-web
docker run --rm -it -e DB_ADDR=db -e DB_NAME=hlstatsxce -e DB_USER=hlstatsxce -e DB_PASS=hlstatsxce -p 80:80 startersclan/hlstatsx-community-edition:1.8.0-web
```

`daemon` image:

```sh
# Use --help for usage
docker run --rm -it -p 27500:27500/udp startersclan/hlstatsx-community-edition:1.7.0-daemon --db-host=db:3306 --db-name=hlstatsxce --db-username=hlstatsxce --db-password=hlstatsxce #--help
docker run --rm -it -p 27500:27500/udp startersclan/hlstatsx-community-edition:1.8.0-daemon --db-host=db:3306 --db-name=hlstatsxce --db-username=hlstatsxce --db-password=hlstatsxce #--help
```

The tag convention is `<version>-<service>` or `<version>-<sha>-<service>`. For instance, for release `v1.2.3` on sha `0abcdef`:

- `web` image tags: `1-web`, `1.2-web`, `1.2.3-web`, `1-0abcdef-web`, `1.2-0abcdef-web`, `1.2.3-0abcdef-web`
- `daemon` image tags: `1-daemon`, `1.2-daemon`, `1.2.3-daemon`, `1-0abcdef-daemon`, `1.2-0abcdef-daemon`, `1.2.3-0abcdef-daemon`

### Upgrading (docker)

1. To be safe, stop the `daemon`.
1. Upgrade `web`:
1. Bump the docker image to the latest tag
1. Login to the `web` Admin Panel, there should be a notice to upgrade the DB. Click the `HLX:CE Database Updater` button to begin upgrading. The upgrade may take a while.
1. After a few moments, you should see messages that the DB was successfully upgraded
1. Upgrade `daemon`:
1. Simply bump the docker image to the latest tag

## Development

```sh
Expand Down
51 changes: 51 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh
# This script makes it easy to create a new release.
# It requires git, which is only used to detect the previous tag.

set -eu

TAG=${1:-}
COMMENT=${2:-}
if [ -z "$TAG" ]; then
echo "Please specify a tag as a first argument. E.g. v1.2.3"
exit 1
fi
TAG_REGEX='^v?[0-9]+\.[0-9]+\.[0-9]+$'
if ! echo "$TAG" | grep -E "$TAG_REGEX" > /dev/null; then
echo "Tag does not match regex: $TAG_REGEX"
exit 1
fi
TAG_PREV=$( git --no-pager tag -l --sort=-version:refname | head -n1 )
if ! echo "$TAG_PREV" | grep -E "$TAG_REGEX" > /dev/null; then
echo "Previous git tag is invalid. It does not match regex: $TAG_REGEX"
exit 1
fi

VERSION=$( echo "$TAG" | sed 's/^v//' )
VERSION_PREV=$( echo "$TAG_PREV" | sed 's/^v//' )
DBVERSION_PREV=$( ls web/updater | grep -E '^[0-9]+\.php$' | sort -n | tail -n1 | cut -d '.' -f1 )
DBVERSION=$(( $DBVERSION_PREV + 1 ))

# Bump version in docs, .php, and .sql files
sed -i "s/$VERSION_PREV/$VERSION/" README.md
sed -i "s/^SET @DBVERSION=.*/SET @DBVERSION=\"$DBVERSION\";/" sql/install.sql
sed -i "s/^SET @VERSION=.*/SET @VERSION=\"$VERSION\";/" sql/install.sql
echo "Creating web/updater/$DBVERSION.php"
cat - > web/updater/$DBVERSION.php <<EOF
<?php
if ( !defined('IN_UPDATER') )
{
die('Do not access this file directly.');
}
\$dbversion = $DBVERSION;
\$version = "$VERSION";
// Perform database schema update notification
print "Updating database and verion schema numbers.<br />";
\$db->query("UPDATE hlstats_Options SET \`value\` = '\$version' WHERE \`keyname\` = 'version'");
\$db->query("UPDATE hlstats_Options SET \`value\` = '\$dbversion' WHERE \`keyname\` = 'dbversion'");
?>
EOF

echo "Done bumping version to $TAG in all files"
4 changes: 2 additions & 2 deletions sql/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

-- This file is only needed for new installations.

SET @DBVERSION="80";
SET @VERSION="1.7.0";
SET @DBVERSION="81";
SET @VERSION="1.8.0";

-- --------------------------------------------------------

Expand Down
15 changes: 15 additions & 0 deletions web/updater/79.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
// Dummy upgrade file. Changes in ./sql/migrations/*.sql should have been added here
if ( !defined('IN_UPDATER') )
{
die('Do not access this file directly.');
}

$dbversion = 79;
$version = "1.7.0";

// Perform database schema update notification
print "Updating database and verion schema numbers.<br />";
$db->query("UPDATE hlstats_Options SET `value` = '$version' WHERE `keyname` = 'version'");
$db->query("UPDATE hlstats_Options SET `value` = '$dbversion' WHERE `keyname` = 'dbversion'");
?>
15 changes: 15 additions & 0 deletions web/updater/80.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
// Dummy upgrade file. Changes in ./sql/migrations/*.sql should have been added here
if ( !defined('IN_UPDATER') )
{
die('Do not access this file directly.');
}

$dbversion = 80;
$version = "1.7.0";

// Perform database schema update notification
print "Updating database and verion schema numbers.<br />";
$db->query("UPDATE hlstats_Options SET `value` = '$version' WHERE `keyname` = 'version'");
$db->query("UPDATE hlstats_Options SET `value` = '$dbversion' WHERE `keyname` = 'dbversion'");
?>
14 changes: 14 additions & 0 deletions web/updater/81.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
if ( !defined('IN_UPDATER') )
{
die('Do not access this file directly.');
}

$dbversion = 81;
$version = "1.8.0";

// Perform database schema update notification
print "Updating database and verion schema numbers.<br />";
$db->query("UPDATE hlstats_Options SET `value` = '$version' WHERE `keyname` = 'version'");
$db->query("UPDATE hlstats_Options SET `value` = '$dbversion' WHERE `keyname` = 'dbversion'");
?>

0 comments on commit c8526ea

Please sign in to comment.