Skip to content

Commit 60de886

Browse files
committed
Update workspace
1 parent acba880 commit 60de886

10 files changed

Lines changed: 229 additions & 29 deletions

File tree

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ end_of_line = lf
99
charset = utf-8
1010
trim_trailing_whitespace = true
1111

12-
[*.lua]
12+
[*.{lua,lua2p,sh,cmd,can}]
1313
indent_style = tab
1414
insert_final_newline = true
1515

@@ -22,6 +22,7 @@ insert_final_newline = false
2222
indent_style = space
2323
indent_size = 2
2424
insert_final_newline = true
25+
trim_trailing_whitespace = false
2526

2627
[*.{json,md}]
2728
indent_style = tab

.github/workflows/autoPublish.yml

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Auto publish
22

33
on:
44
push:
5+
paths:
6+
- 'info.json' # Triggers only if the mod info file is updated
57
branches:
68
- main
79

@@ -10,15 +12,9 @@ jobs:
1012
runs-on: ubuntu-latest
1113
steps:
1214
- name: Checkout repository and submodules
13-
uses: actions/checkout@v2
15+
uses: actions/checkout@v3
1416
with:
1517
submodules: recursive
16-
- name: get version
17-
id: version
18-
uses: notiz-dev/github-action-json-property@release
19-
with:
20-
path: 'info.json'
21-
prop_path: 'version'
2218
- name: get factorio_version
2319
id: factorio_version
2420
uses: notiz-dev/github-action-json-property@release
@@ -31,24 +27,18 @@ jobs:
3127
with:
3228
path: 'info.json'
3329
prop_path: 'name'
30+
- name: Zip mod
31+
run: bash ./.scripts/zip_mod.sh
32+
- name: Upload the mod on mods.factorio.com
33+
env:
34+
FACTORIO_MOD_API_KEY: ${{ secrets.FACTORIO_MOD_API_KEY }}
35+
run: bash ./.scripts/upload.sh
3436
- uses: marvinpinto/action-automatic-releases@latest
3537
id: aar
3638
with:
37-
automatic_release_tag: "${{steps.version.outputs.prop}}"
39+
automatic_release_tag: "${{steps.factorio_version.outputs.prop}}"
3840
title: "For factorio ${{steps.factorio_version.outputs.prop}}"
3941
repo_token: "${{ secrets.GITHUB_TOKEN }}"
4042
prerelease: false
41-
- name: Download the file
42-
uses: suisei-cn/actions-download-file@v1
43-
id: downloadfile # Remember to give an ID if you need the output
44-
with:
45-
url: https://github.com/${{github.repository}}/archive/refs/tags/${{steps.aar.outputs.automatic_releases_tag}}.zip
46-
target: temp/
47-
- run: cd temp && mv ${{steps.aar.outputs.automatic_releases_tag}}.zip ${{steps.mod_name.outputs.prop}}_${{steps.aar.outputs.automatic_releases_tag}}.zip
48-
- uses: TGNThump/factorio-publish-mod-action@v1
49-
with:
50-
mod_portal_username: ${{ secrets.FACTORIO_USER }}
51-
mod_portal_password: ${{ secrets.FACTORIO_PASSWORD }}
52-
mod_name: ${{steps.mod_name.outputs.prop}}
53-
asset_path: ./temp/${{steps.mod_name.outputs.prop}}_${{steps.aar.outputs.automatic_releases_tag}}.zip
54-
asset_name: ${{steps.aar.outputs.automatic_releases_tag}}
43+
files: |
44+
./${{steps.mod_name.outputs.prop}}_${{steps.version.outputs.prop}}.zip

.github/workflows/lint.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
on: push
1+
on:
2+
push:
3+
branches:
4+
- main
5+
26
name: Lint
37
jobs:
48
lint:
@@ -8,4 +12,4 @@ jobs:
812
- name: lint
913
uses: Roang-zero1/factorio-mod-luacheck@master
1014
with:
11-
luacheckrc_url: https://github.com/Nexela/Factorio-luacheckrc/raw/master/.luacheckrc
15+
luacheckrc_url: https://github.com/Nexela/Factorio-luacheckrc/raw/master/.luacheckrc

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,9 @@ coverage.xml
165165
.pydevproject
166166
# Sphinx documentation
167167
docs/_build
168+
169+
# lua2p debug files
170+
*.meta.lua
171+
172+
# Factorio debug files
173+
.vscode/factorio/*

.lua-format

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
column_limit: &1 120
2+
indent_width: 1
3+
use_tab: true
4+
tab_width: 4
5+
continuation_indent_width: 4
6+
spaces_before_call: 0
7+
keep_simple_control_block_one_line: false
8+
keep_simple_function_one_line: false
9+
align_args: false
10+
break_after_functioncall_lp: false
11+
break_before_functioncall_rp: false
12+
align_parameter: false
13+
chop_down_parameter: false
14+
break_after_functiondef_lp: false
15+
break_before_functiondef_rp: true
16+
align_table_field: false
17+
break_after_table_lb: true
18+
break_before_table_rb: true
19+
chop_down_table: false
20+
chop_down_kv_table: true
21+
table_sep: ","
22+
extra_sep_at_table_end: false
23+
column_table_limit: *1
24+
break_after_operator: true
25+
double_quote_to_single_quote: false
26+
single_quote_to_double_quote: true

.scripts/upload.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
(set -o igncr) 2>/dev/null && set -o igncr; # This comment is required.
3+
### The above line ensures that the script can be run on Cygwin/Linux even with Windows CRNL.
4+
### Run this script on GitHub after zipping the mod to upload the mod on mods.factorio.com
5+
### This a modified version of https://github.com/Penguin-Spy/factorio-mod-portal-publish/blob/5c669dc60672e6293afd5b1913a0c8475c5490c0/entrypoint.sh
6+
### You can generate your FACTORIO_MOD_API_KEY on https://factorio.com/create-api-key
7+
8+
9+
main() {
10+
### Check commands
11+
local has_errors=false
12+
if ! command -v jq &> /dev/null; then
13+
echo "Please install jq https://stedolan.github.io/jq/"
14+
local has_errors=true
15+
fi
16+
if [ $has_errors = true ] ; then
17+
exit 1
18+
fi
19+
20+
21+
### Get mod name and version from info.json
22+
### https://stedolan.github.io/jq/
23+
local MOD_VERSION=$(jq -r '.version' info.json)
24+
local MOD_NAME=$(jq -r '.name' info.json)
25+
26+
27+
# Validate the version string we're building
28+
if ! echo "${MOD_VERSION}" | grep -P --quiet '^\d+\.\d+\.\d+$'; then
29+
echo "Incorrect version pattern, needs to be %u.%u.%u (e.q., 0.1.0)"
30+
exit 1
31+
fi
32+
33+
34+
# Get an upload url for the mod
35+
local URL_RESULT=$(curl -s -d "mod=${MOD_NAME}" -H "Authorization: Bearer ${FACTORIO_MOD_API_KEY}" https://mods.factorio.com/api/v2/mods/releases/init_upload)
36+
local UPLOAD_URL=$(echo "${URL_RESULT}" | jq -r '.upload_url')
37+
if [[ "${UPLOAD_URL}" == "null" ]] || [[ -z "${UPLOAD_URL}" ]]; then
38+
echo "Couldn't get an upload url, failed"
39+
local ERROR=$(echo "${URL_RESULT}" | jq -r '.error')
40+
local MESSAGE=$(echo "${URL_RESULT}" | jq -r '.message // empty')
41+
echo "${ERROR}: ${MESSAGE}"
42+
exit 1
43+
fi
44+
45+
46+
# Upload the file
47+
local UPLOAD_RESULT=$(curl -s -F "file=@${MOD_NAME}_${MOD_VERSION}.zip" "${UPLOAD_URL}")
48+
49+
# The success attribute only appears on successful uploads
50+
local SUCCESS=$(echo "${UPLOAD_RESULT}" | jq -r '.success')
51+
if [[ "${SUCCESS}" == "null" ]] || [[ -z "${SUCCESS}" ]]; then
52+
echo "Upload failed"
53+
local ERROR=$(echo "${UPLOAD_RESULT}" | jq -r '.error')
54+
local MESSAGE=$(echo "${UPLOAD_RESULT}" | jq -r '.message // empty')
55+
echo "${ERROR}: ${MESSAGE}"
56+
exit 1
57+
fi
58+
59+
echo "Upload of ${MOD_NAME}_${MOD_VERSION}.zip completed"
60+
}
61+
main

.scripts/zip_mod.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
(set -o igncr) 2>/dev/null && set -o igncr; # This comment is required.
3+
### The above line ensures that the script can be run on Cygwin/Linux even with Windows CRNL.
4+
### Run this script after updating the mod to prepare a zip of it.
5+
6+
main() {
7+
### Check commands
8+
if ! command -v git &> /dev/null; then
9+
echo "Please install/use git https://git-scm.com/downloads"
10+
fi
11+
local has_errors=false
12+
if ! command -v jq &> /dev/null; then
13+
echo "Please install jq https://stedolan.github.io/jq/"
14+
local has_errors=true
15+
fi
16+
if ! command -v 7z &> /dev/null; then
17+
echo "Please install 7-Zip https://www.7-zip.org/download.html"
18+
local has_errors=true
19+
fi
20+
if [ $has_errors = true ] ; then
21+
exit 1
22+
fi
23+
24+
25+
### mod_folder is a mod directory with info.json
26+
local init_dir=`pwd`
27+
28+
29+
### Find info.json
30+
local SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
31+
local infojson_exists=false
32+
if [[ -s "$SCRIPT_DIR/info.json" ]]; then
33+
infojson_exists=true
34+
mod_folder=$SCRIPT_DIR
35+
else
36+
cd $SCRIPT_DIR
37+
cd ..
38+
if [[ -s "$PWD/info.json" ]]; then
39+
infojson_exists=true
40+
mod_folder=$PWD
41+
elif [[ -s "$init_dir/info.json" ]]; then
42+
infojson_exists=true
43+
mod_folder=$init_dir
44+
fi
45+
fi
46+
47+
48+
if [ $infojson_exists = false ] ; then
49+
echo "There's no info.json"
50+
exit 1
51+
fi
52+
cd "$mod_folder/"
53+
echo "Target folder: ${mod_folder}"
54+
55+
56+
### Get mod name and version from info.json
57+
### https://stedolan.github.io/jq/
58+
local MOD_NAME=$(jq -r '.name' info.json)
59+
local MOD_VERSION=$(jq -r '.version' info.json)
60+
61+
62+
# Validate the version string we're building
63+
if ! echo "${MOD_VERSION}" | grep -P --quiet '^\d+\.\d+\.\d+$'; then
64+
echo "Incorrect version pattern, needs to be %u.%u.%u (e.q., 0.1.0)"
65+
exit 1
66+
fi
67+
68+
69+
### Prepare zip for Factorio native use and mod portal
70+
### https://www.7-zip.org/download.html
71+
local name="${MOD_NAME}_${MOD_VERSION}"
72+
if command -v git &> /dev/null; then
73+
git clean -xdf
74+
fi
75+
7z a -xr'!.*' "${mod_folder}/${name}.zip" "${mod_folder}"
76+
}
77+
main

.vscode/extensions.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
"recommendations": [
33
"eamodio.gitlens",
44
"justarandomgeek.factoriomod-debug",
5-
"coenraads.bracket-pair-colorizer-2",
65
"sumneko.lua",
76
"davidanson.vscode-markdownlint",
87
"editorconfig.editorconfig",
9-
"lextudio.restructuredtext"
8+
"lextudio.restructuredtext",
9+
"koihik.vscode-lua-format",
10+
"mads-hartmann.bash-ide-vscode",
11+
"ms-vscode-remote.remote-wsl",
12+
"formulahendry.code-runner",
13+
"gruntfuggly.triggertaskonsave"
1014
]
1115
}

.vscode/settings.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"Lua.workspace.ignoreDir": [
3131
".vscode",
3232
".github",
33+
".script",
3334
"locale"
3435
],
3536
"Lua.runtime.builtin": {
@@ -40,10 +41,10 @@
4041
"string": "enable",
4142
"package": "enable",
4243
"debug": "enable",
44+
"bit32": "disable",
4345
"io": "disable",
4446
"jit": "disable",
4547
"bit": "disable",
46-
"bit32": "enable",
4748
"coroutine": "disable",
4849
"ffi": "disable",
4950
"os": "disable",
@@ -65,5 +66,13 @@
6566
"restructuredtext.confPath": "${workspaceFolder}\\predocs",
6667
"restructuredtext.builtDocumentationPath" : "${workspaceFolder}/docs/_build/html",
6768
"restructuredtext.updateOnTextChanged" : "false",
68-
"restructuredtext.updateDelay" : 1000,
69+
"restructuredtext.updateDelay": 1000,
70+
"Lua.diagnostics.disable": [
71+
"lowercase-global",
72+
"undefined-doc-name",
73+
"undefined-doc-class"
74+
],
75+
"triggerTaskOnSave.tasks": {
76+
"Luacheck": ["*.lua"]
77+
}
6978
}

.vscode/tasks.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "zip mod",
6+
"type": "shell",
7+
"command": "bash",
8+
"args": [".scripts/zip_mod.sh"],
9+
"group": "build",
10+
"presentation": {
11+
"reveal": "silent",
12+
}
13+
},
14+
{
15+
"label": "Luacheck",
16+
"type": "shell",
17+
"command": "luacheck",
18+
"args": ["${file}"],
19+
"group": "test"
20+
},
21+
]
22+
}

0 commit comments

Comments
 (0)