Some checks failed
Build & Release / build (push) Failing after 39s
- README with features, config docs, build instructions, project structure - Pipeline: add Docker CLI install step, fix DinD volume pattern, fix token generation flags (--user git -u calic --raw), proper token cleanup by name instead of fragile ID grep - .gitignore: add dist/ and *.zip Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
86 lines
3.3 KiB
YAML
86 lines
3.3 KiB
YAML
name: Build & Release
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
tags: ['v*']
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Docker CLI
|
|
run: |
|
|
apt-get update -qq && apt-get install -y -qq ca-certificates curl >/dev/null
|
|
install -m 0755 -d /etc/apt/keyrings
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
|
|
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu noble stable" > /etc/apt/sources.list.d/docker.list
|
|
apt-get update -qq && apt-get install -y -qq docker-ce-cli >/dev/null
|
|
|
|
- name: Build mod
|
|
run: |
|
|
VERSION=$(grep -oPm1 '"version":\s*"\K[^"]+' resources/modinfo.json)
|
|
MODID="welcomescreen"
|
|
echo "Building ${MODID} v${VERSION}..."
|
|
|
|
# DinD: bind mounts don't work — use docker cp with a volume
|
|
docker volume create mod-build
|
|
docker pull alpine:3 >/dev/null 2>&1
|
|
HELPER=$(docker create -v mod-build:/src alpine:3 true)
|
|
docker cp . $HELPER:/src/
|
|
docker rm $HELPER >/dev/null
|
|
|
|
docker run --rm -v mod-build:/src -w /src mcr.microsoft.com/dotnet/sdk:8.0 \
|
|
dotnet build -c Release
|
|
|
|
# Extract build output from volume
|
|
HELPER=$(docker create -v mod-build:/src alpine:3 true)
|
|
docker cp $HELPER:/src/bin/Release/WelcomeScreen.dll ./WelcomeScreen.dll
|
|
docker rm $HELPER >/dev/null
|
|
docker volume rm mod-build >/dev/null
|
|
|
|
# Package mod ZIP
|
|
mkdir -p dist
|
|
cp WelcomeScreen.dll dist/
|
|
cp resources/modinfo.json dist/
|
|
cd dist && zip -j "../${MODID}_${VERSION}.zip" WelcomeScreen.dll modinfo.json
|
|
cd ..
|
|
|
|
echo "MOD_ZIP=${MODID}_${VERSION}.zip" >> $GITHUB_ENV
|
|
echo "MOD_VERSION=${VERSION}" >> $GITHUB_ENV
|
|
echo "Built: ${MODID}_${VERSION}.zip"
|
|
|
|
- name: Create release
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
TAG="${GITHUB_REF#refs/tags/}"
|
|
TOKEN_NAME="ci-release-$$"
|
|
|
|
# Generate temporary Gitea API token
|
|
# --user git = container OS user; -u calic = Gitea account
|
|
TOKEN=$(docker exec --user git gitea gitea admin user generate-access-token \
|
|
-u calic -t "$TOKEN_NAME" --scopes all --raw 2>/dev/null)
|
|
|
|
# Create release
|
|
RELEASE_ID=$(curl -sf \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"${TAG}\",\"name\":\"Welcome Screen ${MOD_VERSION}\",\"body\":\"Release ${MOD_VERSION}\"}" \
|
|
"http://gitea:3000/api/v1/repos/calic/vs-welcome-screen/releases" \
|
|
| grep -oPm1 '"id":\K[0-9]+')
|
|
|
|
# Attach mod ZIP to release
|
|
curl -sf \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-F "attachment=@${MOD_ZIP}" \
|
|
"http://gitea:3000/api/v1/repos/calic/vs-welcome-screen/releases/${RELEASE_ID}/assets"
|
|
|
|
echo "Release ${TAG} created with ${MOD_ZIP}"
|
|
|
|
# Clean up token
|
|
curl -sf -X DELETE -u "calic:${TOKEN}" \
|
|
"http://gitea:3000/api/v1/users/calic/tokens/${TOKEN_NAME}" >/dev/null 2>&1 || true
|