Skip to content

fix: add libclang for Flathub build and OCR models for COPR packaging #823

fix: add libclang for Flathub build and OCR models for COPR packaging

fix: add libclang for Flathub build and OCR models for COPR packaging #823

Workflow file for this run

name: "publish"
on:
workflow_dispatch:
push:
branches: [main]
paths-ignore:
- "docs/**"
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
env:
ARCH: x86_64
jobs:
setup:
runs-on: ubuntu-22.04
outputs:
name: ${{ steps.get-package.outputs.name }}
name_bin: ${{ steps.get-package.outputs.name }}-rs-bin
version: ${{ steps.get-package.outputs.version }}
description: ${{ steps.get-package.outputs.description }}
license: ${{ steps.get-package.outputs.license }}
deb_pkg_name: ${{ steps.get-package.outputs.name }}_${{ steps.get-package.outputs.version }}_amd64.deb
deb_pkg_path: ./src-tauri/target/release/bundle/deb/
deb_pkg_renamed: ${{ steps.get-package.outputs.name }}-${{ steps.get-package.outputs.version }}-${{ env.ARCH }}.deb
arch_pkg_name: ${{ steps.get-package.outputs.name }}-rs-bin-${{ steps.get-package.outputs.version }}-1-${{ env.ARCH }}.pkg.tar.zst
tag_name: v${{ steps.get-package.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: get package info
id: get-package
run: |
echo "name=$(node -p "require('./package.json').name")" >> $GITHUB_OUTPUT
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
echo "description=$(node -p "require('./package.json').description")" >> $GITHUB_OUTPUT
echo "license=$(node -p "require('./package.json').license")" >> $GITHUB_OUTPUT
build-tauri:
needs: [setup]
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: "macos-latest"
args: "--target universal-apple-darwin"
- platform: "ubuntu-22.04"
args: ""
- platform: "ubuntu-22.04-arm"
args: ""
- platform: "windows-latest"
args: ""
- platform: "windows-11-arm"
args: ""
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Replace environment variables in config
env:
TAURI_GOOGLE_CLIENT_ID: ${{ secrets.TAURI_GOOGLE_CLIENT_ID }}
TAURI_GOOGLE_CLIENT_SECRET: ${{ secrets.TAURI_GOOGLE_CLIENT_SECRET }}
run: node ./.github/replace-config.js
- name: install rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: cache rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
src-tauri/target
key: ${{ matrix.platform }}-cargo-${{ hashFiles('src-tauri/Cargo.lock') }}
restore-keys: |
${{ matrix.platform }}-cargo-
- name: install dependencies (ubuntu only)
if: startsWith(matrix.platform, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y libayatana-appindicator3-dev libwebkit2gtk-4.1-dev patchelf xdg-utils
- name: install frontend dependencies
run: yarn install
- name: Set NO_STRIP environment variable
if: startsWith(matrix.platform, 'ubuntu') || matrix.platform == 'macos-latest'
run: echo "NO_STRIP=true" >> $GITHUB_ENV
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: ${{ needs.setup.outputs.tag_name }}
releaseName: ${{ needs.setup.outputs.tag_name }}
releaseDraft: false
prerelease: false
args: ${{ matrix.args }}
- name: generate PKGBUILD from template (ubuntu only)
if: matrix.platform == 'ubuntu-22.04'
run: |
mkdir -p ${{ needs.setup.outputs.name_bin }}
cp -fr ${{ needs.setup.outputs.deb_pkg_path }}${{ needs.setup.outputs.deb_pkg_name }} ${{ needs.setup.outputs.name_bin }}/${{ needs.setup.outputs.deb_pkg_renamed }}
DEB_SHA256=$(sha256sum ${{ needs.setup.outputs.name_bin }}/${{ needs.setup.outputs.deb_pkg_renamed }} | awk '{print $1}')
sed -e "s|{{NAME}}|${{ needs.setup.outputs.name }}|g" \
-e "s|{{VERSION}}|${{ needs.setup.outputs.version }}|g" \
-e "s|{{DESCRIPTION}}|${{ needs.setup.outputs.description }}|g" \
-e "s|{{LICENSE}}|${{ needs.setup.outputs.license }}|g" \
-e "s|{{SHA256}}|${DEB_SHA256}|g" \
.github/aur/PKGBUILD > ${{ needs.setup.outputs.name_bin }}/PKGBUILD
cat ${{ needs.setup.outputs.name_bin }}/PKGBUILD
- name: create arch package (ubuntu only)
if: matrix.platform == 'ubuntu-22.04'
run: |
docker run --rm -v "$PWD/${{ needs.setup.outputs.name_bin }}:/pkg" archlinux:latest bash -c "
pacman -Sy --noconfirm base-devel sudo &&
useradd -m builder &&
chown -R builder: /pkg &&
cd /pkg &&
sudo -u builder makepkg -f --nodeps
"
- name: upload arch package to release (ubuntu only)
if: matrix.platform == 'ubuntu-22.04'
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ needs.setup.outputs.tag_name }}
files: |
${{ needs.setup.outputs.name_bin }}/${{ needs.setup.outputs.arch_pkg_name }}
publish-linux:
needs: [setup, build-tauri]
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: setup auth
run: |
mkdir -p ~/.ssh
echo "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/aur
chmod 600 ~/.ssh/aur
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts 2>/dev/null
git config --global url."https://0-don:${{ secrets.GH_PAT }}@github.com/".insteadOf "https://github.com/"
git config --global user.email "0-don@users.noreply.github.com"
git config --global user.name "0-don"
- name: download deb from release
run: |
curl -sL "https://github.com/0-don/${{ needs.setup.outputs.name }}/releases/download/${{ needs.setup.outputs.tag_name }}/${{ needs.setup.outputs.deb_pkg_name }}" -o /tmp/clippy.deb
echo "DEB_SHA256=$(sha256sum /tmp/clippy.deb | awk '{print $1}')" >> $GITHUB_ENV
- name: publish to AUR
run: |
export GIT_SSH_COMMAND="ssh -i ~/.ssh/aur"
git clone ssh://aur@aur.archlinux.org/${{ needs.setup.outputs.name }}-rs-bin.git /tmp/aur-pkg
cd /tmp/aur-pkg
sed -e "s|{{NAME}}|${{ needs.setup.outputs.name }}|g" \
-e "s|{{VERSION}}|${{ needs.setup.outputs.version }}|g" \
-e "s|{{DESCRIPTION}}|${{ needs.setup.outputs.description }}|g" \
-e "s|{{LICENSE}}|${{ needs.setup.outputs.license }}|g" \
-e "s|{{SHA256}}|${{ env.DEB_SHA256 }}|g" \
${{ github.workspace }}/.github/aur/PKGBUILD > PKGBUILD
mkdir -p /tmp/pkgbuild-work
cp PKGBUILD /tmp/pkgbuild-work/
docker run --rm -v "/tmp/pkgbuild-work:/pkg" archlinux:latest bash -c "
pacman -Sy --noconfirm pacman-contrib sudo &&
useradd -m builder &&
chown -R builder: /pkg &&
cd /pkg &&
sudo -u builder makepkg --printsrcinfo > .SRCINFO
"
cp /tmp/pkgbuild-work/.SRCINFO .
git add PKGBUILD .SRCINFO
git diff --cached --quiet || git commit -m "Update to ${{ needs.setup.outputs.version }}" && git push
- name: update homebrew cask
run: |
git clone https://github.com/0-don/homebrew-clippy.git /tmp/homebrew-tap
cd /tmp/homebrew-tap
DMG_URL="https://github.com/0-don/${{ needs.setup.outputs.name }}/releases/download/${{ needs.setup.outputs.tag_name }}/${{ needs.setup.outputs.name }}_${{ needs.setup.outputs.version }}_universal.dmg"
curl -sL "$DMG_URL" -o /tmp/clippy.dmg
DMG_SHA256=$(sha256sum /tmp/clippy.dmg | awk '{print $1}')
sed -e "s|{{NAME}}|${{ needs.setup.outputs.name }}|g" \
-e "s|{{VERSION}}|${{ needs.setup.outputs.version }}|g" \
-e "s|{{DESCRIPTION}}|${{ needs.setup.outputs.description }}|g" \
-e "s|{{SHA256}}|${DMG_SHA256}|g" \
${{ github.workspace }}/.github/homebrew/Casks/clippy.rb.template > Casks/clippy.rb
git add Casks/clippy.rb
git diff --cached --quiet || git commit -m "Update to ${{ needs.setup.outputs.version }}" && git push
- name: update scoop bucket
run: |
git clone https://github.com/0-don/scoop-clippy.git /tmp/scoop-bucket
cd /tmp/scoop-bucket
EXE_URL="https://github.com/0-don/${{ needs.setup.outputs.name }}/releases/download/${{ needs.setup.outputs.tag_name }}/${{ needs.setup.outputs.name }}_${{ needs.setup.outputs.version }}_x64-setup.exe"
curl -sL "$EXE_URL" -o /tmp/clippy-setup.exe
EXE_SHA256=$(sha256sum /tmp/clippy-setup.exe | awk '{print $1}')
sed -e "s|{{NAME}}|${{ needs.setup.outputs.name }}|g" \
-e "s|{{VERSION}}|${{ needs.setup.outputs.version }}|g" \
-e "s|{{DESCRIPTION}}|${{ needs.setup.outputs.description }}|g" \
-e "s|{{SHA256}}|${EXE_SHA256}|g" \
${{ github.workspace }}/.github/scoop/clippy.json > bucket/clippy.json
git add bucket/clippy.json
git diff --cached --quiet || git commit -m "Update to ${{ needs.setup.outputs.version }}" && git push
- name: update flathub
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
git clone https://github.com/flathub/io.github._0_don.clippy.git /tmp/flathub
cd /tmp/flathub
git submodule update --init
BRANCH="update-v${{ needs.setup.outputs.version }}"
git checkout -b "$BRANCH"
COMMIT_HASH=$(git -C ${{ github.workspace }} rev-parse HEAD)
MNN_X86=$(curl -sL "https://github.com/zibo-chen/MNN-Prebuilds/releases/download/dev/mnn-dev-linux-x86_64.tar.gz" | sha256sum | awk '{print $1}')
MNN_ARM=$(curl -sL "https://github.com/zibo-chen/MNN-Prebuilds/releases/download/dev/mnn-dev-linux-aarch64.tar.gz" | sha256sum | awk '{print $1}')
sed -e "s|{{COMMIT_HASH}}|${COMMIT_HASH}|g" \
-e "s|{{MNN_X86_64_SHA256}}|${MNN_X86}|g" \
-e "s|{{MNN_AARCH64_SHA256}}|${MNN_ARM}|g" \
${{ github.workspace }}/.github/flathub/io.github._0_don.clippy.yml > io.github._0_don.clippy.yml
pip3 install tomlkit aiohttp
python3 <(curl -sL https://raw.githubusercontent.com/flatpak/flatpak-builder-tools/refs/heads/master/cargo/flatpak-cargo-generator.py) \
${{ github.workspace }}/src-tauri/Cargo.lock -o cargo-sources.json
pip3 install requirements-parser
git clone https://github.com/flatpak/flatpak-builder-tools.git /tmp/fbt
cd /tmp/fbt/node && pip3 install .
flatpak-node-generator npm ${{ github.workspace }}/package-lock.json -o /tmp/flathub/node-sources.json
cd /tmp/flathub
git add io.github._0_don.clippy.yml cargo-sources.json node-sources.json
git diff --cached --quiet && exit 0
git commit -m "Update to ${{ needs.setup.outputs.version }}"
git push origin "$BRANCH" --force
GH_TOKEN="${{ secrets.GH_PAT }}" gh pr create --repo flathub/io.github._0_don.clippy \
--base master --head "$BRANCH" \
--title "Update to ${{ needs.setup.outputs.version }}" \
--body "Automated update from release workflow" || echo "PR already exists"
- name: prepare snapcraft.yaml
run: |
sed -e "s|{{NAME}}|${{ needs.setup.outputs.name }}|g" \
-e "s|{{VERSION}}|${{ needs.setup.outputs.version }}|g" \
-e "s|{{DESCRIPTION}}|${{ needs.setup.outputs.description }}|g" \
.github/snap/snapcraft.yaml > snapcraft.yaml
- name: build snap
uses: snapcore/action-build@v1
id: snap-build
- name: publish snap
if: steps.snap-build.outputs.snap
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
run: |
if [ -z "$SNAPCRAFT_STORE_CREDENTIALS" ]; then echo "No snap credentials, skipping"; exit 0; fi
sudo snap install snapcraft --classic
snapcraft upload ${{ steps.snap-build.outputs.snap }} --release=stable
- name: build copr package
env:
COPR_API_TOKEN: ${{ secrets.COPR_API_TOKEN }}
run: |
if [ -z "$COPR_API_TOKEN" ]; then echo "No COPR token, skipping"; exit 0; fi
sudo pip3 install copr-cli
mkdir -p ~/.config
echo "$COPR_API_TOKEN" > ~/.config/copr
sed -e "s|{{NAME}}|${{ needs.setup.outputs.name }}|g" \
-e "s|{{VERSION}}|${{ needs.setup.outputs.version }}|g" \
-e "s|{{DESCRIPTION}}|${{ needs.setup.outputs.description }}|g" \
.github/copr/clippy.spec > /tmp/clippy.spec
copr-cli build clippy /tmp/clippy.spec
publish-windows:
needs: [setup, build-tauri]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: publish to chocolatey
shell: pwsh
env:
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
run: |
if (-not $env:CHOCOLATEY_API_KEY) { Write-Host "No Chocolatey API key, skipping"; exit 0 }
$exe_url = "https://github.com/0-don/${{ needs.setup.outputs.name }}/releases/download/${{ needs.setup.outputs.tag_name }}/${{ needs.setup.outputs.name }}_${{ needs.setup.outputs.version }}_x64-setup.exe"
Invoke-WebRequest -Uri $exe_url -OutFile clippy-setup.exe
$hash = (Get-FileHash clippy-setup.exe -Algorithm SHA256).Hash
$chocoDir = ".github/chocolatey"
(Get-Content "$chocoDir/clippy.nuspec") -replace '\{\{VERSION\}\}', '${{ needs.setup.outputs.version }}' | Set-Content "$chocoDir/clippy.nuspec"
(Get-Content "$chocoDir/tools/chocolateyinstall.ps1") -replace '\{\{VERSION\}\}', '${{ needs.setup.outputs.version }}' -replace '\{\{SHA256\}\}', $hash | Set-Content "$chocoDir/tools/chocolateyinstall.ps1"
cd $chocoDir
choco pack
choco push clippy-clipboard.${{ needs.setup.outputs.version }}.nupkg --source https://push.chocolatey.org/ --api-key $env:CHOCOLATEY_API_KEY