Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add mobile build support #525

Open
developomp opened this issue Jul 17, 2023 · 8 comments
Open

[Feature Request] Add mobile build support #525

developomp opened this issue Jul 17, 2023 · 8 comments
Labels
type: feature request New feature or request

Comments

@developomp
Copy link

Currently, there's no way to build mobile apps using the tauri-action workflow, and since I can't find discussions of it anywhere, I would like to start one here:

tauri-action automatically build apps for specific platform based on the OS. And since mobile apps has to be compiled from desktop OS, I think adding a mobile option sounds like a decent solution.

Here's an example of how the mobile build workflow might look like:

...
jobs:
  release:
    strategy:
      matrix:
        platform: [macos-latest, ubuntu-20.04, windows-latest]
        mobile: no
        include: # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#expanding-or-adding-matrix-configurations
          - os: ubuntu-latest
            mobile: yes
          - os: macos-latest
            mobile: yes
      ...

      - uses: tauri-apps/tauri-action@v0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tagName: app-v__VERSION__
          releaseName: 'App v__VERSION__'
          mobile: ${{ matrix.mobile }} # <- HERE
          releaseDraft: true
          prerelease: false
@FabianLars FabianLars added the type: feature request New feature or request label Jul 17, 2023
@FabianLars
Copy link
Member

Yes, this is planned though i don't know yet how far we can really get in CI but we'll see.
There's currently no mobile/v2 support because i'm waiting for it to be a bit more stable (at least beta) so we don't have to redo it every second week.

@developomp developomp changed the title [Question] Plans for mobile build? [Feature Request] Add mobile build support Jul 17, 2023
@liudonghua123
Copy link
Contributor

I also like this feature. Looking forward to beta/stable of tauri 2.0.

@jbeuria
Copy link

jbeuria commented Mar 12, 2024

Is building mobile apps using the tauri-action workflow implemented now in the beta version?

@FabianLars
Copy link
Member

If that were the case, this issue would be closed.

@haleksandre
Copy link

It is possible to build Android apps by modifying the tauriScript command to something along the lines of npx tauri android but then the step fails because it can't find the artifacts.

# building...
# compiling...
    Finished 1 APK at:
        /home/runner/work/test-tauri/test-tauri/src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk

    Finished 1 AAB at:
        /home/runner/work/test-tauri/test-tauri/src-tauri/gen/android/app/build/outputs/bundle/universalRelease/app-universal-release.aab

Looking for artifacts in:
/home/runner/work/test-tauri/test-tauri/src-tauri/target/x86_64-unknown-linux-gnu/release/bundle/deb/***bracket_0.0.1_amd64.deb
/home/runner/work/test-tauri/test-tauri/src-tauri/target/x86_64-unknown-linux-gnu/release/bundle/rpm/***bracket-0.0.1-1.x86_64.rpm
/home/runner/work/test-tauri/test-tauri/src-tauri/target/x86_64-unknown-linux-gnu/release/bundle/appimage/***bracket_0.0.1_amd64.AppImage
/home/runner/work/test-tauri/test-tauri/src-tauri/target/x86_64-unknown-linux-gnu/release/bundle/appimage/***bracket_0.0.1_amd64.AppImage.tar.gz
/home/runner/work/test-tauri/test-tauri/src-tauri/target/x86_64-unknown-linux-gnu/release/bundle/appimage/***bracket_0.0.1_amd64.AppImage.tar.gz.sig
Error: No artifacts were found.

Technically the action only needs a way to modify the platform check below & append the the apk/aad paths to the artifacts variable if the build is Android.

tauri-action/src/build.ts

Lines 90 to 236 in a32a76c

if (targetInfo.platform === 'macos') {
if (arch === 'x86_64') {
arch = 'x64';
} else if (arch === 'arm64') {
arch = 'aarch64';
}
artifacts = [
join(
artifactsPath,
`bundle/dmg/${fileAppName}_${app.version}_${arch}.dmg`,
),
join(artifactsPath, `bundle/macos/${fileAppName}.app`),
join(artifactsPath, `bundle/macos/${fileAppName}.app.tar.gz`),
join(artifactsPath, `bundle/macos/${fileAppName}.app.tar.gz.sig`),
].map((path) => ({ path, arch }));
} else if (targetInfo.platform === 'windows') {
if (arch.startsWith('i')) {
arch = 'x86';
} else if (arch === 'aarch64') {
arch = 'arm64';
} else {
arch = 'x64';
}
// If multiple Wix languages are specified, multiple installers (.msi) will be made
// The .zip and .sig are only generated for the first specified language
let langs;
if (typeof app.wixLanguage === 'string') {
langs = [app.wixLanguage];
} else if (Array.isArray(app.wixLanguage)) {
langs = app.wixLanguage;
} else {
langs = Object.keys(app.wixLanguage);
}
const winArtifacts: string[] = [];
langs.forEach((lang) => {
winArtifacts.push(
join(
artifactsPath,
`bundle/msi/${fileAppName}_${app.wixAppVersion}_${arch}_${lang}.msi`,
),
);
winArtifacts.push(
join(
artifactsPath,
`bundle/msi/${fileAppName}_${app.wixAppVersion}_${arch}_${lang}.msi.zip`,
),
);
winArtifacts.push(
join(
artifactsPath,
`bundle/msi/${fileAppName}_${app.wixAppVersion}_${arch}_${lang}.msi.zip.sig`,
),
);
});
winArtifacts.push(
join(
artifactsPath,
`bundle/nsis/${fileAppName}_${app.version}_${arch}-setup.exe`,
),
);
winArtifacts.push(
join(
artifactsPath,
`bundle/nsis/${fileAppName}_${app.version}_${arch}-setup.nsis.zip`,
),
);
winArtifacts.push(
join(
artifactsPath,
`bundle/nsis/${fileAppName}_${app.version}_${arch}-setup.nsis.zip.sig`,
),
);
artifacts = winArtifacts.map((path) => ({ path, arch }));
} else {
const debianArch =
arch === 'x64' || arch === 'x86_64'
? 'amd64'
: arch === 'x32' || arch === 'i686'
? 'i386'
: arch === 'arm'
? 'armhf'
: arch === 'aarch64'
? 'arm64'
: arch;
const rpmArch =
arch === 'x64' || arch === 'x86_64'
? 'x86_64'
: arch === 'x32' || arch === 'x86' || arch === 'i686'
? 'i386'
: arch === 'arm'
? 'armhfp'
: arch;
const appImageArch =
arch === 'x64' || arch === 'x86_64'
? 'amd64'
: arch === 'x32' || arch === 'i686'
? 'i386'
: arch === 'arm' // TODO: Confirm this
? 'arm'
: arch === 'arm64' // TODO: This is probably a Tauri bug
? 'aarch64'
: arch;
artifacts = [
{
path: join(
artifactsPath,
`bundle/deb/${fileAppName}_${app.version}_${debianArch}.deb`,
),
arch: debianArch,
},
{
path: join(
artifactsPath,
`bundle/rpm/${fileAppName}-${app.version}-${app.rpmRelease}.${rpmArch}.rpm`,
),
arch: rpmArch,
},
{
path: join(
artifactsPath,
`bundle/appimage/${fileAppName}_${app.version}_${appImageArch}.AppImage`,
),
arch: appImageArch,
},
{
path: join(
artifactsPath,
`bundle/appimage/${fileAppName}_${app.version}_${appImageArch}.AppImage.tar.gz`,
),
arch: appImageArch,
},
{
path: join(
artifactsPath,
`bundle/appimage/${fileAppName}_${app.version}_${appImageArch}.AppImage.tar.gz.sig`,
),
arch: appImageArch,
},
];
}

Is this something you'd be willing to add relatively soon or you'd still prefer to wait for a more stable Tauri 2.0?

@RoseBlume
Copy link

This would be nice, for now im stuck using a selfhosted runner for this.

@francollamas
Copy link

I can share my Github Action as "workarround" to build signed APK files, for anyone interested on it. I know it probably doesn't have the best practices and it isn't optimized either, but it works for me for the moment.
It makes use of another GH actions.

To make it works, you need to set this environments variables on your github project:
ANDROID_RELEASE_KEYSTORE --> your keystore file encoded in base64
ANDROID_RELEASE_PASSWORD --> the keystore password
ANDROID_RELEASE_KEY --> the name of the Key
ANDROID_RELEASE_KEY_PASSWORD --> the password for that Key

name: 'publish'

on:
    push:
        branches:
            - release

    workflow_dispatch:

jobs:
    publish-android:
        runs-on: ubuntu-latest
        permissions:
            contents: write
        steps:
            - uses: actions/checkout@v4

            - uses: pnpm/action-setup@v4
              with:
                  version: 8

            - name: Setup Java
              uses: actions/setup-java@v4
              with:
                  distribution: 'zulu'
                  java-version: '17'

            - name: Setup Android SDK
              uses: android-actions/setup-android@v3

            - name: Install NDK
              run: sdkmanager "ndk;27.0.11902837"

            - name: setup node
              uses: actions/setup-node@v4
              with:
                  node-version: lts/*

            - name: install Rust stable
              uses: dtolnay/rust-toolchain@stable
              with:
                  targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android

            - name: Install dependencies
              run: pnpm install

            - name: Build app bundle
              run: pnpm tauri android build -v
              env:
                  NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/27.0.11902837

            - name: Extract android signing key from env
              run: |
                  echo "${{ secrets.ANDROID_RELEASE_KEYSTORE }}" > src-tauri/gen/android/release.jks.base64
                  base64 -d src-tauri/gen/android/release.jks.base64 > src-tauri/gen/android/release.decrypted.jks

            - name: Sign APK
              run: |
                  ${{ env.ANDROID_HOME }}/build-tools/34.0.0/apksigner sign --ks src-tauri/gen/android/release.decrypted.jks \
                    --ks-key-alias ${{ secrets.ANDROID_RELEASE_KEY }} \
                    --ks-pass pass:${{ secrets.ANDROID_RELEASE_PASSWORD }} \
                    --key-pass pass:${{ secrets.ANDROID_RELEASE_KEY_PASSWORD }} \
                    --out src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release-signed.apk \
                    src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release-unsigned.apk

            - name: Get Node project version
              id: package-version
              uses: martinbeentjes/[email protected]

            - name: Rename APK file
              run: |
                  mv ./src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release-signed.apk ./src-tauri/gen/android/app/build/outputs/apk/universal/release/myappliation-${{ steps.package-version.outputs.current-version}}.apk

            - name: Publish
              uses: softprops/action-gh-release@v1
              with:
                  draft: true
                  name: App v${{ steps.package-version.outputs.current-version}}
                  tag_name: v${{ steps.package-version.outputs.current-version}}
                  generate_release_notes: true
                  files: |
                      ./src-tauri/gen/android/app/build/outputs/apk/universal/release/myapplication-${{ steps.package-version.outputs.current-version}}.apk

@nyxb
Copy link

nyxb commented Sep 10, 2024

I can share my Github Action as "workarround" to build signed APK files, for anyone interested on it. I know it probably doesn't have the best practices and it isn't optimized either, but it works for me for the moment. It makes use of another GH actions.

To make it works, you need to set this environments variables on your github project: ANDROID_RELEASE_KEYSTORE --> your keystore file encoded in base64 ANDROID_RELEASE_PASSWORD --> the keystore password ANDROID_RELEASE_KEY --> the name of the Key ANDROID_RELEASE_KEY_PASSWORD --> the password for that Key

name: 'publish'

on:
push:
branches:
- release

workflow_dispatch:

jobs:
publish-android:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

        - uses: pnpm/action-setup@v4
          with:
              version: 8

        - name: Setup Java
          uses: actions/setup-java@v4
          with:
              distribution: 'zulu'
              java-version: '17'

        - name: Setup Android SDK
          uses: android-actions/setup-android@v3

        - name: Install NDK
          run: sdkmanager "ndk;27.0.11902837"

        - name: setup node
          uses: actions/setup-node@v4
          with:
              node-version: lts/*

        - name: install Rust stable
          uses: dtolnay/rust-toolchain@stable
          with:
              targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android

        - name: Install dependencies
          run: pnpm install

        - name: Build app bundle
          run: pnpm tauri android build -v
          env:
              NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/27.0.11902837

        - name: Extract android signing key from env
          run: |
              echo "${{ secrets.ANDROID_RELEASE_KEYSTORE }}" > src-tauri/gen/android/release.jks.base64
              base64 -d src-tauri/gen/android/release.jks.base64 > src-tauri/gen/android/release.decrypted.jks

        - name: Sign APK
          run: |
              ${{ env.ANDROID_HOME }}/build-tools/34.0.0/apksigner sign --ks src-tauri/gen/android/release.decrypted.jks \
                --ks-key-alias ${{ secrets.ANDROID_RELEASE_KEY }} \
                --ks-pass pass:${{ secrets.ANDROID_RELEASE_PASSWORD }} \
                --key-pass pass:${{ secrets.ANDROID_RELEASE_KEY_PASSWORD }} \
                --out src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release-signed.apk \
                src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release-unsigned.apk

        - name: Get Node project version
          id: package-version
          uses: martinbeentjes/[email protected]

        - name: Rename APK file
          run: |
              mv ./src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release-signed.apk ./src-tauri/gen/android/app/build/outputs/apk/universal/release/myappliation-${{ steps.package-version.outputs.current-version}}.apk

        - name: Publish
          uses: softprops/action-gh-release@v1
          with:
              draft: true
              name: App v${{ steps.package-version.outputs.current-version}}
              tag_name: v${{ steps.package-version.outputs.current-version}}
              generate_release_notes: true
              files: |
                  ./src-tauri/gen/android/app/build/outputs/apk/universal/release/myapplication-${{ steps.package-version.outputs.current-version}}.apk

Do you have something like this in stock for ios?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
Status: 📋 Backlog
Development

No branches or pull requests

8 participants