Build Desktop Artifacts #37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Desktop Artifacts | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| prepare: | |
| name: Prepare Build Version | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| build_version: ${{ steps.meta.outputs.build_version }} | |
| steps: | |
| - name: Determine CI build version | |
| id: meta | |
| shell: bash | |
| run: echo "build_version=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" | |
| prepare-ci-release: | |
| name: Prepare ci-latest Draft Release | |
| runs-on: ubuntu-22.04 | |
| needs: prepare | |
| steps: | |
| - name: Create or clear ci-latest draft release | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| const tag = "ci-latest"; | |
| const releaseName = "CI Latest"; | |
| const releases = await github.paginate(github.rest.repos.listReleases, { | |
| owner, | |
| repo, | |
| per_page: 100, | |
| }); | |
| let release = releases.find((candidate) => candidate.tag_name === tag); | |
| if (!release) { | |
| core.info(`Draft release ${tag} does not exist yet; creating it now.`); | |
| const created = await github.rest.repos.createRelease({ | |
| owner, | |
| repo, | |
| tag_name: tag, | |
| name: releaseName, | |
| draft: true, | |
| prerelease: true, | |
| make_latest: "false", | |
| }); | |
| release = created.data; | |
| } else { | |
| core.info(`Using existing release ${release.id} for tag ${tag}.`); | |
| } | |
| if (!release.assets || release.assets.length === 0) { | |
| core.info(`Release ${tag} has no assets to delete.`); | |
| return; | |
| } | |
| for (const asset of release.assets) { | |
| core.info(`Deleting old asset: ${asset.name}`); | |
| await github.rest.repos.deleteReleaseAsset({ | |
| owner, | |
| repo, | |
| asset_id: asset.id, | |
| }); | |
| } | |
| build-macos: | |
| name: macOS | |
| runs-on: macos-14 | |
| needs: [prepare, prepare-ci-release] | |
| env: | |
| SOLOKEYS_GUI_VERSION: ${{ needs.prepare.outputs.build_version }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install libusb | |
| run: brew install libusb | |
| - name: Build app bundle and DMG | |
| run: | | |
| chmod +x build_macos.sh | |
| ./build_macos.sh | |
| - name: Upload macOS to draft release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ci-latest | |
| name: CI Latest | |
| draft: true | |
| prerelease: true | |
| make_latest: false | |
| overwrite_files: true | |
| files: dist/SoloKeys-GUI-*.dmg | |
| build-windows: | |
| name: Windows | |
| runs-on: windows-2022 | |
| needs: [prepare, prepare-ci-release] | |
| env: | |
| SOLOKEYS_GUI_VERSION: ${{ needs.prepare.outputs.build_version }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Download libusb | |
| shell: pwsh | |
| run: | | |
| $ErrorActionPreference = "Stop" | |
| $zipPath = "$env:RUNNER_TEMP\libusb.zip" | |
| $extractDir = "$env:RUNNER_TEMP\libusb" | |
| Invoke-WebRequest ` | |
| -Uri "https://github.com/libusb/libusb/releases/download/v1.0.27/libusb-1.0.27.7z" ` | |
| -OutFile $zipPath | |
| 7z x $zipPath "-o$extractDir" | Out-Null | |
| $dllPath = Get-ChildItem -Path $extractDir -Recurse -Filter "libusb-1.0.dll" | | |
| Where-Object { $_.FullName -match "MS64\\dll\\libusb-1\.0\.dll$" } | | |
| Select-Object -First 1 -ExpandProperty FullName | |
| if (-not $dllPath) { | |
| throw "Could not locate libusb-1.0.dll in extracted archive." | |
| } | |
| "LIBUSB_PATH=$dllPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| - name: Install Inno Setup | |
| shell: pwsh | |
| run: choco install innosetup --no-progress -y | |
| - name: Build Windows package | |
| shell: cmd | |
| run: build_windows.bat | |
| - name: Upload Windows to draft release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ci-latest | |
| name: CI Latest | |
| draft: true | |
| prerelease: true | |
| make_latest: false | |
| overwrite_files: true | |
| files: dist/installer/SoloKeys-GUI-Setup-*.exe | |
| build-linux: | |
| name: Linux | |
| runs-on: ubuntu-22.04 | |
| needs: [prepare, prepare-ci-release] | |
| env: | |
| SOLOKEYS_GUI_VERSION: ${{ needs.prepare.outputs.build_version }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y dpkg-dev rpm | |
| - name: Build Linux artifacts | |
| run: | | |
| chmod +x build_linux_deb.sh | |
| chmod +x build_linux_rpm.sh | |
| ./build_linux_deb.sh | |
| ./build_linux_rpm.sh | |
| - name: Upload Linux to draft release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ci-latest | |
| name: CI Latest | |
| draft: true | |
| prerelease: true | |
| make_latest: false | |
| overwrite_files: true | |
| files: | | |
| dist/solokeys-gui_*.deb | |
| dist/solokeys-gui-*.rpm |