fix: update Tauri version from git tag in release workflow (#56) #55
Workflow file for this run
This file contains hidden or 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: Desktop Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version tag (e.g., v0.1.0)' | |
| required: true | |
| type: string | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| # Triggered by rustledger releases | |
| repository_dispatch: | |
| types: [rustledger-release] | |
| permissions: | |
| contents: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUSTLEDGER_REPO: rustledger/rustledger | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }} | |
| jobs: | |
| build-sidecar: | |
| timeout-minutes: 30 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| target: x86_64-unknown-linux-gnu | |
| sidecar_name: rustfava-server-x86_64-unknown-linux-gnu | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| sidecar_name: rustfava-server-x86_64-apple-darwin | |
| - os: macos-14 | |
| target: aarch64-apple-darwin | |
| sidecar_name: rustfava-server-aarch64-apple-darwin | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| sidecar_name: rustfava-server-x86_64-pc-windows-msvc.exe | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| - name: Get latest rustledger tag | |
| id: rustledger-tag | |
| shell: bash | |
| run: | | |
| TAG=$(gh release view --repo ${{ env.RUSTLEDGER_REPO }} --json tagName -q '.tagName') | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "Using rustledger $TAG" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Download rustledger WASM from release | |
| shell: bash | |
| run: | | |
| gh release download ${{ steps.rustledger-tag.outputs.tag }} \ | |
| --repo ${{ env.RUSTLEDGER_REPO }} \ | |
| --pattern "rustledger-ffi-wasi-*.wasm" \ | |
| --output src/rustfava/rustledger/rustledger-wasi.wasm | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Set up Python | |
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | |
| with: | |
| python-version: '3.13' | |
| cache: 'pip' | |
| - name: Install Bun | |
| uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2 | |
| - name: Install Python dependencies | |
| shell: bash | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pyinstaller | |
| # Install runtime dependencies only (no rustfava install needed) | |
| pip install "Flask>=2.2,<4" "Flask-Babel>=3,<5" "Jinja2>=3,<4" "Werkzeug>=2.2,<4" \ | |
| "beangulp>=0.1" "cheroot>=8,<12" "click>=7,<9" "markdown2>=2.3.0,<3" \ | |
| "ply>=3.11" "pydantic>=2.0" "watchfiles>=0.20.0" "beancount>=2,<4" \ | |
| "Babel>=2.7,<3" | |
| - name: Build frontend assets | |
| shell: bash | |
| run: | | |
| cd frontend && bun install && bun run build | |
| - name: Compile translations | |
| shell: bash | |
| run: | | |
| python -c " | |
| from pathlib import Path | |
| from babel.messages.mofile import write_mo | |
| from babel.messages.pofile import read_po | |
| for po in Path('src/rustfava/translations').glob('**/messages.po'): | |
| mo = po.parent / 'messages.mo' | |
| catalog = read_po(po.open('rb'), po.parts[-3]) | |
| write_mo(mo.open('wb'), catalog) | |
| print(f'Compiled {po} -> {mo}') | |
| " | |
| - name: Build sidecar with PyInstaller | |
| shell: bash | |
| run: | | |
| pyinstaller contrib/pyinstaller_spec.spec --noconfirm | |
| - name: Rename sidecar (Unix) | |
| if: runner.os != 'Windows' | |
| run: | | |
| mv dist/rustfava dist/${{ matrix.sidecar_name }} | |
| - name: Rename sidecar (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| move dist\rustfava.exe dist\${{ matrix.sidecar_name }} | |
| - name: Upload sidecar artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: sidecar-${{ matrix.target }} | |
| path: dist/${{ matrix.sidecar_name }} | |
| download-rustledger: | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| archive: tar.gz | |
| - target: x86_64-apple-darwin | |
| archive: tar.gz | |
| - target: aarch64-apple-darwin | |
| archive: tar.gz | |
| - target: x86_64-pc-windows-msvc | |
| archive: zip | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get latest rustledger tag | |
| id: rustledger-tag | |
| shell: bash | |
| run: | | |
| TAG=$(gh release view --repo ${{ env.RUSTLEDGER_REPO }} --json tagName -q '.tagName') | |
| VERSION=${TAG#v} | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Using rustledger $TAG" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Download rustledger binaries from release | |
| run: | | |
| gh release download ${{ steps.rustledger-tag.outputs.tag }} \ | |
| --repo ${{ env.RUSTLEDGER_REPO }} \ | |
| --pattern "rustledger-${{ steps.rustledger-tag.outputs.tag }}-${{ matrix.target }}.${{ matrix.archive }}" \ | |
| --output rustledger.${{ matrix.archive }} | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Extract binaries (tar.gz) | |
| if: matrix.archive == 'tar.gz' | |
| run: | | |
| mkdir -p binaries | |
| tar -xzf rustledger.${{ matrix.archive }} | |
| # Rename binaries to include target triple (Tauri sidecar convention) | |
| for bin in bean-check bean-doctor bean-extract bean-format bean-price bean-query bean-report rledger; do | |
| if [ -f "$bin" ]; then | |
| mv "$bin" "binaries/${bin}-${{ matrix.target }}" | |
| fi | |
| done | |
| - name: Extract binaries (zip) | |
| if: matrix.archive == 'zip' | |
| run: | | |
| mkdir -p binaries | |
| unzip rustledger.${{ matrix.archive }} | |
| # Rename binaries to include target triple (Tauri sidecar convention) | |
| for bin in bean-check bean-doctor bean-extract bean-format bean-price bean-query bean-report rledger; do | |
| if [ -f "${bin}.exe" ]; then | |
| mv "${bin}.exe" "binaries/${bin}-${{ matrix.target }}.exe" | |
| fi | |
| done | |
| - name: Upload rustledger binaries | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: rustledger-${{ matrix.target }} | |
| path: binaries/* | |
| build-tauri: | |
| needs: [build-sidecar, download-rustledger] | |
| timeout-minutes: 45 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| target: x86_64-unknown-linux-gnu | |
| sidecar_name: rustfava-server-x86_64-unknown-linux-gnu | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| sidecar_name: rustfava-server-x86_64-apple-darwin | |
| - os: macos-14 | |
| target: aarch64-apple-darwin | |
| sidecar_name: rustfava-server-aarch64-apple-darwin | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| sidecar_name: rustfava-server-x86_64-pc-windows-msvc.exe | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| - name: Download sidecar artifact | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| name: sidecar-${{ matrix.target }} | |
| path: desktop/src-tauri/binaries/ | |
| - name: Download rustledger binaries | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| name: rustledger-${{ matrix.target }} | |
| path: desktop/src-tauri/binaries/ | |
| - name: Make binaries executable (Unix) | |
| if: runner.os != 'Windows' | |
| run: chmod +x desktop/src-tauri/binaries/* | |
| - name: Install Linux dependencies | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libwebkit2gtk-4.1-dev \ | |
| librsvg2-dev \ | |
| patchelf \ | |
| libssl-dev \ | |
| libgtk-3-dev \ | |
| libayatana-appindicator3-dev | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b # stable | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.target }} | |
| - name: Rust cache | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
| with: | |
| workspaces: desktop/src-tauri | |
| cache-targets: true | |
| cache-all-crates: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: '20' | |
| - name: Install Bun | |
| uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2 | |
| - name: Install frontend dependencies | |
| working-directory: desktop | |
| run: bun install | |
| - name: Update version from tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| shell: bash | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| echo "Updating tauri.conf.json version to $VERSION" | |
| cd desktop/src-tauri | |
| # Update version in tauri.conf.json using jq | |
| jq --arg v "$VERSION" '.version = $v' tauri.conf.json > tauri.conf.json.tmp | |
| mv tauri.conf.json.tmp tauri.conf.json | |
| cat tauri.conf.json | grep version | |
| - name: Build Tauri app | |
| uses: tauri-apps/tauri-action@79c624843491f12ae9d63592534ed49df3bc4adb # v0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| projectPath: desktop | |
| tauriScript: bun tauri | |
| args: --target ${{ matrix.target }} | |
| - name: Create tarball (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| mkdir -p tarball-staging/bin tarball-staging/lib/rustfava/resources | |
| # Copy main binary | |
| cp desktop/src-tauri/target/${{ matrix.target }}/release/rustfava-desktop tarball-staging/bin/ | |
| # Copy sidecars (server + rustledger CLI tools) | |
| cp desktop/src-tauri/binaries/* tarball-staging/bin/ | |
| # Copy resources | |
| cp contrib/examples/example.beancount tarball-staging/lib/rustfava/resources/ | |
| # Create tarball | |
| tar -czvf rustfava-desktop-${{ matrix.target }}.tar.gz -C tarball-staging . | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: rustfava-${{ matrix.target }} | |
| path: | | |
| rustfava-desktop-${{ matrix.target }}.tar.gz | |
| desktop/src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb | |
| desktop/src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm | |
| desktop/src-tauri/target/${{ matrix.target }}/release/bundle/appimage/*.AppImage | |
| desktop/src-tauri/target/${{ matrix.target }}/release/bundle/dmg/*.dmg | |
| desktop/src-tauri/target/${{ matrix.target }}/release/bundle/macos/*.app | |
| desktop/src-tauri/target/${{ matrix.target }}/release/bundle/msi/*.msi | |
| desktop/src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*.exe | |
| release: | |
| needs: build-tauri | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| path: artifacts | |
| pattern: rustfava-* | |
| merge-multiple: true | |
| - name: List artifacts | |
| run: find artifacts -type f | |
| - name: Create Release | |
| uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2 | |
| with: | |
| files: | | |
| artifacts/**/*.tar.gz | |
| artifacts/**/*.deb | |
| artifacts/**/*.rpm | |
| artifacts/**/*.AppImage | |
| artifacts/**/*.dmg | |
| artifacts/**/*.msi | |
| artifacts/**/*.exe | |
| draft: true | |
| generate_release_notes: true |