Skip to content

Commit efb36f1

Browse files
Changed escaping and made description update optional (#75)
Co-authored-by: Chris Kaiser <chris.kaiser@bahmut.de>
1 parent ac00850 commit efb36f1

File tree

2 files changed

+37
-20
lines changed

2 files changed

+37
-20
lines changed

.github/workflows/build-release.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ on:
2121
- 'Urban Synergy Unleashed;3371689443'
2222
- 'USU LLWA;3387021675'
2323
- 'USU Morgenrote;3371690718'
24+
update-description:
25+
description: 'Update description?'
26+
required: true
27+
default: 'true'
28+
type: choice
29+
options:
30+
- 'true'
31+
- 'false'
32+
2433

2534
jobs:
2635
release:
@@ -42,15 +51,26 @@ jobs:
4251
rm -f "${{ steps.metadata.outputs.mod-name }}/vic3-tiger.conf"
4352
rm -f "${{ steps.metadata.outputs.mod-name }}/design_notes.txt"
4453
# Use rm -f for files and rm -rf for folders.
45-
54+
4655
# Create mod metadata for the steam release
4756
# Uses STEAM_PAGE.bbcode to update steam description
57+
- name: Create Workshop Metadata with Description
58+
if: ${{ inputs.update-description == 'true' }}
59+
shell: bash
60+
run: |
61+
./script/create-release-vdf.sh "${{ github.workspace }}/${{ steps.metadata.outputs.mod-name }}" "${{ steps.metadata.outputs.mod-id }}" ../steam-release/STEAM_PAGE.bbcode
62+
63+
- name: Create Workshop Metadata without Description
64+
if: ${{ inputs.update-description == 'false' }}
65+
shell: bash
66+
run: |
67+
./script/create-release-vdf.sh "${{ github.workspace }}/${{ steps.metadata.outputs.mod-name }}" "${{ steps.metadata.outputs.mod-id }}"
68+
4869
# Report: Generated metadata
49-
- name: Create Workshop Metadata
70+
- name: Process Workshop Metadata
5071
id: steam-metadata
5172
shell: bash
5273
run: |
53-
./script/create-release-vdf.sh "${{ github.workspace }}/${{ steps.metadata.outputs.mod-name }}" ../steam-release/STEAM_PAGE.bbcode "${{ steps.metadata.outputs.mod-id }}"
5474
mv workshop.vdf ../steam-release/workshop.vdf
5575
echo "vdf=$(realpath ../steam-release/workshop.vdf)" >> "$GITHUB_OUTPUT"
5676
echo "# Workflow Metadata" >> $GITHUB_STEP_SUMMARY

script/create-release-vdf.sh

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,24 @@ else
1010
printf 'Usage: ./create-release-vdf.sh MOD_DIR DESC_FILE [MOD_ID]'
1111
exit 1
1212
fi
13-
# Check mod description
14-
if [ -f "$2" ]
15-
then
16-
description="$(cat < "$2")"
17-
description=${description//$'\n'/\\n}
18-
description=${description//$'\t'/\\t}
19-
description=${description//\"/\\\"}
20-
else
21-
printf 'Missing Steam description'
22-
printf '\n'
23-
printf 'Usage: ./create-release-vdf.sh MOD_DIR DESC_FILE [MOD_ID]'
24-
exit 1
25-
fi
2613

2714
title=$(grep -Po '(?<=\s\"name\"\s:\s\").+(?=\",)' "$mod_path/.metadata/metadata.json")
2815

2916
# Read mod id
30-
if [ -n "$3" ]
17+
if [ -n "$2" ]
3118
then
32-
mod_id="$3"
19+
mod_id="$2"
3320
else
3421
mod_id='0'
3522
fi
3623

24+
# Check mod description
25+
if [ -f "$3" ]
26+
then
27+
description="$(cat < "$3")"
28+
description=${description//\"/\\\"}
29+
fi
30+
3731
# Clean up old file
3832
printf '' > workshop.vdf
3933

@@ -51,8 +45,11 @@ printf '\t"previewfile" "%s/thumbnail.png"' "$mod_path" >> workshop.vdf
5145
printf '\n' >> workshop.vdf
5246
printf '\t"title" "%s"' "$title" >> workshop.vdf
5347
printf '\n' >> workshop.vdf
54-
printf '\t"description" "%s"' "$description" >> workshop.vdf
55-
printf '\n' >> workshop.vdf
48+
if [ -f "$3" ]
49+
then
50+
printf '\t"description" "%s"' "$description" >> workshop.vdf
51+
printf '\n' >> workshop.vdf
52+
fi
5653
printf '}' >> workshop.vdf
5754

5855
cat workshop.vdf

0 commit comments

Comments
 (0)