Skip to content

Commit 19be52b

Browse files
committed
Add release management to workflow
1 parent 6c57d88 commit 19be52b

3 files changed

Lines changed: 169 additions & 95 deletions

File tree

.github/workflows/build.yaml

Lines changed: 0 additions & 87 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "Tag / Release name (leave empty for dry-run)"
8+
required: false
9+
10+
env:
11+
pyinstaller-version: "4.0"
12+
name: modimporter
13+
artifacts-content-type: application/zip
14+
15+
jobs:
16+
tag-and-release:
17+
name: Tag and create release
18+
runs-on: ubuntu-latest
19+
outputs:
20+
upload_url: ${{ steps.release.outputs.upload_url }}
21+
steps:
22+
- name: Checkout files
23+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
24+
25+
- name: Tag
26+
if: github.event.inputs.tag
27+
run: |
28+
git tag ${{ github.event.inputs.tag }}
29+
git push origin --tags
30+
31+
- name: Create release
32+
if: github.event.inputs.tag
33+
id: release
34+
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e
35+
with:
36+
release_name: ${{ github.event.inputs.tag }}
37+
tag_name: ${{ github.event.inputs.tag }}
38+
body_path: ${{ env.release-notes }}
39+
commitish: main
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
43+
archive-and-upload-python-artifacts:
44+
name: Archive and upload Python artifacts
45+
needs: tag-and-release
46+
runs-on: ubuntu-latest
47+
env:
48+
artifacts-python: modimporter-python.zip
49+
license: LICENSE
50+
readme: README.md
51+
sjson: sjson
52+
steps:
53+
- name: Checkout files
54+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
55+
with:
56+
ref: ${{ github.event.inputs.tag || github.sha }}
57+
submodules: true
58+
59+
- name: Consolidate Python artifacts in a zip
60+
run: |
61+
rm -r ${{ env.sjson }}/.git
62+
zip ${{ env.artifacts-python }} -r ${{ env.name }}.py ${{ env.sjson }} ${{ env.license }} ${{ env.readme }}
63+
64+
- name: Upload artifacts to workflow
65+
uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074
66+
with:
67+
name: ${{ env.artifacts-python }}
68+
path: ${{ env.artifacts-python }}
69+
retention-days: 1
70+
71+
- name: Upload artifacts to release
72+
if: needs.tag-and-release.outputs.upload_url
73+
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5
74+
with:
75+
upload_url: ${{ needs.tag-and-release.outputs.upload_url }}
76+
asset_path: ${{ env.artifacts-python }}
77+
asset_name: ${{ env.artifacts-python }}
78+
asset_content_type: ${{ env.artifacts-content-type }}
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
82+
build-and-upload-binaries:
83+
name: Build and upload binaries
84+
needs: tag-and-release
85+
runs-on: ${{ matrix.os }}
86+
strategy:
87+
matrix:
88+
os: [windows-latest, macos-latest, ubuntu-latest]
89+
include:
90+
- os: windows-latest
91+
pip-cache-path: ~\AppData\Local\pip\Cache
92+
artifacts: modimporter-windows.zip
93+
- os: macos-latest
94+
pip-cache-path: ~/Library/Caches/pip
95+
artifacts: modimporter-macos.zip
96+
- os: ubuntu-latest
97+
pip-cache-path: ~/.cache/pip
98+
artifacts: modimporter-linux.zip
99+
steps:
100+
- name: Checkout files
101+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
102+
with:
103+
ref: ${{ github.event.inputs.tag || github.sha }}
104+
submodules: true
105+
106+
- name: Set up Python
107+
uses: actions/setup-python@dc73133d4da04e56a135ae2246682783cc7c7cb6
108+
with:
109+
python-version: 3.9
110+
111+
- name: Retrieve pip dependencies from cache
112+
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
113+
with:
114+
path: |
115+
${{ env.pythonLocation }}\lib\site-packages
116+
${{ matrix.pip-cache-path }}
117+
key: ${{ runner.os }}-pip-cache-${{ env.pyinstaller-version }}
118+
119+
- name: Install pip dependencies
120+
run: python -m pip install pyinstaller==${{ env.pyinstaller-version }}
121+
122+
- name: Build binaries with PyInstaller
123+
run: python -m PyInstaller --onefile ${{ env.name }}.py --name ${{ env.name }}
124+
125+
- name: Consolidate artifacts in a zip
126+
if: startsWith(runner.os, 'Windows')
127+
run: Compress-Archive dist/${{ env.name }}.exe ${{ matrix.artifacts }}
128+
129+
- name: Consolidate artifacts in a zip
130+
if: startsWith(runner.os, 'macOS') || startsWith(runner.os, 'Linux')
131+
run: |
132+
mv dist/${{ env.name }} .
133+
zip ${{ matrix.artifacts }} -r ${{ env.name }}
134+
135+
- name: Upload artifacts to workflow
136+
uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074
137+
with:
138+
name: ${{ matrix.artifacts }}
139+
path: ${{ matrix.artifacts }}
140+
retention-days: 1
141+
142+
- name: Upload artifacts to release
143+
if: needs.tag-and-release.outputs.upload_url
144+
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5
145+
with:
146+
upload_url: ${{ needs.tag-and-release.outputs.upload_url }}
147+
asset_path: ${{ matrix.artifacts }}
148+
asset_name: ${{ matrix.artifacts }}
149+
asset_content_type: ${{ env.artifacts-content-type }}
150+
env:
151+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
# Mod Importer
2+
23
For SuperGiantGames's games (To be replaced by SGGMI)
34

45
https://www.nexusmods.com/hades/mods/26
56

67
## Development
78

8-
Binaries can be built from GitHub Actions runners using the build workflow
9-
available [here](https://github.com/SGG-Modding/sgg-mod-modimporter/actions/workflows/build.yaml).
9+
### Release workflow
10+
11+
New releases can be created from GitHub Actions using the release workflow
12+
available [here](https://github.com/SGG-Modding/sgg-mod-modimporter/actions/workflows/release.yaml).
13+
14+
The release workflow takes a tag / release name as input parameter to tag the
15+
repository, create a new release, build binaries, and upload them to the
16+
release.
17+
18+
If the tag / release name is omitted and left blank, the workflow will run in
19+
dry-run mode (no tag / release, only binaries build) for testing purposes.
1020

11-
To build binaries locally:
21+
### Build binaries locally
1222

1323
- Install [PyInstaller](https://pypi.org/project/pyinstaller/):
1424

@@ -17,11 +27,11 @@ python -m pip install pyinstaller==4.0
1727
```
1828

1929
> Note that we use version 4.0 instead of the latest version to avoid getting
20-
flagged by too many antivirus solutions due to PyInstaller's
21-
pre-compiled bootloader. Older versions are less susceptible to this as AV
22-
solutions had more time to properly recognize and whitelist them, in particular
23-
from Microsoft antivirus (which is the single most important one not to get
24-
flagged by).
30+
> flagged by too many antivirus solutions due to PyInstaller's
31+
> pre-compiled bootloader. Older versions are less susceptible to this as AV
32+
> solutions had more time to properly recognize and whitelist them, in particular
33+
> from Microsoft antivirus (which is the single most important one not to get
34+
> flagged by).
2535
2636
- Build binaries:
2737

0 commit comments

Comments
 (0)