Add support to build binary for Apple Silicon

This commit is contained in:
Krishan 2022-06-26 10:32:02 +05:30
parent 800ad4e486
commit 671ff5f4c1
2 changed files with 246 additions and 97 deletions

View file

@ -4,89 +4,227 @@ on:
types: [published] types: [published]
jobs: jobs:
publish-tauri: # Windows-x86_64
strategy: windows-x86_64:
fail-fast: false runs-on: windows-latest
matrix:
platform: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3.0.2 uses: actions/checkout@v3.0.2
with: with:
submodules: true submodules: true
- name: Get release - name: Get release
id: get_release id: get_release
uses: bruceadams/get-release@3a8733307b85cd96d52772b037617bd63d99522e uses: bruceadams/get-release@3a8733307b85cd96d52772b037617bd63d99522e
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup node - name: Setup node
uses: actions/setup-node@v3.3.0 uses: actions/setup-node@v3.3.0
with: with:
node-version: 17.9.0 node-version: 17.9.0
- name: Install Rust stable - name: Install Rust stable
uses: actions-rs/toolchain@v1.0.7 uses: actions-rs/toolchain@v1.0.7
with: with:
toolchain: stable toolchain: stable
- name: Install dependencies (ubuntu only) - name: Build desktop app with Tauri
if: matrix.platform == 'ubuntu-latest' uses: tauri-apps/tauri-action@v0.3.1
run: | env:
sudo apt-get update GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
- name: Install cinny dependencies TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
run: cd cinny && npm ci with:
- name: Install tauri dependencies releaseId: ${{ steps.get_release.outputs.upload_url }}
run: npm ci - name: Get app version (windows)
- name: Build desktop app with Tauri if: matrix.platform == 'windows-latest'
uses: tauri-apps/tauri-action@v0.3.1 run: |
env: $json = (Get-Content "src-tauri\tauri.conf.json" -Raw) | ConvertFrom-Json
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} $version = $json.package.version
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} echo "Version: ${version}"
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} echo "TAURI_VERSION=${version}" >> $Env:GITHUB_ENV
with: echo "${Env:TAURI_VERSION}"
releaseId: ${{ steps.get_release.outputs.upload_url }} shell: pwsh
- name: Get app version (macos, ubuntu) - name: Move msi
if: matrix.platform != 'windows-latest' run: mv "src-tauri\target\release\bundle\msi\Cinny_${{ env.TAURI_VERSION }}_x64_en-US.msi" "src-tauri\target\release\bundle\msi\Cinny_desktop-x86_64.msi"
id: vars - name: Move msi.zip
run: echo ::set-output name=tag::$(jq .package.version src-tauri/tauri.conf.json | tr -d '"') run: mv "src-tauri\target\release\bundle\msi\Cinny_${{ env.TAURI_VERSION }}_x64_en-US.msi.zip" "src-tauri\target\release\bundle\msi\Cinny_desktop-x86_64.msi.zip"
- name: Upload tagged release (macos) - name: Move msi.zip.sig
if: matrix.platform == 'macos-latest' run: mv "src-tauri\target\release\bundle\msi\Cinny_${{ env.TAURI_VERSION }}_x64_en-US.msi.zip.sig" "src-tauri\target\release\bundle\msi\Cinny_desktop-x86_64.msi.zip.gz"
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 - name: Upload tagged release
with: uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
files: | with:
src-tauri/target/release/bundle/dmg/cinny_${{ steps.vars.outputs.tag }}_x64.dmg files: |
src-tauri/target/release/bundle/macos/cinny.app.tar.gz src-tauri\target\release\bundle\msi\Cinny_desktop-x86_64.msi
src-tauri/target/release/bundle/macos/cinny.app.tar.gz.sig src-tauri\target\release\bundle\msi\Cinny_desktop-x86_64.msi.zip
- name: Upload tagged release (ubuntu) src-tauri\target\release\bundle\msi\Cinny_desktop-x86_64.msi.zip.sig
if: matrix.platform == 'ubuntu-latest'
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
with:
files: |
src-tauri/target/release/bundle/deb/cinny_${{ steps.vars.outputs.tag }}_amd64.deb
src-tauri/target/release/bundle/appimage/cinny_${{ steps.vars.outputs.tag }}_amd64.AppImage
src-tauri/target/release/bundle/appimage/cinny_${{ steps.vars.outputs.tag }}_amd64.AppImage.tar.gz
src-tauri/target/release/bundle/appimage/cinny_${{ steps.vars.outputs.tag }}_amd64.AppImage.tar.gz.sig
- name: Get app version (windows)
if: matrix.platform == 'windows-latest'
run: |
$json = (Get-Content "src-tauri\tauri.conf.json" -Raw) | ConvertFrom-Json
$version = $json.package.version
echo "Version: ${version}"
echo "TAURI_VERSION=${version}" >> $Env:GITHUB_ENV
echo "${Env:TAURI_VERSION}"
shell: pwsh
- name: Upload tagged release (windows)
if: matrix.platform == 'windows-latest'
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
with:
files: |
src-tauri\target\release\bundle\msi\cinny_${{ env.TAURI_VERSION }}_x64_en-US.msi
src-tauri\target\release\bundle\msi\cinny_${{ env.TAURI_VERSION }}_x64_en-US.msi.zip
src-tauri\target\release\bundle\msi\cinny_${{ env.TAURI_VERSION }}_x64_en-US.msi.zip.sig
# Linux-x86_64
linux-x86_64:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3.0.2
with:
submodules: true
- name: Get release
id: get_release
uses: bruceadams/get-release@3a8733307b85cd96d52772b037617bd63d99522e
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup node
uses: actions/setup-node@v3.3.0
with:
node-version: 17.9.0
- name: Install Rust stable
uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
- name: Install cinny dependencies
run: cd cinny && npm ci
- name: Install tauri dependencies
run: npm ci
- name: Build desktop app with Tauri
uses: tauri-apps/tauri-action@v0.3.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
with:
releaseId: ${{ steps.get_release.outputs.upload_url }}
- name: Get app version
id: vars
run: echo ::set-output name=tag::$(jq .package.version src-tauri/tauri.conf.json | tr -d '"')
- name: Move deb
run: mv "src-tauri/target/release/bundle/deb/Cinny_${{ steps.vars.outputs.tag }}_amd64.deb" "src-tauri/target/release/bundle/deb/Cinny_desktop-x86_64.deb"
- name: Move AppImage
run: mv "src-tauri/target/release/bundle/appimage/Cinny_${{ steps.vars.outputs.tag }}_amd64.AppImage" "src-tauri/target/release/bundle/appimage/Cinny_desktop-x86_64.AppImage"
- name: Move AppImage.tar.gz
run: mv "src-tauri/target/release/bundle/appimage/Cinny_${{ steps.vars.outputs.tag }}_amd64.AppImage.tar.gz" "src-tauri/target/release/bundle/appimage/Cinny_desktop-x86_64.AppImage.tar.gz"
- name: Move AppImage.tar.gz.sig
run: mv "src-tauri/target/release/bundle/appimage/Cinny_${{ steps.vars.outputs.tag }}_amd64.AppImage.tar.gz.sig" "src-tauri/target/release/bundle/appimage/Cinny_desktop-x86_64.AppImage.tar.gz.sig"
- name: Upload tagged release
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
with:
files: |
src-tauri/target/release/bundle/deb/Cinny_desktop-x86_64.deb
src-tauri/target/release/bundle/appimage/Cinny_desktop-x86_64.AppImage
src-tauri/target/release/bundle/appimage/Cinny_desktop-x86_64.AppImage.tar.gz
src-tauri/target/release/bundle/appimage/Cinny_desktop-x86_64.AppImage.tar.gz.sig
# macos-x86_64
macos-x86_64:
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3.0.2
with:
submodules: true
- name: Get release
id: get_release
uses: bruceadams/get-release@3a8733307b85cd96d52772b037617bd63d99522e
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup node
uses: actions/setup-node@v3.3.0
with:
node-version: 17.9.0
- name: Install Rust stable
uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
- name: Install cinny dependencies
run: cd cinny && npm ci
- name: Install tauri dependencies
run: npm ci
- name: Build desktop app with Tauri
uses: tauri-apps/tauri-action@v0.3.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
with:
releaseId: ${{ steps.get_release.outputs.upload_url }}
- name: Get app version
id: vars
run: echo ::set-output name=tag::$(jq .package.version src-tauri/tauri.conf.json | tr -d '"')
- name: Move dmg
run: mv "src-tauri/target/release/bundle/dmg/Cinny_${{ steps.vars.outputs.tag }}_x64.dmg" "src-tauri/target/release/bundle/dmg/Cinny_desktop-x86_64.dmg"
- name: Move app.tar.gz
run: mv "src-tauri/target/release/bundle/macos/Cinny.app.tar.gz" "src-tauri/target/release/bundle/macos/Cinny_desktop-x86_64.app.tar.gz"
- name: Move app.tar.gz.sig
run: mv "src-tauri/target/release/bundle/macos/Cinny.app.tar.gz.sig" "src-tauri/target/release/bundle/macos/Cinny_desktop-x86_64.app.tar.gz.sig"
- name: Upload tagged release
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
with:
files: |
src-tauri/target/release/bundle/dmg/Cinny_desktop-x86_64.dmg
src-tauri/target/release/bundle/macos/Cinny_desktop-x86_64.app.tar.gz
src-tauri/target/release/bundle/macos/Cinny_desktop-x86_64.app.tar.gz.sig
# macos-aarch64
macos-aarch64:
runs-on: macos-12
steps:
- name: Checkout repository
uses: actions/checkout@v3.0.2
with:
submodules: true
- name: Get release
id: get_release
uses: bruceadams/get-release@3a8733307b85cd96d52772b037617bd63d99522e
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup node
uses: actions/setup-node@v3.3.0
with:
node-version: 17.9.0
- name: Install Rust stable
uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
- name: Install cinny dependencies
run: cd cinny && npm ci
- name: Install tauri dependencies
run: npm ci
- name: Install rustup target aarch64 darwin
run: rustup target add aarch64-apple-darwin
- name: Build desktop app with Tauri
uses: tauri-apps/tauri-action@v0.3.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
with:
args: --target aarch64-apple-darwin
releaseId: ${{ steps.get_release.outputs.upload_url }}
- name: Get app version
if: always()
id: vars
run: echo ::set-output name=tag::$(jq .package.version src-tauri/tauri.conf.json | tr -d '"')
- name: Move dmg
if: always()
run: mv "src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/Cinny_${{ steps.vars.outputs.tag }}_aarch64.dmg" "src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/Cinny_desktop-aarch64.dmg"
- name: Move app.tar.gz
if: always()
run: mv "src-tauri/target/aarch64-apple-darwin/release/bundle/macos/Cinny.app.tar.gz" "src-tauri/target/aarch64-apple-darwin/release/bundle/macos/Cinny_desktop-aarch64.app.tar.gz"
- name: Move app.tar.gz.sig
if: always()
run: mv "src-tauri/target/aarch64-apple-darwin/release/bundle/macos/Cinny.app.tar.gz.sig" "src-tauri/target/aarch64-apple-darwin/release/bundle/macos/Cinny_desktop-aarch64.app.tar.gz.sig"
- name: Upload tagged release
if: always()
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
with:
files: |
src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/Cinny_desktop-aarch64.dmg
src-tauri/target/aarch64-apple-darwin/release/bundle/macos/Cinny_desktop-aarch64.tar.gz
src-tauri/target/aarch64-apple-darwin/release/bundle/macos/Cinny_desktop-aarch64.tar.gz.sig
# Upload release.json
release-update: release-update:
needs: publish-tauri if: always()
needs: [windows-x86_64, linux-x86_64, macos-x86_64, macos-aarch64]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository

View file

@ -31,32 +31,40 @@ async function createTauriRelease() {
const latestRelease = await repos.getReleaseByTag({ ...repoMetaData, tag: latestTag.name }); const latestRelease = await repos.getReleaseByTag({ ...repoMetaData, tag: latestTag.name });
const latestAssets = latestRelease.data.assets; const latestAssets = latestRelease.data.assets;
const win64 = {}; const windowsX86_64 = {};
const linux = {}; const linuxX86_64 = {};
const darwin = {}; const darwinX86_64 = {};
const darwinAarch64 = {};
const promises = latestAssets.map(async (asset) => { const promises = latestAssets.map(async (asset) => {
const { name, browser_download_url } = asset; const { name, browser_download_url } = asset;
if (/\.msi\.zip$/.test(name)) { if (/\.msi\.zip$/.test(name)) {
win64.url = browser_download_url; windowsX86_64.url = browser_download_url;
} }
if (/\.msi\.zip\.sig$/.test(name)) { if (/\.msi\.zip\.sig$/.test(name)) {
win64.signature = await getAssetSign(browser_download_url); windowsX86_64.signature = await getAssetSign(browser_download_url);
} }
if (/\.AppImage\.tar\.gz$/.test(name)) { if (/\.AppImage\.tar\.gz$/.test(name)) {
linux.url = browser_download_url; linuxX86_64.url = browser_download_url;
} }
if (/\.AppImage\.tar\.gz\.sig$/.test(name)) { if (/\.AppImage\.tar\.gz\.sig$/.test(name)) {
linux.signature = await getAssetSign(browser_download_url); linuxX86_64.signature = await getAssetSign(browser_download_url);
} }
if (/\.app\.tar\.gz$/.test(name)) { if (/x86_64\.app\.tar\.gz$/.test(name)) {
darwin.url = browser_download_url; darwinX86_64.url = browser_download_url;
} }
if (/\.app\.tar\.gz\.sig$/.test(name)) { if (/x86_64\.app\.tar\.gz\.sig$/.test(name)) {
darwin.signature = await getAssetSign(browser_download_url); darwinX86_64.signature = await getAssetSign(browser_download_url);
}
if (/aarch64\.app\.tar\.gz$/.test(name)) {
darwinAarch64.url = browser_download_url;
}
if (/aarch64\.app\.tar\.gz\.sig$/.test(name)) {
darwinAarch64.signature = await getAssetSign(browser_download_url);
} }
}); });
@ -69,14 +77,17 @@ async function createTauriRelease() {
platforms: {}, platforms: {},
}; };
if (win64.url) releaseData.platforms["windows-x86_64"] = win64; if (windowsX86_64.url) releaseData.platforms["windows-x86_64"] = windowsX86_64;
else console.error('Failed to get release for win64'); else console.error('Failed to get release for windowsX86_64');
if (linux.url) releaseData.platforms["linux-x86_64"] = linux; if (linuxX86_64.url) releaseData.platforms["linux-x86_64"] = linuxX86_64;
else console.error('Failed to get release for linux'); else console.error('Failed to get release for linuxX86_64');
if (darwin.url) releaseData.platforms["darwin-x86_64"] = darwin; if (darwinX86_64.url) releaseData.platforms["darwin-x86_64"] = darwinX86_64;
else console.error('Failed to get release for darwin'); else console.error('Failed to get release for darwinX86_64');
if (darwinAarch64.url) releaseData.platforms["darwin-aarch64"] = darwinAarch64;
else console.error('Failed to get release for darwinAarch64');
const releaseResult = await repos.getReleaseByTag({ ...repoMetaData, tag: 'tauri' }); const releaseResult = await repos.getReleaseByTag({ ...repoMetaData, tag: 'tauri' });
const tauriRelease = releaseResult.data; const tauriRelease = releaseResult.data;