|
| 1 | +name: Modrinth App build |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + tags: |
| 7 | + - 'v*' |
| 8 | + paths: |
| 9 | + - .github/workflows/theseus-build.yml |
| 10 | + - 'apps/app/**' |
| 11 | + - 'apps/app-frontend/**' |
| 12 | + - 'packages/app-lib/**' |
| 13 | + - 'packages/app-macros/**' |
| 14 | + - 'packages/assets/**' |
| 15 | + - 'packages/ui/**' |
| 16 | + - 'packages/utils/**' |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + sign-windows-binaries: |
| 20 | + description: Sign Windows binaries |
| 21 | + type: boolean |
| 22 | + default: true |
| 23 | + required: false |
| 24 | + |
| 25 | +jobs: |
| 26 | + build: |
| 27 | + name: Build |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + platform: [macos-latest, windows-latest, ubuntu-22.04] |
| 32 | + include: |
| 33 | + - platform: macos-latest |
| 34 | + artifact-target-name: universal-apple-darwin |
| 35 | + - platform: windows-latest |
| 36 | + artifact-target-name: x86_64-pc-windows-msvc |
| 37 | + - platform: ubuntu-22.04 |
| 38 | + artifact-target-name: x86_64-unknown-linux-gnu |
| 39 | + |
| 40 | + runs-on: ${{ matrix.platform }} |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: 📥 Check out code |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + fetch-depth: 0 |
| 47 | + |
| 48 | + - name: 🧰 Setup Rust toolchain |
| 49 | + uses: actions-rust-lang/setup-rust-toolchain@v1 |
| 50 | + with: |
| 51 | + rustflags: '' |
| 52 | + target: ${{ startsWith(matrix.platform, 'macos') && 'x86_64-apple-darwin' || '' }} |
| 53 | + |
| 54 | + - name: 🧰 Install pnpm |
| 55 | + uses: pnpm/action-setup@v4 |
| 56 | + |
| 57 | + - name: 🧰 Setup Node.js |
| 58 | + uses: actions/setup-node@v4 |
| 59 | + with: |
| 60 | + node-version-file: .nvmrc |
| 61 | + cache: pnpm |
| 62 | + |
| 63 | + - name: 🧰 Install Linux build dependencies |
| 64 | + if: startsWith(matrix.platform, 'ubuntu') |
| 65 | + run: | |
| 66 | + sudo apt-get update |
| 67 | + sudo apt-get install -yq libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev |
| 68 | +
|
| 69 | + - name: 🧰 Setup Dasel |
| 70 | + uses: jaxxstorm/action-install-gh-release@v2.1.0 |
| 71 | + with: |
| 72 | + repo: TomWright/dasel |
| 73 | + tag: v2.8.1 |
| 74 | + extension-matching: disable |
| 75 | + rename-to: ${{ startsWith(matrix.platform, 'windows') && 'dasel.exe' || 'dasel' }} |
| 76 | + chmod: 0755 |
| 77 | + |
| 78 | + - name: ⚙️ Set application version |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + APP_VERSION="$(git describe --tags --always | sed -E 's/-([0-9]+)-(g[0-9a-fA-F]+)$/-canary+\1.\2/')" |
| 82 | + echo "Setting application version to $APP_VERSION" |
| 83 | + dasel put -f apps/app/Cargo.toml -t string -v "${APP_VERSION#v}" 'package.version' |
| 84 | + dasel put -f packages/app-lib/Cargo.toml -t string -v "${APP_VERSION#v}" 'package.version' |
| 85 | + dasel put -f apps/app-frontend/package.json -t string -v "${APP_VERSION#v}" 'version' |
| 86 | +
|
| 87 | + - name: 💨 Setup Turbo cache |
| 88 | + uses: rharkor/caching-for-turbo@v1.8 |
| 89 | + |
| 90 | + - name: 🧰 Install dependencies |
| 91 | + run: pnpm install |
| 92 | + |
| 93 | + - name: ✍️ Set up Windows code signing |
| 94 | + if: startsWith(matrix.platform, 'windows') |
| 95 | + shell: bash |
| 96 | + run: | |
| 97 | + if [ '${{ startsWith(github.ref, 'refs/tags/v') || inputs.sign-windows-binaries }}' = 'true' ]; then |
| 98 | + choco install jsign --ignore-dependencies # GitHub runners come with a global Java installation already |
| 99 | + else |
| 100 | + dasel delete -f apps/app/tauri-release.conf.json 'bundle.windows.signCommand' |
| 101 | + fi |
| 102 | +
|
| 103 | + - name: 🔨 Build macOS app |
| 104 | + run: pnpm --filter=@modrinth/app run tauri build --target universal-apple-darwin --config tauri-release.conf.json |
| 105 | + if: startsWith(matrix.platform, 'macos') |
| 106 | + env: |
| 107 | + ENABLE_CODE_SIGNING: ${{ secrets.APPLE_CERTIFICATE }} |
| 108 | + APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} |
| 109 | + APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} |
| 110 | + APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }} |
| 111 | + APPLE_ID: ${{ secrets.APPLE_ID }} |
| 112 | + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} |
| 113 | + APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} |
| 114 | + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} |
| 115 | + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} |
| 116 | + |
| 117 | + - name: 🔨 Build Linux app |
| 118 | + run: pnpm --filter=@modrinth/app run tauri build --config tauri-release.conf.json |
| 119 | + if: startsWith(matrix.platform, 'ubuntu') |
| 120 | + env: |
| 121 | + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} |
| 122 | + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} |
| 123 | + |
| 124 | + - name: 🔨 Build Windows app |
| 125 | + run: | |
| 126 | + [System.Convert]::FromBase64String("$env:DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_BASE64") | Set-Content -Path signer-client-cert.p12 -AsByteStream |
| 127 | + $env:DIGICERT_ONE_SIGNER_CREDENTIALS = "$env:DIGICERT_ONE_SIGNER_API_KEY|$PWD\signer-client-cert.p12|$env:DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_PASSWORD" |
| 128 | + $env:JAVA_HOME = "$env:JAVA_HOME_11_X64" |
| 129 | + pnpm --filter=@modrinth/app run tauri build --config tauri-release.conf.json --verbose --bundles 'nsis,updater' |
| 130 | + Remove-Item -Path signer-client-cert.p12 -ErrorAction SilentlyContinue |
| 131 | + if: startsWith(matrix.platform, 'windows') |
| 132 | + env: |
| 133 | + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} |
| 134 | + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} |
| 135 | + DIGICERT_ONE_SIGNER_API_KEY: ${{ secrets.DIGICERT_ONE_SIGNER_API_KEY }} |
| 136 | + DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_BASE64: ${{ secrets.DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_BASE64 }} |
| 137 | + DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_PASSWORD: ${{ secrets.DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_PASSWORD }} |
| 138 | + |
| 139 | + - name: 📤 Upload app bundles |
| 140 | + uses: actions/upload-artifact@v4 |
| 141 | + with: |
| 142 | + name: App bundle (${{ matrix.artifact-target-name }}) |
| 143 | + path: | |
| 144 | + target/release/bundle/appimage/Modrinth App_*.AppImage* |
| 145 | + target/release/bundle/deb/Modrinth App_*.deb* |
| 146 | + target/release/bundle/rpm/Modrinth App-*.rpm* |
| 147 | + target/universal-apple-darwin/release/bundle/macos/Modrinth App.app.tar.gz* |
| 148 | + target/universal-apple-darwin/release/bundle/dmg/Modrinth App_*.dmg* |
| 149 | + target/release/bundle/nsis/Modrinth App_*-setup.exe* |
| 150 | + target/release/bundle/nsis/Modrinth App_*-setup.nsis.zip* |
0 commit comments