Skip to content

Commit 936d184

Browse files
committed
add CI (lint + packaging tests) and extract build.sh
1 parent 1d88c5a commit 936d184

3 files changed

Lines changed: 102 additions & 23 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
lint-and-package:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v5
16+
17+
- name: PHP syntax check (php -l)
18+
run: |
19+
command -v php >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq php-cli; }
20+
fail=0
21+
while IFS= read -r -d '' f; do
22+
php -l "$f" || fail=1
23+
done < <(find . -name '*.php' -not -path './dist/*' -print0)
24+
exit $fail
25+
26+
- name: Validate theme_info.xml
27+
run: |
28+
command -v xmllint >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq libxml2-utils; }
29+
xmllint --noout theme_info.xml
30+
31+
- name: ShellCheck build.sh
32+
run: |
33+
command -v shellcheck >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq shellcheck; }
34+
shellcheck build.sh # deploy.sh ist nicht im Repo (server-only) und wird lokal geprüft
35+
36+
- name: Packaging smoke test
37+
run: |
38+
chmod +x build.sh
39+
ZIP="$(./build.sh 9.9.9-citest | tail -n1)"
40+
echo "Built: $ZIP"
41+
42+
# 1) Wrapper-Ordner + theme_info.xml vorhanden
43+
unzip -l "$ZIP" | grep -q 'siduction/theme_info.xml' \
44+
|| { echo "FAIL: siduction/theme_info.xml fehlt im Zip"; exit 1; }
45+
46+
# 2) Version korrekt eingebrannt (theme_info.xml UND @version)
47+
unzip -p "$ZIP" siduction/theme_info.xml | grep -q '<version>9.9.9-citest</version>' \
48+
|| { echo "FAIL: Version nicht in theme_info.xml gestempelt"; exit 1; }
49+
unzip -p "$ZIP" siduction/index.template.php | grep -q '@version 9.9.9-citest' \
50+
|| { echo "FAIL: @version nicht in index.template.php gestempelt"; exit 1; }
51+
52+
# 3) VCS/CI/Ops-Dateien dürfen NICHT im Zip sein
53+
if unzip -l "$ZIP" | grep -qE 'deploy\.sh|build\.sh|\.github|\.git/|\.claude'; then
54+
echo "FAIL: unerwünschte Dateien im Zip:"; unzip -l "$ZIP"; exit 1
55+
fi
56+
57+
echo "OK: Packaging-Assertions bestanden"

‎.github/workflows/release.yml‎

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,13 @@ jobs:
1616

1717
- name: Derive version from tag
1818
id: ver
19-
run: |
20-
VERSION="${GITHUB_REF_NAME#v}" # v1.0 -> 1.0
21-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
19+
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" # v1.0 -> 1.0
2220

23-
- name: Stamp version into theme files
24-
env:
25-
VERSION: ${{ steps.ver.outputs.version }}
26-
run: |
27-
sed -i -E "s|<version>[^<]*</version>|<version>${VERSION}</version>|" theme_info.xml
28-
sed -i -E "s|(@version[[:space:]]+).*|\1${VERSION}|" index.template.php
29-
grep -n "<version>" theme_info.xml
30-
grep -n "@version" index.template.php
31-
32-
- name: Build theme zip (wrapped in siduction/)
33-
env:
34-
VERSION: ${{ steps.ver.outputs.version }}
21+
- name: Build theme zip
22+
id: build
3523
run: |
36-
rm -rf dist && mkdir -p dist/siduction
37-
rsync -a \
38-
--exclude='.git' --exclude='.github' --exclude='.gitignore' \
39-
--exclude='deploy.sh' --exclude='dist' --exclude='.DS_Store' \
40-
./ dist/siduction/
41-
(cd dist && zip -r -q "siduction-${VERSION}.zip" siduction)
42-
ls -lah dist
24+
chmod +x build.sh
25+
echo "zip=$(./build.sh "${{ steps.ver.outputs.version }}" | tail -n1)" >> "$GITHUB_OUTPUT"
4326
4427
- name: Create GitHub release
4528
env:
@@ -49,6 +32,6 @@ jobs:
4932
PRERELEASE=""
5033
case "$VERSION" in *-*) PRERELEASE="--prerelease";; esac # v1.0-rc1 -> prerelease
5134
gh release create "$GITHUB_REF_NAME" \
52-
"dist/siduction-${VERSION}.zip" \
35+
"${{ steps.build.outputs.zip }}" \
5336
--title "Siduction $VERSION" \
5437
--generate-notes $PRERELEASE

‎build.sh‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
# Baut das installierbare SMF-Theme-Zip mit eingebrannter Version.
3+
# Mutiert den Quellbaum NICHT — gestempelt wird nur im Staging-Verzeichnis.
4+
# Einzige Quelle der Wahrheit fürs Packaging (von release.yml UND ci.yml genutzt).
5+
#
6+
# Usage: ./build.sh <version> [dist_dir]
7+
# Gibt auf der letzten Zeile den Pfad zum erzeugten Zip aus.
8+
set -euo pipefail
9+
10+
VERSION="${1:?Usage: build.sh <version> [dist_dir]}"
11+
DIST="${2:-dist}"
12+
THEME_NAME="siduction"
13+
14+
ROOT="$(cd "$(dirname "$0")" && pwd)"
15+
STAGE="${DIST}/${THEME_NAME}"
16+
17+
# Portable In-Place-Ersetzung (GNU- und BSD-sed): in Temp schreiben, dann mv.
18+
stamp() { # stamp <datei> <sed-expr>
19+
sed -E "$2" "$1" > "$1.tmp" && mv "$1.tmp" "$1"
20+
}
21+
22+
rm -rf "$DIST"
23+
mkdir -p "$STAGE"
24+
25+
# Theme-Dateien ins Staging spiegeln (VCS/CI/Ops/OS-Kram raus)
26+
rsync -a \
27+
--exclude='.git' --exclude='.github' --exclude='.gitignore' \
28+
--exclude='.claude' --exclude='deploy.sh' --exclude='build.sh' \
29+
--exclude='dist' --exclude='.DS_Store' \
30+
"${ROOT}/" "$STAGE/"
31+
32+
# Version einbrennen (nur im Staging)
33+
stamp "${STAGE}/theme_info.xml" "s|<version>[^<]*</version>|<version>${VERSION}</version>|"
34+
stamp "${STAGE}/index.template.php" "s|(@version[[:space:]]+).*|\1${VERSION}|"
35+
36+
# Zip mit umschließendem siduction/-Ordner
37+
( cd "$DIST" && zip -r -q "${THEME_NAME}-${VERSION}.zip" "$THEME_NAME" )
38+
39+
echo "${DIST}/${THEME_NAME}-${VERSION}.zip"

0 commit comments

Comments
 (0)