Skip to content

Commit

Permalink
ci: create build ci for push/prs
Browse files Browse the repository at this point in the history
  • Loading branch information
PythiaUF authored and JMalegni committed Oct 6, 2024
1 parent 63e8c18 commit d9205ae
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build Bytes of Love
on:
- push
- pull_request

jobs:
renpy-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Extract short commit hash
shell: bash
run: echo "git_hash=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
id: ref

- name: Setup Ren'Py and Build
run: |
wget https://www.renpy.org/dl/8.3.2/renpy-8.3.2-sdk.tar.bz2
tar -xf renpy-8.3.2-sdk.tar.bz2
( cd renpy-8.3.2-sdk && ./renpy.sh launcher distribute ../BytesOfLove --destination ../dist --package win --package mac --package linux )
- name: Process Files
run: python .github/workflows/process.py ${{ steps.ref.outputs.git_hash }}

- name: Upload Linux Build
uses: actions/upload-artifact@v4
with:
name: BytesOfLove-linux-${{ steps.ref.outputs.git_hash }}
path: dist/BytesOfLove-linux-${{ steps.ref.outputs.git_hash }}.tar.bz2
compression-level: 0

- name: Upload Mac Build
uses: actions/upload-artifact@v4
with:
name: BytesOfLove-mac-${{ steps.ref.outputs.git_hash }}
path: dist/BytesOfLove-mac-${{ steps.ref.outputs.git_hash }}.zip
compression-level: 0

- name: Upload Windows Build
uses: actions/upload-artifact@v4
with:
name: BytesOfLove-win-${{ steps.ref.outputs.git_hash }}
path: dist/BytesOfLove-win-${{ steps.ref.outputs.git_hash }}
31 changes: 31 additions & 0 deletions .github/workflows/process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sys
from pathlib import Path
from zipfile import ZipFile

commit_hash = sys.argv[1]

files = Path("dist").glob('*')

for a_file in files:
if not a_file.is_file():
continue

if a_file.suffix == ".zip":
platform = a_file.stem.split("-")[-1].removesuffix(".zip")

if platform == "win":
print("Extracting", a_file)
with ZipFile(a_file, 'r') as zip_ref:
zip_ref.extractall(f"dist/BytesOfLove-{platform}-{commit_hash}")
print("Extracted", a_file)
else:
# due to https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss,
# we don't want to extract the file in the fears of losing certain permissions
# windows doesn't care though
print("Renaming", a_file)
a_file.rename(f"dist/BytesOfLove-{platform}-{commit_hash}.zip")

elif a_file.suffix == ".bz2":
# see above
print("Renaming", a_file)
a_file.rename("dist/BytesOfLove-linux-" + commit_hash + ".tar.bz2")

0 comments on commit d9205ae

Please sign in to comment.