CI: Clean up workflows. (#3316)
This commit is contained in:
+59
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (C) 2026-present VMaNGOS https://github.com/vmangos
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 <output-dir>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
output_dir="$1"
|
||||
dump_dir="$output_dir/mysql-dump"
|
||||
mysql_client_args=(--host=127.0.0.1 --protocol=TCP -u root -proot)
|
||||
|
||||
dump_database() {
|
||||
local database="$1"
|
||||
local file_path="$2"
|
||||
docker exec mysqldb mysqldump "${mysql_client_args[@]}" "$database" > "$file_path"
|
||||
}
|
||||
|
||||
import_sql_file() {
|
||||
local database="$1"
|
||||
local file_path="$2"
|
||||
docker exec -i mysqldb mysql "${mysql_client_args[@]}" "$database" < "$file_path"
|
||||
}
|
||||
|
||||
mkdir -p "$dump_dir"
|
||||
|
||||
echo "Exporting MySQL dumps..."
|
||||
dump_database mangos "$dump_dir/mangos.sql"
|
||||
dump_database realmd "$dump_dir/logon.sql"
|
||||
dump_database logs "$dump_dir/logs.sql"
|
||||
dump_database characters "$dump_dir/characters.sql"
|
||||
|
||||
echo "Creating verification databases..."
|
||||
for database in realmd_verify characters_verify mangos_verify logs_verify; do
|
||||
docker exec mysqldb mysql "${mysql_client_args[@]}" -e "CREATE DATABASE IF NOT EXISTS $database DEFAULT CHARSET utf8 COLLATE utf8_general_ci;"
|
||||
done
|
||||
|
||||
echo "Reimporting exported dumps..."
|
||||
import_sql_file realmd_verify "$dump_dir/logon.sql"
|
||||
import_sql_file logs_verify "$dump_dir/logs.sql"
|
||||
import_sql_file mangos_verify "$dump_dir/mangos.sql"
|
||||
import_sql_file characters_verify "$dump_dir/characters.sql"
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (C) 2026-present VMaNGOS https://github.com/vmangos
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 <world-db-archive-name>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
world_db_archive="$1"
|
||||
workspace="${GITHUB_WORKSPACE:?GITHUB_WORKSPACE must be set}"
|
||||
mysql_client_args=(--host=127.0.0.1 --protocol=TCP -u root -proot)
|
||||
|
||||
import_sql_file() {
|
||||
local database="$1"
|
||||
local file_path="$2"
|
||||
docker exec -i mysqldb mysql "${mysql_client_args[@]}" "$database" < "$file_path"
|
||||
}
|
||||
|
||||
apply_migration_file() {
|
||||
local database="$1"
|
||||
local file_name="$2"
|
||||
local file_path="$workspace/sql/migrations/$file_name"
|
||||
|
||||
if [ -f "$file_path" ]; then
|
||||
import_sql_file "$database" "$file_path"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Stopping preinstalled MySQL service..."
|
||||
sudo service mysql stop
|
||||
|
||||
echo "Starting MySQL container..."
|
||||
sudo docker run --name mysqldb -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -d mysql:5.6 --max_allowed_packet=128M
|
||||
|
||||
echo "Waiting for database availability..."
|
||||
max_attempts=30
|
||||
attempt=0
|
||||
until docker exec mysqldb mysqladmin "${mysql_client_args[@]}" ping --silent &> /dev/null; do
|
||||
attempt=$((attempt + 1))
|
||||
if [ "$attempt" -gt "$max_attempts" ]; then
|
||||
echo "Database failed to become ready in time!" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Waiting for database to be ready... (attempt $attempt/$max_attempts)"
|
||||
sleep 5
|
||||
done
|
||||
echo "Database is ready!"
|
||||
|
||||
echo "Downloading base world database..."
|
||||
world_db_archive_path="$workspace/$world_db_archive.7z"
|
||||
curl --fail --location --silent --show-error \
|
||||
--output "$world_db_archive_path" \
|
||||
"https://github.com/brotalnia/database/raw/master/$world_db_archive.7z"
|
||||
7z e -y "$world_db_archive_path" -o"$workspace"
|
||||
|
||||
echo "Creating source databases..."
|
||||
for database in realmd characters mangos logs; do
|
||||
docker exec mysqldb mysql "${mysql_client_args[@]}" -e "CREATE DATABASE IF NOT EXISTS $database DEFAULT CHARSET utf8 COLLATE utf8_general_ci;"
|
||||
done
|
||||
|
||||
echo "Importing schema and base data..."
|
||||
import_sql_file realmd "$workspace/sql/logon.sql"
|
||||
import_sql_file logs "$workspace/sql/logs.sql"
|
||||
import_sql_file mangos "$workspace/$world_db_archive.sql"
|
||||
import_sql_file characters "$workspace/sql/characters.sql"
|
||||
|
||||
echo "Applying SQL migrations..."
|
||||
cd "$workspace/sql/migrations"
|
||||
chmod +x merge.sh
|
||||
./merge.sh
|
||||
|
||||
apply_migration_file mangos world_db_updates.sql
|
||||
apply_migration_file characters characters_db_updates.sql
|
||||
apply_migration_file realmd logon_db_updates.sql
|
||||
apply_migration_file logs logs_db_updates.sql
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (C) 2026-present VMaNGOS https://github.com/vmangos
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$#" -ne 3 ]; then
|
||||
echo "Usage: $0 <release-tag> <release-title-prefix> <asset-dir>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
release_tag="$1"
|
||||
release_title_prefix="$2"
|
||||
asset_dir="$3"
|
||||
repo_url="https://github.com/$GITHUB_REPOSITORY"
|
||||
release_title="$release_title_prefix($(date -u +%F))"
|
||||
notes_file="$(mktemp)"
|
||||
|
||||
trap 'rm -f "$notes_file"' EXIT
|
||||
|
||||
git fetch --force --tags origin
|
||||
previous_sha="$(git rev-parse -q --verify "refs/tags/$release_tag^{commit}" 2>/dev/null || true)"
|
||||
|
||||
echo "## Commits" > "$notes_file"
|
||||
|
||||
if [ -n "$previous_sha" ] && [ "$previous_sha" != "$GITHUB_SHA" ]; then
|
||||
git_log_args=(--reverse --format='%H%x09%s' "$previous_sha..$GITHUB_SHA")
|
||||
else
|
||||
git_log_args=(-1 --format='%H%x09%s' "$GITHUB_SHA")
|
||||
fi
|
||||
|
||||
git log "${git_log_args[@]}" | while IFS=$'\t' read -r commit_sha subject; do
|
||||
short_sha="${commit_sha:0:7}"
|
||||
if [[ "$subject" =~ \(\#([0-9]+)\) ]]; then
|
||||
pr_number="${BASH_REMATCH[1]}"
|
||||
printf -- '- %s: %s [#%s](%s/pull/%s)\n' "$short_sha" "$subject" "$pr_number" "$repo_url" "$pr_number"
|
||||
else
|
||||
printf -- '- %s: %s\n' "$short_sha" "$subject"
|
||||
fi
|
||||
done >> "$notes_file"
|
||||
|
||||
if gh release view "$release_tag" >/dev/null 2>&1; then
|
||||
gh release delete "$release_tag" --yes
|
||||
fi
|
||||
|
||||
git tag -f "$release_tag" "$GITHUB_SHA"
|
||||
git push origin "refs/tags/$release_tag" --force
|
||||
|
||||
shopt -s nullglob
|
||||
assets=("$asset_dir"/*)
|
||||
|
||||
if [ "${#assets[@]}" -gt 0 ]; then
|
||||
gh release create "$release_tag" "${assets[@]}" --title "$release_title" --notes-file "$notes_file" --prerelease --verify-tag
|
||||
else
|
||||
gh release create "$release_tag" --title "$release_title" --notes-file "$notes_file" --prerelease --verify-tag
|
||||
fi
|
||||
Reference in New Issue
Block a user