generated from fgardt/factorio-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1a5d621
Showing
11 changed files
with
287 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Set the default behavior to automatically detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# files that should not be modified | ||
*.png binary | ||
*.blend binary export-ignore | ||
|
||
# files that should not get included in a release zip | ||
README.md export-ignore | ||
.vscode export-ignore | ||
.git export-ignore | ||
.github export-ignore | ||
.gitignore export-ignore | ||
.gitattributes export-ignore | ||
.releaserc export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Release | ||
|
||
permissions: write-all | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
name: release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
- name: Install release dependencies | ||
run: | | ||
npm install semantic-release@^24 \ | ||
@semantic-release/git@^10 semantic-release-factorio@^1.5.1 \ | ||
conventional-changelog-conventionalcommits@^8 | ||
- name: Run semantic-release | ||
run: npx semantic-release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
FACTORIO_TOKEN: ${{ secrets.FACTORIO_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.vscode/* | ||
!.vscode/extensions.json | ||
!.vscode/settings.json | ||
|
||
*.code-workspace | ||
*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"branches": [ | ||
"main" | ||
], | ||
"plugins": [ | ||
[ | ||
"@semantic-release/commit-analyzer", | ||
{ | ||
"preset": "conventionalcommits", | ||
"releaseRules": [ | ||
{ "type": "info", "release": "patch" }, | ||
{ "type": "feat", "release": "minor" }, | ||
{ "type": "feature", "release": "minor" }, | ||
{ "type": "gui", "release": "patch" }, | ||
{ "type": "balance", "release": "patch" }, | ||
{ "type": "perf", "release": "patch" }, | ||
{ "type": "performance", "release": "patch" }, | ||
{ "type": "compat", "release": "patch" }, | ||
{ "type": "compatibility", "release": "patch" }, | ||
{ "type": "fix", "release": "patch" }, | ||
{ "type": "graphics", "release": "patch" }, | ||
{ "type": "sound", "release": "patch" }, | ||
{ "type": "locale", "release": "patch" }, | ||
{ "type": "translate", "release": "patch" }, | ||
{ "type": "control", "release": "patch" }, | ||
{ "type": "other", "release": "patch" } | ||
] | ||
} | ||
], | ||
[ | ||
"@semantic-release/release-notes-generator", | ||
{ | ||
"preset": "conventionalcommits", | ||
"writerOpts": { | ||
"headerPartial": "---------------------------------------------------------------------------------------------------\nVersion: {{version}}\nDate: {{#if date}}{{date}}{{else}}????{{/if}}\n", | ||
"footerPartial": "", | ||
"commitPartial": "{{#if scope}}[{{scope}}] {{/if}}{{~subject}}", | ||
"mainTemplate": "{{> header}}\n{{#each commitGroups}}\n {{title}}:\n{{#each commits}}\n - {{> commit root=@root}}\n{{/each}}\n{{/each}}" | ||
}, | ||
"presetConfig": { | ||
"types": [ | ||
{ "type": "info", "section": "Info" }, | ||
{ "type": "feat", "section": "Features" }, | ||
{ "type": "feature", "section": "Features" }, | ||
{ "type": "gui", "section": "Gui" }, | ||
{ "type": "balance", "section": "Balancing" }, | ||
{ "type": "perf", "section": "Optimizations" }, | ||
{ "type": "performance", "section": "Optimizations" }, | ||
{ "type": "compat", "section": "Compatibility" }, | ||
{ "type": "compatibility", "section": "Compatibility" }, | ||
{ "type": "fix", "section": "Bugfixes" }, | ||
{ "type": "graphics", "section": "Graphics" }, | ||
{ "type": "sound", "section": "Sounds" }, | ||
{ "type": "locale", "section": "Locale" }, | ||
{ "type": "translate", "section": "Translation" }, | ||
{ "type": "control", "section": "Control" }, | ||
{ "type": "other", "section": "Changes" } | ||
] | ||
} | ||
} | ||
], | ||
"semantic-release-factorio", | ||
[ | ||
"@semantic-release/github", | ||
{ | ||
"assets": [ | ||
{ | ||
"path": "*_*.*.*.zip", | ||
"label": "Packaged Mod" | ||
} | ||
] | ||
} | ||
], | ||
[ | ||
"@semantic-release/git", | ||
{ | ||
"assets": [ | ||
"changelog.txt", | ||
"info.json" | ||
] | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"justarandomgeek.factoriomod-debug", | ||
"sumneko.lua", | ||
"usernamehw.errorlens" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"Lua.diagnostics.globals": [ | ||
"game", | ||
"settings", | ||
"script", | ||
"global", | ||
"entity", | ||
"defines", | ||
"data", | ||
"rendering", | ||
"mods", | ||
"log", | ||
"util", | ||
"table", | ||
"serpent", | ||
"table_size", | ||
"commands", | ||
"remote", | ||
"__DebugAdapter", | ||
"__Profiler" | ||
], | ||
"Lua.diagnostics.disable": [ | ||
"lowercase-global" | ||
], | ||
"Lua.runtime.version": "Lua 5.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Florian Gebhardt | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
[![Release](https://github.com/fgardt/factorio-mod-template/actions/workflows/release.yml/badge.svg?branch=main)](https://github.com/fgardt/factorio-mod-template/actions/workflows/release.yml) | ||
<!-- ^======[REPLACE THIS]======^ ^======[REPLACE THIS]======^ --> | ||
|
||
# factorio-mod-template | ||
|
||
A small Factorio Mod template which also contains GitHub Actions for automatic changelog generation, packaging and releasing to the [Factorio Mod Portal](https://mods.factorio.com) | ||
|
||
# How it works | ||
|
||
This template uses [semantic-release](https://github.com/semantic-release/semantic-release) to automate the changelog generation aswell as packaging and releasing of the mod. \ | ||
To achieve this it analyzes your commit messages to figure out what the new version should be and what to put into the changelog. | ||
Packaging and releasing to the factorio mod portal is done with [this plugin](https://github.com/fgardt/semantic-release-factorio). \ | ||
Additionally the GitHub Action will also create a release in your repository on GitHub itself. | ||
|
||
Once you push new commits to the main branch the release action will trigger. \ | ||
First it will analyze all commits since the last release (determined from the last tag) to figure out if a new version should be released and what version it should be. \ | ||
To make this possible you need to follow a commit message convention. The default convention this template uses is [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) with the following types: | ||
|
||
| Commit type | Changelog section | | ||
| --------------------------- | ----------------- | | ||
| `feat` or `feature` | `Features` | | ||
| `fix` | `Bugfixes` | | ||
| `perf` or `performance` | `Optimizations` | | ||
| `compat` or `compatibility` | `Compatibility` | | ||
| `balance` | `Balancing` | | ||
| `graphics` | `Graphics` | | ||
| `sound` | `Sounds` | | ||
| `gui` | `Gui` | | ||
| `info` | `Info` | | ||
| `locale` | `Locale` | | ||
| `translate` | `Translation` | | ||
| `control` | `Control` | | ||
| `other` | `Changes` | | ||
|
||
Because a push to the main branch triggers the release action it is recommended to work on a separate branch until your work is done and then merge that branch into main to release it. \ | ||
_Or you just work locally and if you want to release you push your changes to main, up to you how you want to do it ;)_ | ||
|
||
# How to use | ||
|
||
## Repository setup | ||
|
||
Click the `Use this template` button and create your own repository. | ||
|
||
Once you have your new repository you need to add a Factorio token as a GitHub Actions secret so that the mod releasing can work. \ | ||
To get the token go to [Factorio's website](https://factorio.com/login) and login with your account. \ | ||
Then you need to go to your [profile](https://factorio.com/profile) and generate a new API key. \ | ||
The API key needs `Upload Mods`, `Publish Mods` and `Edit Mods` permissions. Copy the generated key. | ||
|
||
Now you need to go to your repository settings > `Secrets and variables` > `Actions` and add a new Repository secret called `FACTORIO_TOKEN` with your copied key as the secret. | ||
|
||
## Mod setup | ||
|
||
- Swap out the [`LICENSE`](LICENSE) to your own liking _**(especially change out my name for yours)**_ | ||
- Populate the [`info.json`](info.json) file with correct values _(the `version` field gets updated automatically)_ | ||
- Add the corresponding text into [`locale.cfg`](locale/en/locale.cfg) | ||
- Add a `thumbnail.png` to the root of the repository _([ideally 144x144px](https://wiki.factorio.com/Tutorial:Mod_structure#Files))_ | ||
|
||
# Misc | ||
|
||
## How the packaging works | ||
|
||
The [`semantic-release-factorio` plugin](https://github.com/fgardt/semantic-release-factorio) uses the `git archive` command to package the mod. \ | ||
That way you can specify what folders / files to exclude from your packaged mod by specifying them in [`.gitattributes`](.gitattributes). | ||
|
||
If you want to locally test packaging of your mod you can run the following command: | ||
```sh | ||
git archive --format zip --prefix [YOUR-MOD-NAME]/ --worktree-attributes --output [YOUR-MOD-NAME]_[VERSION].zip HEAD | ||
``` | ||
|
||
## Changing the commit message convention | ||
|
||
If you want to change the commit message convention you can do so by changing the 2 `preset` fields in the [`.releaserc.json`](.releaserc.json) file. \ | ||
Possible presets are: [`angular`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular), [`atom`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-atom), [`codemirror`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-codemirror), [`ember`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-ember), [`eslint`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-eslint), [`express`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-express), [`jquery`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-jquery), [`jshint`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-jshint), [`conventionalcommits`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits). | ||
|
||
Additionally you also need to modify the worflow file [`.github/workflows/release.yml`](.github/workflows/release.yml) to use the package that corresponds to your chosen preset. \ | ||
Replace `conventional-changelog-conventionalcommits` with `conventional-changelog-[YOUR PRESET]` accordingly. | ||
|
||
## Need help? | ||
|
||
Checkout the [official Factorio Discord](https://discord.gg/factorio) and check the pins in the `#mod-making` channel. \ | ||
There is also the [Lua API documentation](https://lua-api.factorio.com/latest/) and the [modding section in the wiki](https://wiki.factorio.com/Modding). |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "[internal-mod-name]", | ||
"version": "0.0.0", | ||
"title": "[MOD DISPLAY NAME]", | ||
"author": "[YOUR MODS.FACTORIO.COM USERNAME]", | ||
"homepage": "[HOMEPAGE/REPO URL]", | ||
"description": "[SHORT DESCRIPTION]", | ||
"factorio_version": "1.1", | ||
"dependencies": [ | ||
"base" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[mod-name] | ||
title=YOUR MOD TITLE | ||
|
||
[mod-description] | ||
description=YOUR MOD DESCRIPTION |