Skip to content

Commit 597bf39

Browse files
committed
Start building releases in Github Actions
1 parent 58966c7 commit 597bf39

File tree

1 file changed

+240
-0
lines changed

1 file changed

+240
-0
lines changed

.github/workflows/main.yml

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
name: BYTEPATH CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: [pre*, v*]
7+
pull_request:
8+
9+
env:
10+
BUILD_TYPE: ${{ fromJSON('["dev", "release"]')[startsWith(github.ref, 'refs/tags/v')] }}
11+
CORE_LOVE_PACKAGE_PATH: ./core.love
12+
CORE_LOVE_ARTIFACT_NAME: core_love_package
13+
14+
jobs:
15+
get-info:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
app-name: ${{ steps.app-info.outputs.app-name }}
19+
version: ${{ steps.app-info.outputs.version }}
20+
commit-hash: ${{ steps.git-info.outputs.commit-hash }}
21+
base-name: ${{ steps.assemble-base-name.outputs.base-name }}
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Install lua
25+
run: |
26+
sudo apt-get install lua5.1 -y
27+
- name: Get app info
28+
id: app-info
29+
shell: lua {0}
30+
run: |
31+
local version = require "version"
32+
os.execute('echo "app-name=BYTEPATH" >> $GITHUB_OUTPUT')
33+
os.execute('echo "version=' .. version .. '" >> $GITHUB_OUTPUT')
34+
- name: Get git info
35+
id: git-info
36+
shell: bash
37+
run: |
38+
COMMIT_HASH=$(git rev-parse --short ${{ GITHUB.SHA }})
39+
echo "commit-hash=$COMMIT_HASH" >> $GITHUB_OUTPUT
40+
- name: Assemble package base name
41+
id: assemble-base-name
42+
shell: bash
43+
run: |
44+
BASE_NAME=Techmino_${{ steps.app-info.outputs.version }}_${{ steps.git-info.outputs.commit-hash }}_#${{ GITHUB.RUN_NUMBER }}
45+
echo "base-name=$BASE_NAME" >> $GITHUB_OUTPUT
46+
47+
build-core:
48+
runs-on: ubuntu-latest
49+
needs: get-info
50+
env:
51+
OUTPUT_FOLDER: ./build
52+
RELEASE_FOLDER: ./release
53+
steps:
54+
- uses: actions/checkout@v3
55+
with:
56+
submodules: recursive
57+
- name: Process app name
58+
id: process-app-name
59+
shell: python3 {0}
60+
run: |
61+
import os
62+
import re
63+
with open(os.getenv('GITHUB_OUTPUT'), 'a') as f:
64+
f.write('product-name=' + re.sub(r'[^A-Za-z0-9]+', '_', '${{ needs.get-info.outputs.app-name }}') + '\n')
65+
- name: Build core love package
66+
uses: love-actions/love-actions-core@v1
67+
with:
68+
package-path: ${{ env.CORE_LOVE_PACKAGE_PATH }}
69+
- name: Upload core love package
70+
uses: actions/upload-artifact@v3
71+
with:
72+
name: ${{ env.CORE_LOVE_ARTIFACT_NAME }}
73+
path: ${{ env.CORE_LOVE_PACKAGE_PATH }}
74+
- name: Rename love package
75+
run: |
76+
mkdir -p ${{ env.OUTPUT_FOLDER }}
77+
mv ${{ env.CORE_LOVE_PACKAGE_PATH }} ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.love
78+
- name: Upload artifact
79+
uses: actions/upload-artifact@v3
80+
with:
81+
name: ${{ needs.get-info.outputs.base-name }}_Core_love
82+
path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.love
83+
- name: Prepare for release
84+
if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }}
85+
shell: bash
86+
run: |
87+
mkdir -p ${{ env.RELEASE_FOLDER }}
88+
cp ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.love ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Bare.love
89+
- name: Upload release
90+
if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }}
91+
uses: ncipollo/release-action@v1
92+
with:
93+
allowUpdates: true
94+
artifacts: ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Bare.love
95+
body: ${{ needs.get-info.outputs.update-note }}
96+
name: ${{ needs.get-info.outputs.update-title }}
97+
prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }}
98+
99+
auto-test:
100+
runs-on: ubuntu-latest
101+
needs: build-core
102+
steps:
103+
- uses: actions/checkout@v3
104+
with:
105+
submodules: recursive
106+
- name: Love actions for testing
107+
uses: love-actions/love-actions-test@v1
108+
with:
109+
font-path: ./parts/fonts/proportional.otf
110+
language-folder: ./parts/language
111+
112+
build-linux:
113+
runs-on: ubuntu-latest
114+
needs: [get-info, build-core, auto-test]
115+
env:
116+
OUTPUT_FOLDER: ./build
117+
RELEASE_FOLDER: ./release
118+
steps:
119+
- uses: actions/checkout@v3
120+
with:
121+
submodules: recursive
122+
- name: Process app name
123+
id: process-app-name
124+
shell: python3 {0}
125+
run: |
126+
import os
127+
import re
128+
129+
product_name = re.sub(r'[^A-Za-z0-9]+', '-', '${{ needs.get-info.outputs.app-name }}').strip('-').lower()
130+
with open(os.getenv('GITHUB_OUTPUT'), 'a') as f:
131+
f.write('bundle-id=org.26f-studio.' + product_name + '\n')
132+
f.write('product-name=' + product_name + '\n')
133+
- name: Download core love package
134+
uses: actions/download-artifact@v3
135+
with:
136+
name: ${{ env.CORE_LOVE_ARTIFACT_NAME }}
137+
- name: Add icon to love package
138+
run: |
139+
cp ./.github/build/linux/${{ env.BUILD_TYPE }}/icon.png media/image/icon.png
140+
zip -u ${{ env.CORE_LOVE_PACKAGE_PATH }} media/image/icon.png
141+
rm media/image/icon.png
142+
- name: Build Linux packages
143+
id: build-packages
144+
uses: love-actions/love-actions-linux@v1
145+
with:
146+
app-name: ${{ needs.get-info.outputs.app-name }}
147+
version-string: ${{ needs.get-info.outputs.version }}
148+
icon-path: ./.github/build/linux/${{ env.BUILD_TYPE }}/icon.png
149+
love-package: ${{ env.CORE_LOVE_PACKAGE_PATH }}
150+
product-name: ${{ steps.process-app-name.outputs.product-name }}
151+
output-folder: ${{ env.OUTPUT_FOLDER }}
152+
- name: Upload AppImage artifact
153+
uses: actions/upload-artifact@v3
154+
with:
155+
name: ${{ needs.get-info.outputs.base-name }}_Linux_AppImage
156+
path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.AppImage
157+
- name: Prepare for release
158+
if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }}
159+
shell: bash
160+
run: |
161+
mkdir -p ${{ env.RELEASE_FOLDER }}
162+
cp ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.AppImage ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Linux.AppImage
163+
cp ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.deb ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Linux.deb
164+
- name: Upload release
165+
if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }}
166+
uses: ncipollo/release-action@v1
167+
with:
168+
allowUpdates: true
169+
artifacts: |
170+
${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Linux.AppImage
171+
${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Linux.deb
172+
body: ${{ needs.get-info.outputs.update-note }}
173+
name: ${{ needs.get-info.outputs.update-title }}
174+
prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }}
175+
176+
build-windows:
177+
runs-on: windows-latest
178+
needs: [get-info, build-core, auto-test]
179+
env:
180+
OUTPUT_FOLDER: ./build
181+
RELEASE_FOLDER: ./release
182+
steps:
183+
- uses: actions/checkout@v3
184+
with:
185+
submodules: recursive
186+
- name: Process app name
187+
id: process-app-name
188+
shell: python3 {0}
189+
run: |
190+
import os
191+
import re
192+
with open(os.getenv('GITHUB_OUTPUT'), 'a') as f:
193+
f.write('product-name=' + re.sub(r'[^A-Za-z0-9]+', '_', '${{ needs.get-info.outputs.app-name }}') + '\n')
194+
- name: Download core love package
195+
uses: actions/download-artifact@v3
196+
with:
197+
name: ${{ env.CORE_LOVE_ARTIFACT_NAME }}
198+
- name: Build Windows packages
199+
id: build-packages
200+
uses: love-actions/love-actions-windows@v1
201+
with:
202+
icon-path: ./.github/build/windows/${{ env.BUILD_TYPE }}/icon.ico
203+
love-package: ${{ env.CORE_LOVE_PACKAGE_PATH }}
204+
product-name: ${{ steps.process-app-name.outputs.product-name }}
205+
output-folder: ${{ env.OUTPUT_FOLDER }}
206+
- name: Upload 32-bit artifact
207+
uses: actions/upload-artifact@v3
208+
with:
209+
name: ${{ needs.get-info.outputs.base-name }}_Windows_x86
210+
path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_x86.zip
211+
- name: Upload 64-bit artifact
212+
uses: actions/upload-artifact@v3
213+
with:
214+
name: ${{ needs.get-info.outputs.base-name }}_Windows_x64
215+
path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_x64.zip
216+
- name: Upload installer artifact
217+
uses: actions/upload-artifact@v3
218+
with:
219+
name: ${{ needs.get-info.outputs.base-name }}_Windows_installer
220+
path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_installer.exe
221+
- name: Prepare for release
222+
if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }}
223+
shell: bash
224+
run: |
225+
mkdir -p ${{ env.RELEASE_FOLDER }}
226+
cp ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_x86.zip ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Windows_x86.zip
227+
cp ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_x64.zip ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Windows_x64.zip
228+
cp ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_installer.exe ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Windows_installer.exe
229+
- name: Upload release
230+
if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }}
231+
uses: ncipollo/release-action@v1
232+
with:
233+
allowUpdates: true
234+
artifacts: |
235+
${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Windows_x86.zip
236+
${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Windows_x64.zip
237+
${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Windows_installer.exe
238+
body: ${{ needs.get-info.outputs.update-note }}
239+
name: ${{ needs.get-info.outputs.update-title }}
240+
prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }}

0 commit comments

Comments
 (0)