Release Desktop App #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "release" | |
env: | |
PNPM_VERSION: "9.15.0" | |
NODE_VERSION: "22.11.0" | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "*" | |
jobs: | |
create-release: | |
permissions: | |
contents: write | |
runs-on: ubuntu-20.04 | |
outputs: | |
release_id: ${{ steps.create-release.outputs.result }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache-dependency-path: pnpm-lock.yaml | |
- uses: pnpm/[email protected] | |
with: | |
version: ${{ env.PNPM_VERSION }} | |
- name: Get version | |
run: echo "PACKAGE_VERSION=$(node -p "require('./apps/desktop/package.json').version")" >> $GITHUB_ENV | |
- name: Create release | |
id: create-release | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const { data } = await github.rest.repos.createRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag_name: `v${process.env.PACKAGE_VERSION}`, | |
name: `v${process.env.PACKAGE_VERSION}`, | |
body: '*This release was generated automatically using GitHub Actions.*', | |
draft: true, | |
prerelease: false | |
}) | |
return data.id | |
build-tauri: | |
needs: create-release | |
permissions: | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [windows-latest] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Rust cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: apps/desktop -> apps/desktop/target | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache-dependency-path: pnpm-lock.yaml | |
- uses: pnpm/[email protected] | |
with: | |
version: ${{ env.PNPM_VERSION }} | |
- name: Install apt dependencies (ubuntu only) | |
if: matrix.platform == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt install -y --no-install-recommends libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf | |
- name: Install pnpm | |
run: npm install -g pnpm | |
- name: Install dependencies | |
run: pnpm install | |
- name: Prisma Generate | |
run: pnpm generate | |
- name: Build the app | |
uses: tauri-apps/tauri-action@v0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
projectPath: ./apps/desktop | |
releaseId: ${{ needs.create-release.outputs.release_id }} | |
publish-release: | |
permissions: | |
contents: write | |
runs-on: ubuntu-20.04 | |
needs: [create-release, build-tauri] | |
steps: | |
- name: Publish release | |
id: publish-release | |
uses: actions/github-script@v6 | |
env: | |
release_id: ${{ needs.create-release.outputs.release_id }} | |
with: | |
script: | | |
github.rest.repos.updateRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: process.env.release_id, | |
draft: false, | |
prerelease: false | |
}) |