'How to package App.zip artifact in an installer in Github Actions
I'm a unity developer, and I am new to devops. I am using Github Actions to make a prototype CI/CD pipeline for a project. Currently I can build and attach the build artifact to a release after every push. When I download this from the release, I get a .zip file with my project in it. This is expected, as it is how Unity builds games natively.
I want to make an installer for the game, so users do not have to open up a .zip file to find the game executable. I have watched a couple videos on how to do this manually using Inno and InstallCreator2, but I do not know how to do this using my CI/CD pipe (nor do I know if either of those technologies would be best for my use case)
Here is my yaml code. I made it following documentation and tutorials. I have a vague idea of what individual lines, steps, and jobs are doing, but my understanding is rudimentary at best. If something is terribly inefficient or otherwise bad, I probably don't know. I have added a couple comments to aid in my own understanding.
TL;DR: What job/ steps do I add to make the .zip output to an installer.exe type file?
EDIT: (updated YAML code) So, over the past day I tried creating an installer with inno on my local machine, and it worked! Pretty neat. Then I quickly descended into madness trying to edit the hardcode fields in the .iss file in my build server using YAML. At the end of the day it seems that it is rather challenging to get Inno itself on the build server (they have some instructions on the Inno github, but I got stuck trying to figure out how to apt-get Embarcadero Delphi.) Additionally, about 8 hours in I had the thought that "maybe trying to change the filepaths on a script generated in windows, so it is compatible with linux isn't the best way to go." Is there a linux-to-windows installer script generator? I was looking at this link earlier, but I feel like I am lacking a bunch of information to actually implement it.
name: Build project
on:
[push] #Comment this in (and add more triggers if you want), to have the job run on the set triggers (instead of manual). if using, might want to have this run on main branch merge only.
#workflow_dispatch: {} #Comment this in for a manual push button in github actions
jobs:
buildForAllSupportedPlatforms:
name: Build for ${{ matrix.targetPlatform }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
targetPlatform:
#- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
#- StandaloneWindows # Build a Windows standalone.
- StandaloneWindows64 # Build a Windows 64-bit standalone.
#- StandaloneLinux64 # Build a Linux 64-bit standalone.
#- iOS # Build an iOS player.
#- Android # Build an Android .apk standalone app.
#- WebGL # WebGL.
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
lfs: true
- name: cache
uses: actions/cache@v2
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-
- name: build unity project
uses: game-ci/unity-builder@v2
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
- name: upload build artifact
uses: actions/upload-artifact@v2
with:
name: Build-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
- name: Set Up Enviorment Varibles for installers
run: |
echo "pathStartpoint=$(pwd)" >> $GITHUB_ENV
cd .installer
echo "installedDirPath=$(pwd)" >> $GITHUB_ENV
echo "appVersion=$(less VersionInfo.txt)" >> $GITHUB_ENV
echo "iconPath=$(ls -d *.ico | tail -n +1 | head -1)" >> $GITHUB_ENV
echo "appId=$(uuidgen)" >> $GITHUB_ENV
cd ../build
echo "outputDir=$(pwd)" >> $GITHUB_ENV
- name: Create Windows Installer using Inno script
if: matrix.targetPlatform == 'StandaloneWindows64' #Conditional task
run: |
cd ${{ env.pathStartpoint }}
cd build/StandaloneWindows64
echo 'refactoring build file arrangment for inno file'
sudo mkdir tempDir1 tempDir2
sudo mv ${{ matrix.targetPlatform }}_Data /tempDir1
sudo mv tempDir1 ${{ matrix.targetPlatform }}_Data
sudo mv MonoBleedingEdge /tempDir2
sudo mv tempDir2 MonoBleedingEdge
echo 'finished refactoring build file arrangment'
echo 'Making a copy of WindowsInstaller64.iss'
cd ../..
sudo cp ./.installer/WindowsInstaller64.iss ./build
echo 'Finished making copy'
echo 'setting installer values'
cd ./build
sudo sed -i 's/#define MyAppName "UNITYWINDOWSBUILD"/#define MyAppName "${{ github.event.repository.name }}"/g' WindowsInstaller64.iss
echo 'set MyAppName'
sudo sed -i 's/#define MyAppVersion "1.11"/#define MyAppVersion "${{ env.appVersion }}"/g' WindowsInstaller64.iss
echo 'set MyAppVersion'
sudo sed -i 's/AppId={{76999C4F-90E2-49D0-8EF2-C315F16CEAD6}/AppId={{"${{ env.appId }}"}/g' WindowsInstaller64.iss
echo 'set AppId'
sudo sed -i 's,LicenseFile=EXAMPLELicense.txt,LicenseFile=${{ env.installedDirPath }}/License.txt,g' WindowsInstaller64.iss
echo 'set LicenseFile path'
sudo sed -i 's,InfoBeforeFile=EXAMPLEPreInstall.txt,InfoBeforeFile=${{ env.installedDirPath }}/PreInstall.txt,g' WindowsInstaller64.iss
echo 'set PreInstallFile path'
sudo sed -i 's,InfoAfterFile=EXAMPLEPostInstall.txt,InfoAfterFile=${{ env.installedDirPath }}/PostInstall.txt,g' WindowsInstaller64.iss
echo 'set PostInstallFile path'
sudo sed -i 's,OutputDir=EXAMPLEDIR,OutputDir=${{ env.outputDir }},g' WindowsInstaller64.iss
echo 'set Output path'
sudo sed -i 's,OutputBaseFilename=EXAMPLEPROJ_Setup(x64),OutputBaseFilename=StandaloneWindows_Setup(x64),g' WindowsInstaller64.iss
echo 'set OutputFile name'
sudo sed -i 's,SetupIconFile=EXAMPLEICONPATH.ico,SetupIconFile=${{ env.installedDirPath }}/${{ env.iconPath }},g' WindowsInstaller64.iss
echo 'set Icon file path name'
sudo sed -i 's,Source: "EXAMPLEPATH/{#MyAppExeName}",Source: "${{ env.pathStartpoint }}/build/StandaloneWindows64/{#MyAppExeName}",g' WindowsInstaller64.iss
echo 'set executable path'
sudo sed -i 's,Source: "EXAMPLEPATH/UnityCrashHandler64.exe",Source: "${{ env.pathStartpoint }}/build/StandaloneWindows64/UnityCrashHandler64.exe",g' WindowsInstaller64.iss
echo 'set Crash Handler path'
sudo sed -i 's,Source: "EXAMPLEPATH/UnityPlayer.dll",Source: "${{ env.pathStartpoint }}/build/StandaloneWindows64/UnityPlayer.dll",g' WindowsInstaller64.iss
echo 'set unity player path'
sudo sed -i 's,Source: "EXAMPLEPATH/StandaloneWindows64_Data/*",Source: "${{ env.pathStartpoint }}/build/StandaloneWindows64/StandaloneWindows64_Data/*"",g' WindowsInstaller64.iss
echo 'set build Data path'
sudo sed -i 's,Source: "EXAMPLEPATH/MonoBleedingEdge/*",Source: "${{ env.pathStartpoint }}/build/StandaloneWindows64/MonoBleedingEdge/*",g' WindowsInstaller64.iss
echo 'set monoBleedingEdge path'
echo 'Finished setting installer values'
less WindowsInstaller64.iss
echo downloading Inno
cd ~
sudo git clone https://github.com/jrsoftware/issrc.git is
cd is
sudo git submodule init
sudo git submodule update
sudo iscc ${{ env.pathStartpoint }}/build/WindowsInstaller64.iss
#Add another upload build artifact step to upload the windows installer
release-project:
name: release for ${{ matrix.targetPlatform }}
runs-on: ubuntu-latest
needs: buildForAllSupportedPlatforms
strategy:
fail-fast: false
matrix:
targetPlatform:
#- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
#- StandaloneWindows # Build a Windows standalone.
- StandaloneWindows64 # Build a Windows 64-bit standalone.
#- StandaloneLinux64 # Build a Linux 64-bit standalone.
#- iOS # Build an iOS player.
#- Android # Build an Android .apk standalone app.
#- WebGL # WebGL.
steps:
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: Build-${{ matrix.targetPlatform }}
- name: Archive Artifact Content
uses: thedoctor0/zip-release@master
with:
filename: ${{ matrix.targetPlatform }}.zip
- name: Create Github Release
id: create-new-release
uses: "marvinpinto/action-automatic-releases@latest" #NOTE: If this step breaks, it may be because the latest commit to marvinpinto/... broke the action. refactor this to use stable version instead of @latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}" # This token is provided by Actions, you do not need to create your own token
automatic_release_tag: "latest-${{ matrix.targetPlatform }}"
prerelease: false
title: "Release-${{ matrix.targetPlatform }}-v${{ github.run_number }}"
- name: Upload Release Asset Versioned #This attaches the built .zip file to the release with the version in the name
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-new-release.outputs.upload_url }} # This pulls from the CREATE GITHUB RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ matrix.targetPlatform }}.zip
asset_name: build_${{ matrix.targetPlatform }}-v${{ github.run_number }}.zip
asset_content_type: application/zip
- name: Upload Release Asset Static #This attaches the built .zip file to the release without the version in the name. This is good for a consitant download URL for sites
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-new-release.outputs.upload_url }} # This pulls from the CREATE GITHUB RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ matrix.targetPlatform }}.zip
asset_name: build_${{ matrix.targetPlatform }}-latest.zip
asset_content_type: application/zip
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
