Skip to content

Commit d6cda06

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

File tree

2 files changed

+222
-0
lines changed

2 files changed

+222
-0
lines changed

.github/build/icon.ico

3.55 KB
Binary file not shown.

.github/workflows/main.yml

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
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=BYTEPATH_${{ 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+
build-linux:
100+
runs-on: ubuntu-latest
101+
needs: [get-info, build-core]
102+
env:
103+
OUTPUT_FOLDER: ./build
104+
RELEASE_FOLDER: ./release
105+
steps:
106+
- uses: actions/checkout@v3
107+
with:
108+
submodules: recursive
109+
- name: Process app name
110+
id: process-app-name
111+
shell: python3 {0}
112+
run: |
113+
import os
114+
import re
115+
116+
product_name = re.sub(r'[^A-Za-z0-9]+', '-', '${{ needs.get-info.outputs.app-name }}').strip('-').lower()
117+
with open(os.getenv('GITHUB_OUTPUT'), 'a') as f:
118+
f.write('bundle-id=org.26f-studio.' + product_name + '\n')
119+
f.write('product-name=' + product_name + '\n')
120+
- name: Download core love package
121+
uses: actions/download-artifact@v3
122+
with:
123+
name: ${{ env.CORE_LOVE_ARTIFACT_NAME }}
124+
- name: Build Linux packages
125+
id: build-packages
126+
uses: love-actions/love-actions-linux@v1
127+
with:
128+
app-name: ${{ needs.get-info.outputs.app-name }}
129+
version-string: ${{ needs.get-info.outputs.version }}
130+
icon-path: ./resources/graphics/icon.jpg
131+
love-package: ${{ env.CORE_LOVE_PACKAGE_PATH }}
132+
product-name: ${{ steps.process-app-name.outputs.product-name }}
133+
output-folder: ${{ env.OUTPUT_FOLDER }}
134+
- name: Upload AppImage artifact
135+
uses: actions/upload-artifact@v3
136+
with:
137+
name: ${{ needs.get-info.outputs.base-name }}_Linux_AppImage
138+
path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.AppImage
139+
- name: Prepare for release
140+
if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }}
141+
shell: bash
142+
run: |
143+
mkdir -p ${{ env.RELEASE_FOLDER }}
144+
cp ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.AppImage ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Linux.AppImage
145+
cp ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.deb ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Linux.deb
146+
- name: Upload release
147+
if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }}
148+
uses: ncipollo/release-action@v1
149+
with:
150+
allowUpdates: true
151+
artifacts: |
152+
${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Linux.AppImage
153+
${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Linux.deb
154+
body: ${{ needs.get-info.outputs.update-note }}
155+
name: ${{ needs.get-info.outputs.update-title }}
156+
prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }}
157+
158+
build-windows:
159+
runs-on: windows-latest
160+
needs: [get-info, build-core]
161+
env:
162+
OUTPUT_FOLDER: ./build
163+
RELEASE_FOLDER: ./release
164+
steps:
165+
- uses: actions/checkout@v3
166+
with:
167+
submodules: recursive
168+
- name: Process app name
169+
id: process-app-name
170+
shell: python3 {0}
171+
run: |
172+
import os
173+
import re
174+
with open(os.getenv('GITHUB_OUTPUT'), 'a') as f:
175+
f.write('product-name=' + re.sub(r'[^A-Za-z0-9]+', '_', '${{ needs.get-info.outputs.app-name }}') + '\n')
176+
- name: Download core love package
177+
uses: actions/download-artifact@v3
178+
with:
179+
name: ${{ env.CORE_LOVE_ARTIFACT_NAME }}
180+
- name: Build Windows packages
181+
id: build-packages
182+
uses: love-actions/love-actions-windows@v1
183+
with:
184+
icon-path: ./.github/build/icon.ico
185+
love-package: ${{ env.CORE_LOVE_PACKAGE_PATH }}
186+
product-name: ${{ steps.process-app-name.outputs.product-name }}
187+
output-folder: ${{ env.OUTPUT_FOLDER }}
188+
- name: Upload 32-bit artifact
189+
uses: actions/upload-artifact@v3
190+
with:
191+
name: ${{ needs.get-info.outputs.base-name }}_Windows_x86
192+
path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_x86.zip
193+
- name: Upload 64-bit artifact
194+
uses: actions/upload-artifact@v3
195+
with:
196+
name: ${{ needs.get-info.outputs.base-name }}_Windows_x64
197+
path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_x64.zip
198+
- name: Upload installer artifact
199+
uses: actions/upload-artifact@v3
200+
with:
201+
name: ${{ needs.get-info.outputs.base-name }}_Windows_installer
202+
path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_installer.exe
203+
- name: Prepare for release
204+
if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }}
205+
shell: bash
206+
run: |
207+
mkdir -p ${{ env.RELEASE_FOLDER }}
208+
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
209+
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
210+
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
211+
- name: Upload release
212+
if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }}
213+
uses: ncipollo/release-action@v1
214+
with:
215+
allowUpdates: true
216+
artifacts: |
217+
${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Windows_x86.zip
218+
${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Windows_x64.zip
219+
${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Windows_installer.exe
220+
body: ${{ needs.get-info.outputs.update-note }}
221+
name: ${{ needs.get-info.outputs.update-title }}
222+
prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }}

0 commit comments

Comments
 (0)