Compare commits

..

4 Commits

Author SHA1 Message Date
Sebastian Seedorf
1bc3606fa3 fix: replace heredoc with printf to avoid YAML indent break 2026-05-19 18:52:38 +02:00
Sebastian Seedorf
eb3e4613db fix: quote description with colon in factorio-mod-push 2026-05-19 18:39:05 +02:00
Sebastian Seedorf
a8c19073a3 Remove helm binary dependency from helm-package-push
Replace 'helm package' with sed on Chart.yaml + tar czf.
No external tool needed beyond coreutils (sed, tar, curl).
2026-05-19 18:26:42 +02:00
Sebastian Seedorf
de4c48d0bf Add factorio-mod-push action
Composite action that sets version in info.json, creates README.md
if missing, zips with {name}_{version}.zip structure, and uploads
to mods.factorio.com via init_upload + finish_upload API.

Fails on any API error (auth, unknown mod, invalid release).
2026-05-19 18:17:08 +02:00
3 changed files with 170 additions and 28 deletions

View File

@@ -20,6 +20,12 @@ Pushes both SHA-tagged and `latest` versions.
**Inputs:** `chart-path`, `version`, `app-version`, `username`, `password` **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` ### `helm-deploy`
Deploy via helmbot SSH to vmd127288. Validates all inputs server-side. Deploy via helmbot SSH to vmd127288. Validates all inputs server-side.

View File

@@ -0,0 +1,142 @@
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,50 +21,44 @@ inputs:
runs: runs:
using: composite using: composite
steps: steps:
- name: Install Helm
shell: bash
run: |
curl -fsSL https://get.helm.sh/helm-v3.14.4-linux-amd64.tar.gz \
| tar xz -C /tmp
mv /tmp/linux-amd64/helm /usr/local/bin/helm
helm version --short
- name: Inject image tag into chart values - name: Inject image tag into chart values
shell: bash shell: bash
run: | run: |
CHART_PATH=${{ inputs.chart-path }}
sed -i "s|^\(\s*tag:\).*|\1 ${{ inputs.app-version }}|" \ sed -i "s|^\(\s*tag:\).*|\1 ${{ inputs.app-version }}|" \
${{ inputs.chart-path }}/values.yaml "$CHART_PATH/values.yaml"
- name: Package helm chart (SHA) - name: Package and push helm chart (SHA)
shell: bash shell: bash
run: | run: |
helm package ${{ inputs.chart-path }} \ CHART_PATH=${{ inputs.chart-path }}
--version "${{ inputs.version }}" \ CHART_NAME=$(basename "$CHART_PATH")
--app-version "${{ inputs.app-version }}" 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" .
- name: Push helm chart (SHA) to Gitea
shell: bash
run: |
CHART_NAME=$(basename ${{ inputs.chart-path }})
curl -u ${{ inputs.username }}:${{ inputs.password }} \ curl -u ${{ inputs.username }}:${{ inputs.password }} \
-X POST \ -X POST \
https://git.sebse.de/api/packages/sebse/helm/api/charts \ https://git.sebse.de/api/packages/sebse/helm/api/charts \
-F "chart=@${CHART_NAME}-${{ inputs.version }}.tgz" \ -F "chart=@${CHART_NAME}-${VERSION}.tgz" \
--fail-with-body --fail-with-body
- name: Package helm chart (latest) - name: Package and push helm chart (latest)
shell: bash shell: bash
run: | run: |
sed -i "s|^\(\s*tag:\).*|\1 ${{ inputs.app-version }}|" \ CHART_PATH=${{ inputs.chart-path }}
${{ inputs.chart-path }}/values.yaml CHART_NAME=$(basename "$CHART_PATH")
helm package ${{ inputs.chart-path }} \ APP_VERSION=${{ inputs.app-version }}
--version "0.0.0-latest" \
--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" .
- name: Push helm chart (latest) to Gitea
shell: bash
run: |
CHART_NAME=$(basename ${{ inputs.chart-path }})
curl -u ${{ inputs.username }}:${{ inputs.password }} \ curl -u ${{ inputs.username }}:${{ inputs.password }} \
-X POST \ -X POST \
https://git.sebse.de/api/packages/sebse/helm/api/charts \ https://git.sebse.de/api/packages/sebse/helm/api/charts \