Compare commits

..

1 Commits

Author SHA1 Message Date
Caesar2011
5b9acd86f5 Install latest version of helm via apt 2026-05-18 19:04:32 +02:00
4 changed files with 32 additions and 239 deletions

View File

@@ -20,12 +20,6 @@ Pushes both SHA-tagged and `latest` versions.
**Inputs:** `chart-path`, `version`, `app-version`, `username`, `password`
### `factorio-mod-push`
Set version, zip, and upload a Factorio mod to mods.factorio.com. Creates README.md if missing. Fails on any API error (auth, unknown mod, invalid release).
**Inputs:** `mod-folder` (default `.`), `version`, `factorio-token`
**Outputs:** `zip-path`
### `helm-deploy`
Deploy via helmbot SSH to vmd127288. Validates all inputs server-side.

View File

@@ -1,142 +0,0 @@
name: Factorio Mod Push
description: Set version, zip, and upload a Factorio mod to mods.factorio.com
inputs:
mod-folder:
description: Path to the Factorio mod root directory (containing info.json)
required: false
default: "."
version:
description: Semver version string to set in info.json, e.g. 1.0.1
required: true
factorio-token:
description: "Factorio API key with ModPortal: Upload Mods permission"
required: true
outputs:
zip-path:
description: Absolute path to the generated zip file
value: ${{ steps.package.outputs.zip-path }}
runs:
using: composite
steps:
- name: Validate inputs
shell: bash
run: |
MOD_FOLDER="${{ inputs.mod-folder }}"
VERSION="${{ inputs.version }}"
if [ ! -f "$MOD_FOLDER/info.json" ]; then
echo "ERROR: info.json not found in $MOD_FOLDER"
exit 1
fi
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "ERROR: version '$VERSION' does not match semver x.y.z"
exit 1
fi
- name: Set version in info.json
shell: bash
run: |
MOD_FOLDER="${{ inputs.mod-folder }}"
VERSION="${{ inputs.version }}"
sed -i 's/"version": *"[^"]*"/"version": "'"$VERSION"'"/' "$MOD_FOLDER/info.json"
- name: Create README.md if missing
shell: bash
run: |
MOD_FOLDER="${{ inputs.mod-folder }}"
if [ ! -f "$MOD_FOLDER/README.md" ]; then
TITLE=$(sed -n 's/.*"title": *"\([^"]*\)".*/\1/p' "$MOD_FOLDER/info.json")
DESC=$(sed -n 's/.*"description": *"\([^"]*\)".*/\1/p' "$MOD_FOLDER/info.json")
printf '# %s\n\n%s\n' "$TITLE" "$DESC" > "$MOD_FOLDER/README.md"
echo "Created $MOD_FOLDER/README.md"
fi
- name: Read mod name from info.json
id: modinfo
shell: bash
run: |
MOD_FOLDER="${{ inputs.mod-folder }}"
NAME=$(sed -n 's/.*"name": *"\([^"]*\)".*/\1/p' "$MOD_FOLDER/info.json")
echo "name=$NAME" >> $GITHUB_OUTPUT
- name: Package mod zip
id: package
shell: bash
run: |
MOD_FOLDER="${{ inputs.mod-folder }}"
NAME=${{ steps.modinfo.outputs.name }}
VERSION="${{ inputs.version }}"
ZIP_NAME="${NAME}_${VERSION}.zip"
ZIP_PATH="${GITHUB_WORKSPACE}/${ZIP_NAME}"
TMPDIR=$(mktemp -d)
cp -r "$MOD_FOLDER/." "$TMPDIR/$NAME/"
find "$TMPDIR/$NAME" -type d -name node_modules -exec rm -rf {} + 2>/dev/null || true
find "$TMPDIR/$NAME" -type d -name .git -exec rm -rf {} + 2>/dev/null || true
cd "$TMPDIR"
zip -r "$ZIP_PATH" "$NAME/"
rm -rf "$TMPDIR"
echo "zip-path=$ZIP_PATH" >> $GITHUB_OUTPUT
echo "Created $ZIP_PATH"
- name: Init upload to Factorio mod portal
id: init
shell: bash
run: |
NAME=${{ steps.modinfo.outputs.name }}
RESPONSE=$(curl -s -w "\n%{http_code}" \
-X POST "https://mods.factorio.com/api/v2/mods/releases/init_upload" \
-H "Authorization: Bearer ${{ inputs.factorio-token }}" \
-F "mod=$NAME")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_CODE" -ne 200 ]; then
echo "ERROR: init_upload failed (HTTP $HTTP_CODE)"
echo "Response: $BODY"
exit 1
fi
UPLOAD_URL=$(echo "$BODY" | sed -n 's/.*"upload_url": *"\([^"]*\)".*/\1/p')
if [ -z "$UPLOAD_URL" ]; then
echo "ERROR: init_upload failed - no upload_url in response"
echo "Response: $BODY"
exit 1
fi
echo "upload_url=$UPLOAD_URL" >> $GITHUB_OUTPUT
- name: Upload zip to Factorio mod portal
shell: bash
run: |
ZIP_PATH=${{ steps.package.outputs.zip-path }}
UPLOAD_URL=${{ steps.init.outputs.upload_url }}
RESPONSE=$(curl -s -w "\n%{http_code}" \
-X POST "$UPLOAD_URL" \
-F "file=@$ZIP_PATH")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_CODE" -ne 200 ]; then
echo "ERROR: upload failed (HTTP $HTTP_CODE)"
echo "Response: $BODY"
exit 1
fi
if ! echo "$BODY" | grep -q '"success": *true'; then
echo "ERROR: upload reported failure"
echo "Response: $BODY"
exit 1
fi
echo "Upload successful: ${{ steps.modinfo.outputs.name }} ${{ inputs.version }}"

View File

@@ -21,44 +21,54 @@ inputs:
runs:
using: composite
steps:
- name: Install Helm
shell: bash
run: |
curl -fsSL https://packages.buildkite.com/helm-linux/helm-debian/gpgkey \
| gpg --dearmor \
| sudo tee /usr/share/keyrings/helm.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/helm.gpg] https://packages.buildkite.com/helm-linux/helm-debian/any/ any main" \
| sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update -qq
sudo apt-get install -y helm
helm version --short
- name: Inject image tag into chart values
shell: bash
run: |
CHART_PATH=${{ inputs.chart-path }}
sed -i "s|^\(\s*tag:\).*|\1 ${{ inputs.app-version }}|" \
"$CHART_PATH/values.yaml"
${{ inputs.chart-path }}/values.yaml
- name: Package and push helm chart (SHA)
- name: Package helm chart (SHA)
shell: bash
run: |
CHART_PATH=${{ inputs.chart-path }}
CHART_NAME=$(basename "$CHART_PATH")
VERSION=${{ inputs.version }}
APP_VERSION=${{ inputs.app-version }}
sed -i "s/^version:.*/version: $VERSION/" "$CHART_PATH/Chart.yaml"
sed -i "s/^appVersion:.*/appVersion: \"$APP_VERSION\"/" "$CHART_PATH/Chart.yaml"
tar czf "${CHART_NAME}-${VERSION}.tgz" -C "$CHART_PATH" .
helm package ${{ inputs.chart-path }} \
--version "${{ inputs.version }}" \
--app-version "${{ inputs.app-version }}"
- name: Push helm chart (SHA) to Gitea
shell: bash
run: |
CHART_NAME=$(basename ${{ inputs.chart-path }})
curl -u ${{ inputs.username }}:${{ inputs.password }} \
-X POST \
https://git.sebse.de/api/packages/sebse/helm/api/charts \
-F "chart=@${CHART_NAME}-${VERSION}.tgz" \
-F "chart=@${CHART_NAME}-${{ inputs.version }}.tgz" \
--fail-with-body
- name: Package and push helm chart (latest)
- name: Package helm chart (latest)
shell: bash
run: |
CHART_PATH=${{ inputs.chart-path }}
CHART_NAME=$(basename "$CHART_PATH")
APP_VERSION=${{ inputs.app-version }}
sed -i "s/^version:.*/version: 0.0.0-latest/" "$CHART_PATH/Chart.yaml"
sed -i "s/^appVersion:.*/appVersion: \"$APP_VERSION\"/" "$CHART_PATH/Chart.yaml"
tar czf "${CHART_NAME}-0.0.0-latest.tgz" -C "$CHART_PATH" .
sed -i "s|^\(\s*tag:\).*|\1 ${{ inputs.app-version }}|" \
${{ inputs.chart-path }}/values.yaml
helm package ${{ inputs.chart-path }} \
--version "0.0.0-latest" \
--app-version "${{ inputs.app-version }}"
- name: Push helm chart (latest) to Gitea
shell: bash
run: |
CHART_NAME=$(basename ${{ inputs.chart-path }})
curl -u ${{ inputs.username }}:${{ inputs.password }} \
-X POST \
https://git.sebse.de/api/packages/sebse/helm/api/charts \

View File

@@ -1,69 +0,0 @@
name: Version Bump
description: Bump or get semver patch version with git tags
inputs:
token:
description: GitHub/Gitea token for pushing tags
required: true
mode:
description: "bump (create tag) or get (read only)"
required: false
default: bump
outputs:
version:
description: "e.g. 0.1.0 (no v prefix)"
value: ${{ steps.calc.outputs.version }}
version_with_sha:
description: "e.g. 0.1.0-a1b2c3d"
value: ${{ steps.calc.outputs.version_with_sha }}
runs:
using: composite
steps:
- name: Configure git
shell: bash
run: |
git config user.name "CI Bot"
git config user.email "ci@git.sebse.de"
git remote set-url origin https://ci:${{ inputs.token }}@git.sebse.de/${{ github.repository }}
- name: Fetch tags
shell: bash
run: git fetch --tags --force
- name: Calculate version
id: calc
shell: bash
run: |
SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7)
LATEST_TAG=$(git tag -l 'v*' --sort=-v:refname | head -n1)
if [ -z "$LATEST_TAG" ]; then
MAJOR=0
MINOR=0
PATCH=0
else
V="${LATEST_TAG#v}"
MAJOR=$(echo "$V" | cut -d. -f1)
MINOR=$(echo "$V" | cut -d. -f2)
PATCH=$(echo "$V" | cut -d. -f3)
fi
if [ "${{ inputs.mode }}" = "bump" ]; then
NEW_PATCH=$((PATCH + 1))
else
NEW_PATCH=$PATCH
fi
VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "version_with_sha=${VERSION}-${SHORT_SHA}" >> $GITHUB_OUTPUT
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Create and push tag
if: inputs.mode == 'bump'
shell: bash
run: |
git tag "v${VERSION}"
git push origin "v${VERSION}"