Skip to content

Revert "Update crates" #287

Revert "Update crates"

Revert "Update crates" #287

Workflow file for this run

on:
push:
pull_request:
release:
types: [published]
jobs:
build:
permissions:
contents: write
strategy:
matrix:
include:
- name: darwin-aarch64
platform: macos-latest
target: aarch64-apple-darwin
bundles: [dmg, updater]
- name: darwin-x86_64
platform: macos-latest
target: x86_64-apple-darwin
bundles: [dmg, updater]
- name: linux-aarch64
platform: ubuntu-22.04
target: aarch64-unknown-linux-gnu
triple: aarch64-linux-gnu
arch: arm64
bundles: [deb]
- name: linux-x86_64
platform: ubuntu-22.04
target: x86_64-unknown-linux-gnu
triple: x86_64-linux-gnu
arch: amd64
bundles: [deb, appimage, updater]
- name: windows-x86_64
platform: windows-latest
target: x86_64-pc-windows-msvc
bundles: [nsis, updater]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'npm'
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: (Ubuntu) Set up APT sources
if: matrix.platform == 'ubuntu-22.04'
run: |
cat <<EOF | sudo tee /etc/apt/sources.list
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security main restricted
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security multiverse
EOF
- name: (Ubuntu) Set up APT sources for ${{ matrix.arch }}
if: matrix.platform == 'ubuntu-22.04' && matrix.arch != 'amd64'
run: |
cat <<EOF | sudo tee --append /etc/apt/sources.list
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports/ jammy universe
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates universe
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports/ jammy multiverse
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates multiverse
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports/ jammy-security universe
deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports/ jammy-security multiverse
EOF
- name: (Ubuntu) Install native dependencies
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo dpkg --add-architecture ${{ matrix.arch }}
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
libappindicator3-dev:${{ matrix.arch }} \
librsvg2-dev:${{ matrix.arch }} \
libssl-dev:${{ matrix.arch }} \
libudev-dev:${{ matrix.arch }} \
libwebkit2gtk-4.1-dev:${{ matrix.arch }} \
patchelf
echo "PKG_CONFIG_SYSROOT_DIR=/usr" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/lib/${{ matrix.triple }}/pkgconfig" >> $GITHUB_ENV
- name: (Ubuntu) Set up cross-compiler for ${{ matrix.arch }}
if: matrix.platform == 'ubuntu-22.04' && matrix.triple != 'x86_64-linux-gnu'
run: |
sudo apt-get install --no-install-recommends -y gcc-${{ matrix.triple }}
mkdir -p .cargo
cat <<EOF | tee .cargo/config.toml
[target.${{ matrix.target }}]
linker = "${{ matrix.triple }}-gcc"
EOF
- name: Install frontend dependencies
run: npm ci
- name: Decide target bundles
id: target
shell: python
run: |
from os import getenv
bundles = '${{ join(matrix.bundles, ',') }}'.split(',')
if not getenv('TAURI_SIGNING_PRIVATE_KEY'):
bundles = [bundle for bundle in bundles if bundle != 'updater']
bundles = ','.join(bundles)
print(f'bundles={bundles}')
with open(getenv('GITHUB_OUTPUT'), 'at') as f:
f.writelines(f'bundles={bundles}')
env:
TAURI_SIGNING_PRIVATE_KEY: '${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}'
- name: Build
uses: tauri-apps/tauri-action@v0
id: build
with:
args: >
--target ${{ matrix.target }}
--bundles ${{ steps.target.outputs.bundles }}
env:
TAURI_SIGNING_PRIVATE_KEY: '${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}'
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ''
- name: Collect artifacts
shell: python
run: |
import os
import json
import shutil
os.makedirs('distrib', exist_ok=True)
os.makedirs('updater', exist_ok=True)
artifact_paths = '${{ steps.build.outputs.artifactPaths }}'.replace('\\', '\\\\')
name = '${{ matrix.name }}'
for artifact in json.loads(artifact_paths):
filename = os.path.basename(artifact)
sig_file = f'{artifact}.sig'
if filename.endswith('.dmg'):
shutil.move(artifact, os.path.join('distrib', f'cskburn-desktop_{name}.dmg'))
elif filename.endswith('.app.tar.gz'):
shutil.move(artifact, os.path.join('updater', f'cskburn-desktop_{name}.app.tar.gz'))
shutil.move(sig_file, os.path.join('updater', f'cskburn-desktop_{name}.app.tar.gz.sig'))
elif filename.endswith('.deb'):
shutil.move(artifact, os.path.join('distrib', f'cskburn-desktop_{name}.deb'))
elif filename.endswith('.AppImage'):
shutil.move(artifact, os.path.join('distrib', f'cskburn-desktop_{name}.AppImage'))
elif filename.endswith('.AppImage.tar.gz'):
shutil.move(artifact, os.path.join('updater', f'cskburn-desktop_{name}.AppImage.tar.gz'))
shutil.move(sig_file, os.path.join('updater', f'cskburn-desktop_{name}.AppImage.tar.gz.sig'))
elif filename.endswith('-setup.exe'):
shutil.move(artifact, os.path.join('distrib', f'cskburn-desktop_{name}-setup.exe'))
elif filename.endswith('-setup.nsis.zip'):
shutil.move(artifact, os.path.join('updater', f'cskburn-desktop_{name}-setup.nsis.zip'))
shutil.move(sig_file, os.path.join('updater', f'cskburn-desktop_{name}-setup.nsis.zip.sig'))
- name: Archive distributable
uses: actions/upload-artifact@v4
with:
name: cskburn-desktop_distrib_${{ github.run_id }}_${{ matrix.name }}
path: distrib/
- name: Archive updater
uses: actions/upload-artifact@v4
with:
name: cskburn-desktop_updater_${{ github.run_id }}_${{ matrix.name }}
path: updater/
publish-distribs:
needs: build
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- name: Download distributables
uses: actions/download-artifact@v4
with:
pattern: cskburn-desktop_distrib_*
path: distribs/
merge-multiple: true
- name: Upload assets to release
uses: csexton/release-asset-action@v3
with:
pattern: distribs/*
github-token: ${{ secrets.GITHUB_TOKEN }}
publish-updaters:
needs: build
if: github.event_name == 'release' && !github.event.release.prerelease
runs-on: ubuntu-latest
steps:
- name: Set up ossutil
uses: manyuanrong/setup-ossutil@v2.0
with:
endpoint: ${{ secrets.ALIYUN_OSS_REGION }}.aliyuncs.com
access-key-id: ${{ secrets.ALIYUN_ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.ALIYUN_ACCESS_KEY_SECRET }}
- name: Download updaters
uses: actions/download-artifact@v4
with:
pattern: cskburn-desktop_updater_*
path: updaters/
merge-multiple: true
- name: Generate metadata
id: metadata
shell: python
run: |
import json
import os
url_prefix = 'https://cdn.listenai.com/public/cskburn-desktop'
metadata = {
'version': '${{ github.event.release.tag_name }}',
'notes': ${{ toJson(github.event.release.body) }},
'pub_date': '${{ github.event.release.published_at }}',
'platforms': {},
}
platforms = ['darwin', 'linux', 'windows']
archs = ['aarch64', 'x86_64']
names = [f'{platform}-{arch}' for platform in platforms for arch in archs]
for updater in os.listdir('updaters'):
for name in names:
if name in updater and not updater.endswith('.sig'):
with open(os.path.join('updaters', f'{updater}.sig'), 'r') as f:
signature = f.read().strip()
os.remove(os.path.join('updaters', f'{updater}.sig'))
metadata['platforms'][name] = {
'signature': signature,
'url': f'{url_prefix}/${{ github.event.release.tag_name }}/{updater}',
}
with open('latest.json', 'w') as f:
json.dump(metadata, f)
- name: Upload to OSS
run: |
ossutil cp -f latest.json \
oss://${{ secrets.ALIYUN_OSS_BUCKET }}/public/cskburn-desktop/
ossutil cp -r updaters/ \
oss://${{ secrets.ALIYUN_OSS_BUCKET }}/public/cskburn-desktop/${{ github.event.release.tag_name }}/