Update generated module documentation #3320
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
linter: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- 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 | |
compute-version: | |
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: | |
needs: compute-version | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
env: | |
VERSION: ${{ needs.compute-version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- 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: | | |
git config user.name github-actions[bot] | |
git config user.email github-actions[bot]@users.noreply.github.com | |
git add gamemode/shared.lua | |
git diff-index --quiet HEAD || git commit -m "Moved Lilia Version to ${VERSION}" | |
git push origin HEAD:main | |
release: | |
needs: | |
- compute-version | |
- update-shared-version | |
if: github.ref == 'refs/heads/main' | |
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: | |
needs: | |
- compute-version | |
- release | |
if: github.ref == 'refs/heads/main' | |
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 "Moved Lilia Version to ${VERSION}" | |
git push origin HEAD:main | |
fi |