diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 111370c..0e868ac 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,214 +2,53 @@ name: BYTEPATH CI on: push: - branches: [main] - tags: [pre*, v*] + tags: '*' pull_request: -env: - BUILD_TYPE: ${{ fromJSON('["dev", "release"]')[startsWith(github.ref, 'refs/tags/v')] }} - CORE_LOVE_PACKAGE_PATH: ./core.love - CORE_LOVE_ARTIFACT_NAME: BYTEPATH_love_package - jobs: - get-info: - runs-on: ubuntu-latest - outputs: - app-name: ${{ steps.app-info.outputs.app-name }} - version: ${{ steps.app-info.outputs.version }} - commit-hash: ${{ steps.git-info.outputs.commit-hash }} - base-name: ${{ steps.assemble-base-name.outputs.base-name }} - steps: - - uses: actions/checkout@v3 - - name: Install lua - run: | - sudo apt-get install lua5.1 -y - - name: Get app info - id: app-info - shell: lua {0} - run: | - local version = require "version" - os.execute('echo "app-name=BYTEPATH" >> $GITHUB_OUTPUT') - os.execute('echo "version=' .. version .. '" >> $GITHUB_OUTPUT') - - name: Get git info - id: git-info - shell: bash - run: | - COMMIT_HASH=$(git rev-parse --short ${{ GITHUB.SHA }}) - echo "commit-hash=$COMMIT_HASH" >> $GITHUB_OUTPUT - - name: Assemble package base name - id: assemble-base-name - shell: bash - run: | - BASE_NAME=BYTEPATH_${{ steps.app-info.outputs.version }}_${{ steps.git-info.outputs.commit-hash }}_#${{ GITHUB.RUN_NUMBER }} - echo "base-name=$BASE_NAME" >> $GITHUB_OUTPUT - - build-core: + build: runs-on: ubuntu-latest - needs: get-info env: OUTPUT_FOLDER: ./build - RELEASE_FOLDER: ./release steps: - uses: actions/checkout@v3 with: submodules: recursive - - name: Process app name - id: process-app-name - shell: python3 {0} - run: | - import os - import re - with open(os.getenv('GITHUB_OUTPUT'), 'a') as f: - f.write('product-name=' + re.sub(r'[^A-Za-z0-9]+', '_', '${{ needs.get-info.outputs.app-name }}') + '\n') - - name: Build core love package - uses: love-actions/love-actions-core@v1 - with: - build-list: "*.lua LICENSE README.md libraries objects resources rooms" - package-path: ${{ env.CORE_LOVE_PACKAGE_PATH }} - - name: Upload core love package + - name: Build artfacts + run: ./release.sh + - name: Prepare Artifact Names + run: | + echo "ARTIFACT_NAME_LOVE=$(find build -iname '*.love' -printf '%f\n')" >> "$GITHUB_ENV" + echo "ARTIFACT_NAME_WIN32=$(find build -iname '*win32*' -printf '%f\n')" >> "$GITHUB_ENV" + echo "ARTIFACT_NAME_DEFAULT_APPIMAGE=$(find build -iname 'BYTEPATH*.AppImage' -printf '%f\n')" >> "$GITHUB_ENV" + echo "ARTIFACT_NAME_DROP-IN_APPIMAGE=$(find build -iname 'game*.AppImage' -printf '%f\n')" >> "$GITHUB_ENV" + - name: Upload Artifact (love) + if: ${{ !github.event.act }} # skip during local actions testing uses: actions/upload-artifact@v3 with: - name: ${{ env.CORE_LOVE_ARTIFACT_NAME }} - path: ${{ env.CORE_LOVE_PACKAGE_PATH }} - - name: Rename love package - run: | - mkdir -p ${{ env.OUTPUT_FOLDER }} - mv ${{ env.CORE_LOVE_PACKAGE_PATH }} ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.love - - name: Upload artifact + name: ${{ env.ARTIFACT_NAME_LOVE }} + path: build/${{ env.ARTIFACT_NAME_LOVE }} + - name: Upload Artifact (win32) + if: ${{ !github.event.act }} # skip during local actions testing uses: actions/upload-artifact@v3 with: - name: ${{ needs.get-info.outputs.base-name }}_Core_love - path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.love - - name: Prepare for release - if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }} - shell: bash - run: | - mkdir -p ${{ env.RELEASE_FOLDER }} - cp ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.love ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Bare.love - - name: Upload release - if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }} - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - artifacts: ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Bare.love - body: ${{ needs.get-info.outputs.update-note }} - name: ${{ needs.get-info.outputs.update-title }} - prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }} - - build-linux: - runs-on: ubuntu-latest - needs: [get-info, build-core] - env: - OUTPUT_FOLDER: ./build - RELEASE_FOLDER: ./release - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - name: Process app name - id: process-app-name - shell: python3 {0} - run: | - import os - import re - - product_name = re.sub(r'[^A-Za-z0-9]+', '-', '${{ needs.get-info.outputs.app-name }}').strip('-').lower() - with open(os.getenv('GITHUB_OUTPUT'), 'a') as f: - f.write('bundle-id=org.26f-studio.' + product_name + '\n') - f.write('product-name=' + product_name + '\n') - - name: Download core love package - uses: actions/download-artifact@v3 - with: - name: ${{ env.CORE_LOVE_ARTIFACT_NAME }} - - name: Build Linux packages - id: build-packages - uses: love-actions/love-actions-linux@v1 - with: - app-name: ${{ needs.get-info.outputs.app-name }} - version-string: ${{ needs.get-info.outputs.version }} - icon-path: ./resources/graphics/icon.png - love-package: ${{ env.CORE_LOVE_PACKAGE_PATH }} - product-name: ${{ steps.process-app-name.outputs.product-name }} - output-folder: ${{ env.OUTPUT_FOLDER }} - - name: Upload AppImage artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ needs.get-info.outputs.base-name }}_Linux_AppImage - path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.AppImage - - name: Prepare for release - if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }} - shell: bash - run: | - mkdir -p ${{ env.RELEASE_FOLDER }} - cp ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}.AppImage ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Linux.AppImage - - name: Upload release - if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }} - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - artifacts: | - ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Linux.AppImage - body: ${{ needs.get-info.outputs.update-note }} - name: ${{ needs.get-info.outputs.update-title }} - prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }} - - build-windows: - runs-on: windows-latest - needs: [get-info, build-core] - env: - OUTPUT_FOLDER: ./build - RELEASE_FOLDER: ./release - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - name: Process app name - id: process-app-name - shell: python3 {0} - run: | - import os - import re - with open(os.getenv('GITHUB_OUTPUT'), 'a') as f: - f.write('product-name=' + re.sub(r'[^A-Za-z0-9]+', '_', '${{ needs.get-info.outputs.app-name }}') + '\n') - - name: Download core love package - uses: actions/download-artifact@v3 - with: - name: ${{ env.CORE_LOVE_ARTIFACT_NAME }} - - name: Build Windows packages - id: build-packages - uses: love-actions/love-actions-windows@v1 - with: - icon-path: ./.github/buildbits/icon.ico - love-package: ${{ env.CORE_LOVE_PACKAGE_PATH }} - product-name: ${{ steps.process-app-name.outputs.product-name }} - output-folder: ${{ env.OUTPUT_FOLDER }} - - name: Upload 32-bit artifact + name: ${{ env.ARTIFACT_NAME_WIN32 }} + path: build/${{ env.ARTIFACT_NAME_WIN32 }} + - name: Upload artifact + if: ${{ !github.event.act }} # skip during local actions testing uses: actions/upload-artifact@v3 with: - name: ${{ needs.get-info.outputs.base-name }}_Windows_x86 - path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_x86.zip - - name: Upload 64-bit artifact + name: ${{ env.ARTIFACT_NAME_DEFAULT_APPIMAGE }} + path: build/${{ env.ARTIFACT_NAME_DEFAULT_APPIMAGE }} + - name: Upload artifact + if: ${{ !github.event.act }} # skip during local actions testing uses: actions/upload-artifact@v3 with: - name: ${{ needs.get-info.outputs.base-name }}_Windows_x64 - path: ${{ env.OUTPUT_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_x64.zip - - name: Prepare for release - if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }} - shell: bash - run: | - mkdir -p ${{ env.RELEASE_FOLDER }} - 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 - 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 + name: ${{ env.ARTIFACT_NAME_DROP-IN_APPIMAGE }} + path: build/${{ env.ARTIFACT_NAME_DROP-IN_APPIMAGE }} - name: Upload release if: ${{ startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v') }} uses: ncipollo/release-action@v1 with: - allowUpdates: true - artifacts: | - ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Windows_x86.zip - ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Windows_x64.zip - ${{ env.RELEASE_FOLDER }}/${{ steps.process-app-name.outputs.product-name }}_Windows_installer.exe - body: ${{ needs.get-info.outputs.update-note }} - name: ${{ needs.get-info.outputs.update-title }} + artifacts: build/* prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }} diff --git a/release.sh b/release.sh index 1efb1c1..88bc027 100755 --- a/release.sh +++ b/release.sh @@ -63,7 +63,12 @@ chmod +x 'squashfs-root/bin/BYTEPATH' rm 'squashfs-root/love.desktop' cp "${repo_dir}/resources/BYTEPATH.desktop" 'squashfs-root/' -./appimagetool-x86_64.AppImage 'squashfs-root' 'BYTEPATH.AppImage' +if [ "${CI:-'false'}" = 'true' ] ; then + # we're in a container, fuse won't work + ./appimagetool-x86_64.AppImage --appimage-extract-and-run 'squashfs-root' 'BYTEPATH.AppImage' +else + ./appimagetool-x86_64.AppImage 'squashfs-root' 'BYTEPATH.AppImage' +fi mv 'BYTEPATH.AppImage' "$repo_dir/build"