Skip to content

yeah

yeah #3379

Workflow file for this run

name: CI
on:
push:
branches:
- main
tags-ignore:
- release
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
jobs:
strip-comments:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
curl -sSfL https://raw.githubusercontent.com/bleonheart/Useful-Python-Scripts/refs/heads/main/files/remove_lua_comments.py -o remove_lua_comments.py || curl -sSfL https://raw.githubusercontent.com/bleonheart/Useful-Python-Scripts/main/files/remove_lua_comments.py -o remove_lua_comments.py
python3 remove_lua_comments.py gamemode
tar --exclude=.git -cf workspace.tar .
- uses: actions/upload-artifact@v4
with:
name: workspace
path: workspace.tar
overwrite: true
retention-days: 1
format-glua:
needs: strip-comments
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v4
with:
name: workspace
path: .
- run: |
tar -xf workspace.tar
rm -f workspace.tar
- name: Download glualint binary
env:
GLUALINT_VERSION: "1.29.0"
run: |
set -euo pipefail
sudo apt-get update -y
sudo apt-get install -y unzip file
arch="$(uname -m)"
case "$arch" in
x86_64) asset="glualint-${GLUALINT_VERSION}-x86_64-linux.zip" ;;
aarch64|arm64) asset="glualint-${GLUALINT_VERSION}-aarch64-linux.zip" ;;
*) echo "Unsupported architecture: $arch" >&2; exit 1 ;;
esac
url="https://github.com/FPtje/GLuaFixer/releases/download/${GLUALINT_VERSION}/${asset}"
curl -fLsS "$url" -o glualint.zip
unzip -o glualint.zip
chmod +x glualint
file glualint | grep -q ELF
./glualint --version
- name: Pretty-print all Lua files
run: |
find . -type f -name "*.lua" -print0 | xargs -0 ./glualint --pretty-print-files
tar --exclude=.git -cf workspace.tar .
- uses: actions/upload-artifact@v4
with:
name: workspace
path: workspace.tar
overwrite: true
retention-days: 1
linter:
needs: format-glua
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v4
with:
name: workspace
path: .
- run: |
tar -xf workspace.tar
rm -f workspace.tar
- uses: leafo/gh-actions-lua@v8.0.0
with:
luaVersion: "5.2"
- uses: leafo/gh-actions-luarocks@v4.0.0
- run: |
luarocks install luafilesystem
luarocks install argparse
- uses: actions/checkout@v3
with:
repository: LiliaFramework/GluaCheck
path: luacheck
- run: |
cd luacheck
luarocks make
- run: |
luacheck gamemode \
--no-global \
--no-max-line-length \
--no-self \
--no-max-code-line-length \
--no-max-string-line-length \
--no-max-comment-line-length \
--no-max-cyclomatic-complexity
- run: |
cd "${GITHUB_WORKSPACE}"
tar --exclude=.git -cf workspace.tar .
- uses: actions/upload-artifact@v4
with:
name: workspace
path: workspace.tar
overwrite: true
retention-days: 1
compute-version:
if: github.repository == 'LiliaFramework/Lilia'
needs: linter
runs-on: ubuntu-latest
outputs:
version: ${{ steps.calc_version.outputs.version }}
valid_count: ${{ steps.calc_version.outputs.valid_count }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: calc_version
run: |
VALID_COUNT=$(git log --no-merges --pretty=format:'%ae' | grep -v '^github-actions@github.com$' | wc -l)
if (( VALID_COUNT < 100 )); then
MAJOR=0; MINOR=0; PATCH=$VALID_COUNT
elif (( VALID_COUNT < 1000 )); then
MAJOR=0; MINOR=$((VALID_COUNT / 100)); PATCH=$((VALID_COUNT % 100))
else
MAJOR=$((VALID_COUNT / 1000))
MINOR=$(((VALID_COUNT % 1000) / 100))
PATCH=$((VALID_COUNT % 100))
fi
VERSION_FLOAT=$(echo "$MAJOR.$MINOR$PATCH" | sed 's/^0*//' | sed 's/\.$/.0/')
echo "version=$VERSION_FLOAT" >> "$GITHUB_OUTPUT"
echo "valid_count=$VALID_COUNT" >> "$GITHUB_OUTPUT"
update-shared-version:
if: github.repository == 'LiliaFramework/Lilia' && github.ref == 'refs/heads/main'
needs: compute-version
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.compute-version.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: workspace
path: .
- run: |
tar -xf workspace.tar
rm -f workspace.tar
- run: |
python3 - << 'PY'
import os, re, pathlib, sys
version = os.environ["VERSION"]
p = pathlib.Path("gamemode/shared.lua")
lines = p.read_text(encoding="utf-8-sig").splitlines(keepends=True)
out = []; done = False
for line in lines:
if not done and re.match(r"\s*GM\.Name\s*=", line):
out.append(line)
out.append(f"GM.version = {version}\n")
done = True
elif re.match(r"\s*GM\.version\s*=", line):
continue
else:
out.append(line)
if not done:
sys.exit(1)
p.write_text(''.join(out), encoding='utf-8')
PY
- run: |
mkdir -p documentation/docs/versioning
echo "{\"version\":\"${VERSION}\"}" > documentation/docs/versioning/lilia.json
- run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
if ! git diff --cached --quiet; then
git commit -m "chore: Successfully updated workshop Lilia to ${VERSION}"
git push origin HEAD:main
fi
release:
if: github.repository == 'LiliaFramework/Lilia' && github.ref == 'refs/heads/main'
needs: update-shared-version
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.compute-version.outputs.version }}
VALID_COUNT: ${{ needs.compute-version.outputs.valid_count }}
GITHUB_TOKEN: ${{ secrets.LiliaGitSecret }}
STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }}
STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- run: |
rm -rf addon
mkdir -p addon/gamemodes/lilia
cp -a gamemode addon/gamemodes/lilia
cp -a content/. addon/
cp -a icon24.png addon/gamemodes/lilia/
cp -a lilia.txt addon/gamemodes/lilia/
- run: |
rm -rf release
mkdir -p release/lilia
cp -a gamemode release/lilia/
cp icon24.png release/lilia/
cp lilia.txt release/lilia/
- run: |
cd release
zip -r ../lilia.zip lilia
- run: |
sudo apt-get update -y
sudo apt-get install -y jq
- run: |
for rid in $(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/${{ github.repository }}/releases" | jq -r '.[].id'); do
curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/releases/$rid"
done
- run: |
for tag in $(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/git/refs/tags" \
| jq -r '.[].ref' | sed 's#refs/tags/##'); do
if [[ "$tag" != "$VERSION" ]]; then
curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$tag"
fi
done
- id: create_release
uses: actions/create-release@v1
with:
tag_name: release
release_name: Lilia ${{ env.VERSION }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.LiliaGitSecret }}
- uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: lilia.zip
asset_name: lilia.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.LiliaGitSecret }}
- run: |
cat > /tmp/addon.json <<EOF
{
"title": "Lilia",
"description": "Lilia ${VERSION}",
"author": "LiliaFramework",
"type": "gamemode",
"ignore": [".github/*", "site/*", "documentation/*"]
}
EOF
- run: |
cp /tmp/addon.json addon/addon.json
- run: |
sudo apt-get update
sudo apt-get install -y lib32gcc-s1 lua5.3
mkdir -p ~/Steam
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf - -C ~/Steam
- run: |
cd addon
lua5.3 ../gmacreator.lua ../3527535922.gma addon.json
- run: |
echo "Created workshop addon 3527535922.gma"
- run: |
cat > changelog.txt <<EOF
Lilia ${VERSION}
EOF
cat > workshop.vdf <<EOF
"workshopitem"{
"appid" "4000"
"publishedfileid" "3527535922"
"contentfolder" "$(pwd)/3527535922.gma"
"changenote" "$(cat changelog.txt)"
}
EOF
- run: |
~/Steam/steamcmd.sh +login $STEAM_USERNAME $STEAM_PASSWORD +workshop_build_item $(pwd -P)/workshop.vdf +quit
- if: failure()
run: |
echo ~/Steam/logs/stderr.txt
cat ~/Steam/logs/stderr.txt || true
echo
echo ~/Steam/logs/workshop_log.txt
cat ~/Steam/logs/workshop_log.txt || true
echo
echo ~/Steam/workshopbuilds/depot_build_4000.log
cat ~/Steam/workshopbuilds/depot_build_4000.log || true
echo
cat workshop.vdf || true
exit 1
deploy-pages:
if: github.repository == 'LiliaFramework/Lilia' && github.ref == 'refs/heads/main'
needs: release
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.compute-version.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
persist-credentials: true
- uses: actions/checkout@v3
with:
repository: LiliaFramework/LiliaFramework.github.io
path: site
token: ${{ secrets.LiliaGitSecret }}
- run: |
rsync -a --delete --exclude '.git' documentation/ site/
- run: |
curl -L -o site/modules.json https://raw.githubusercontent.com/LiliaFramework/Modules/gh-pages/modules.json
- run: |
echo "{\"version\":\"${VERSION}\"}" > site/version.json
- run: |
cd site
git config user.name github-actions
git config user.email github-actions@github.com
git add -A
if ! git diff --cached --quiet; then
git commit -m "Successfully updated workshop Lilia to ${VERSION}"
git push origin HEAD:main
fi