fix: enhance updater artifact collection and upload process in GitHub… #17
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: Build Tauri Desktop Apps | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| create_release: | |
| description: 'Create a draft release' | |
| required: false | |
| default: true | |
| type: boolean | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: macos-latest | |
| args: --target aarch64-apple-darwin | |
| target: aarch64-apple-darwin | |
| rust_target: aarch64-apple-darwin | |
| updater_target: darwin-aarch64 | |
| bundle_path: src-tauri/target/aarch64-apple-darwin/release/bundle | |
| app_tar: macos/msgReader.app.tar.gz | |
| - platform: macos-latest | |
| args: --target x86_64-apple-darwin | |
| target: x86_64-apple-darwin | |
| rust_target: x86_64-apple-darwin | |
| updater_target: darwin-x86_64 | |
| bundle_path: src-tauri/target/x86_64-apple-darwin/release/bundle | |
| app_tar: macos/msgReader.app.tar.gz | |
| - platform: ubuntu-22.04 | |
| args: '' | |
| target: '' | |
| rust_target: x86_64-unknown-linux-gnu | |
| updater_target: linux-x86_64 | |
| bundle_path: src-tauri/target/release/bundle | |
| app_tar: '' | |
| - platform: windows-latest | |
| args: '' | |
| target: '' | |
| rust_target: x86_64-pc-windows-msvc | |
| updater_target: windows-x86_64 | |
| bundle_path: src-tauri/target/release/bundle | |
| app_tar: '' | |
| runs-on: ${{ matrix.platform }} | |
| outputs: | |
| version: ${{ steps.get-version.outputs.version }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install Rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install dependencies (Ubuntu) | |
| if: matrix.platform == 'ubuntu-22.04' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libwebkit2gtk-4.1-dev \ | |
| libappindicator3-dev \ | |
| librsvg2-dev \ | |
| patchelf | |
| - name: Install npm dependencies | |
| run: npm ci | |
| - name: Get version from tag | |
| id: get-version | |
| shell: bash | |
| run: | | |
| if [[ "$GITHUB_REF" == refs/tags/v* ]]; then | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| else | |
| VERSION="0.0.0-dev" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Update version from tag | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| shell: bash | |
| run: | | |
| VERSION="${{ steps.get-version.outputs.version }}" | |
| echo "Updating version to $VERSION" | |
| node -e " | |
| const fs = require('fs'); | |
| const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); | |
| pkg.version = '$VERSION'; | |
| fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); | |
| " | |
| node -e " | |
| const fs = require('fs'); | |
| let content = fs.readFileSync('src-tauri/Cargo.toml', 'utf8'); | |
| content = content.replace(/^(version = \")[^\"]*(\")$/m, '\$1$VERSION\$2'); | |
| fs.writeFileSync('src-tauri/Cargo.toml', content); | |
| " | |
| - name: Run tests | |
| run: npm test | |
| - name: Build Tauri App | |
| shell: bash | |
| env: | |
| TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} | |
| TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} | |
| run: | | |
| npx tauri build ${{ matrix.args }} | |
| - name: List bundle contents | |
| shell: bash | |
| run: | | |
| echo "Bundle path: ${{ matrix.bundle_path }}" | |
| find ${{ matrix.bundle_path }} -type f -name "*.sig" 2>/dev/null || echo "No .sig files found" | |
| find ${{ matrix.bundle_path }} -type f -name "*.tar.gz" 2>/dev/null || echo "No .tar.gz files found" | |
| find ${{ matrix.bundle_path }} -type f -name "*.zip" 2>/dev/null || echo "No .zip files found" | |
| - name: Prepare updater artifacts (macOS) | |
| if: matrix.platform == 'macos-latest' | |
| id: prepare-macos | |
| shell: bash | |
| run: | | |
| VERSION="${{ steps.get-version.outputs.version }}" | |
| BUNDLE="${{ matrix.bundle_path }}" | |
| # Find the app tar.gz and its signature | |
| APP_TAR=$(find $BUNDLE -name "*.app.tar.gz" -type f | head -1) | |
| APP_SIG=$(find $BUNDLE -name "*.app.tar.gz.sig" -type f | head -1) | |
| echo "Found APP_TAR: $APP_TAR" | |
| echo "Found APP_SIG: $APP_SIG" | |
| if [ -n "$APP_TAR" ] && [ -n "$APP_SIG" ]; then | |
| # Read signature content | |
| SIG_CONTENT=$(cat "$APP_SIG") | |
| echo "signature=$SIG_CONTENT" >> $GITHUB_OUTPUT | |
| echo "app_tar=$APP_TAR" >> $GITHUB_OUTPUT | |
| echo "app_sig=$APP_SIG" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Prepare updater artifacts (Linux) | |
| if: matrix.platform == 'ubuntu-22.04' | |
| id: prepare-linux | |
| shell: bash | |
| run: | | |
| VERSION="${{ steps.get-version.outputs.version }}" | |
| BUNDLE="${{ matrix.bundle_path }}" | |
| # Find AppImage tar.gz and signature | |
| APP_TAR=$(find $BUNDLE -name "*.AppImage.tar.gz" -type f | head -1) | |
| APP_SIG=$(find $BUNDLE -name "*.AppImage.tar.gz.sig" -type f | head -1) | |
| echo "Found APP_TAR: $APP_TAR" | |
| echo "Found APP_SIG: $APP_SIG" | |
| if [ -n "$APP_TAR" ] && [ -n "$APP_SIG" ]; then | |
| SIG_CONTENT=$(cat "$APP_SIG") | |
| echo "signature=$SIG_CONTENT" >> $GITHUB_OUTPUT | |
| echo "app_tar=$APP_TAR" >> $GITHUB_OUTPUT | |
| echo "app_sig=$APP_SIG" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Prepare updater artifacts (Windows) | |
| if: matrix.platform == 'windows-latest' | |
| id: prepare-windows | |
| shell: bash | |
| run: | | |
| VERSION="${{ steps.get-version.outputs.version }}" | |
| BUNDLE="${{ matrix.bundle_path }}" | |
| # Find NSIS zip and signature | |
| APP_ZIP=$(find $BUNDLE -name "*.nsis.zip" -type f | head -1) | |
| APP_SIG=$(find $BUNDLE -name "*.nsis.zip.sig" -type f | head -1) | |
| echo "Found APP_ZIP: $APP_ZIP" | |
| echo "Found APP_SIG: $APP_SIG" | |
| if [ -n "$APP_ZIP" ] && [ -n "$APP_SIG" ]; then | |
| SIG_CONTENT=$(cat "$APP_SIG") | |
| echo "signature=$SIG_CONTENT" >> $GITHUB_OUTPUT | |
| echo "app_zip=$APP_ZIP" >> $GITHUB_OUTPUT | |
| echo "app_sig=$APP_SIG" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Collect and save updater files | |
| shell: bash | |
| run: | | |
| mkdir -p updater-files | |
| BUNDLE="${{ matrix.bundle_path }}" | |
| echo "Searching in: $BUNDLE" | |
| # Find and copy signature files | |
| find "$BUNDLE" -name "*.sig" -type f -exec cp {} updater-files/ \; 2>/dev/null || true | |
| find "$BUNDLE" -name "*.tar.gz" -type f -exec cp {} updater-files/ \; 2>/dev/null || true | |
| find "$BUNDLE" -name "*.nsis.zip" -type f -exec cp {} updater-files/ \; 2>/dev/null || true | |
| echo "Collected files:" | |
| ls -la updater-files/ || echo "No files collected" | |
| - name: Upload updater artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: updater-${{ matrix.updater_target }} | |
| path: updater-files/ | |
| if-no-files-found: warn | |
| - name: Upload to Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: tauri-apps/tauri-action@v0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tagName: ${{ github.ref_name }} | |
| releaseName: 'msgReader ${{ github.ref_name }}' | |
| releaseBody: | | |
| Download the installer for your platform: | |
| - **macOS (Apple Silicon)**: `.dmg` file ending with `aarch64` | |
| - **macOS (Intel)**: `.dmg` file ending with `x64` | |
| - **Windows**: `.msi` or `.exe` installer | |
| - **Linux**: `.AppImage` or `.deb` package | |
| The app will automatically check for updates. | |
| releaseDraft: true | |
| prerelease: false | |
| includeUpdaterJson: false | |
| tauriScript: echo "skip" | |
| args: ${{ matrix.args }} | |
| create-updater-json: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Download all signature artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: List downloaded artifacts | |
| run: | | |
| echo "Downloaded artifacts:" | |
| find artifacts -type f | head -50 | |
| - name: Create latest.json | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| TAG_NAME="${GITHUB_REF_NAME}" | |
| BASE_URL="https://github.com/${{ github.repository }}/releases/download/${TAG_NAME}" | |
| # Find signature files | |
| echo "Looking for signatures..." | |
| # macOS aarch64 | |
| SIG_DARWIN_AARCH64="" | |
| SIG_FILE=$(find artifacts/updater-darwin-aarch64 -name "*.app.tar.gz.sig" -type f 2>/dev/null | head -1) | |
| if [ -n "$SIG_FILE" ]; then | |
| SIG_DARWIN_AARCH64=$(cat "$SIG_FILE") | |
| echo "Found darwin-aarch64 signature: ${SIG_DARWIN_AARCH64:0:50}..." | |
| fi | |
| # macOS x86_64 | |
| SIG_DARWIN_X86_64="" | |
| SIG_FILE=$(find artifacts/updater-darwin-x86_64 -name "*.app.tar.gz.sig" -type f 2>/dev/null | head -1) | |
| if [ -n "$SIG_FILE" ]; then | |
| SIG_DARWIN_X86_64=$(cat "$SIG_FILE") | |
| echo "Found darwin-x86_64 signature: ${SIG_DARWIN_X86_64:0:50}..." | |
| fi | |
| # Linux | |
| SIG_LINUX="" | |
| SIG_FILE=$(find artifacts/updater-linux-x86_64 -name "*.AppImage.tar.gz.sig" -type f 2>/dev/null | head -1) | |
| if [ -n "$SIG_FILE" ]; then | |
| SIG_LINUX=$(cat "$SIG_FILE") | |
| echo "Found linux signature: ${SIG_LINUX:0:50}..." | |
| fi | |
| # Windows | |
| SIG_WINDOWS="" | |
| SIG_FILE=$(find artifacts/updater-windows-x86_64 -name "*.nsis.zip.sig" -type f 2>/dev/null | head -1) | |
| if [ -n "$SIG_FILE" ]; then | |
| SIG_WINDOWS=$(cat "$SIG_FILE") | |
| echo "Found windows signature: ${SIG_WINDOWS:0:50}..." | |
| fi | |
| # Find update bundle URLs | |
| LINUX_TAR=$(find artifacts/updater-linux-x86_64 -name "*.AppImage.tar.gz" -type f 2>/dev/null | head -1) | |
| LINUX_TAR_NAME=$(basename "$LINUX_TAR" 2>/dev/null || echo "") | |
| WINDOWS_ZIP=$(find artifacts/updater-windows-x86_64 -name "*.nsis.zip" -type f 2>/dev/null | head -1) | |
| WINDOWS_ZIP_NAME=$(basename "$WINDOWS_ZIP" 2>/dev/null || echo "") | |
| # Export for node | |
| export SIG_DARWIN_AARCH64 | |
| export SIG_DARWIN_X86_64 | |
| export SIG_LINUX | |
| export SIG_WINDOWS | |
| # Create latest.json | |
| node -e " | |
| const fs = require('fs'); | |
| const version = '${VERSION}'; | |
| const baseUrl = '${BASE_URL}'; | |
| const linuxTar = '${LINUX_TAR_NAME}' || 'msgReader_' + version + '_amd64.AppImage.tar.gz'; | |
| const windowsZip = '${WINDOWS_ZIP_NAME}' || 'msgReader_' + version + '_x64-setup.nsis.zip'; | |
| const json = { | |
| version: version, | |
| notes: 'See release notes at ' + baseUrl, | |
| pub_date: new Date().toISOString(), | |
| platforms: { | |
| 'darwin-aarch64': { | |
| signature: process.env.SIG_DARWIN_AARCH64 || '', | |
| url: baseUrl + '/msgReader_aarch64.app.tar.gz' | |
| }, | |
| 'darwin-x86_64': { | |
| signature: process.env.SIG_DARWIN_X86_64 || '', | |
| url: baseUrl + '/msgReader_x64.app.tar.gz' | |
| }, | |
| 'linux-x86_64': { | |
| signature: process.env.SIG_LINUX || '', | |
| url: baseUrl + '/' + linuxTar | |
| }, | |
| 'windows-x86_64': { | |
| signature: process.env.SIG_WINDOWS || '', | |
| url: baseUrl + '/' + windowsZip | |
| } | |
| } | |
| }; | |
| fs.writeFileSync('latest.json', JSON.stringify(json, null, 2)); | |
| console.log('Created latest.json:'); | |
| console.log(JSON.stringify(json, null, 2)); | |
| " | |
| - name: Upload updater files to release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| # Upload latest.json | |
| gh release upload "${{ github.ref_name }}" latest.json --repo "${{ github.repository }}" --clobber | |
| # Upload Linux AppImage.tar.gz if found | |
| LINUX_TAR=$(find artifacts/updater-linux-x86_64 -name "*.AppImage.tar.gz" -type f 2>/dev/null | head -1) | |
| if [ -n "$LINUX_TAR" ]; then | |
| gh release upload "${{ github.ref_name }}" "$LINUX_TAR" --repo "${{ github.repository }}" --clobber | |
| echo "Uploaded: $(basename $LINUX_TAR)" | |
| fi | |
| # Upload Windows nsis.zip if found | |
| WINDOWS_ZIP=$(find artifacts/updater-windows-x86_64 -name "*.nsis.zip" -type f 2>/dev/null | head -1) | |
| if [ -n "$WINDOWS_ZIP" ]; then | |
| gh release upload "${{ github.ref_name }}" "$WINDOWS_ZIP" --repo "${{ github.repository }}" --clobber | |
| echo "Uploaded: $(basename $WINDOWS_ZIP)" | |
| fi | |
| echo "Updater files uploaded successfully" |