Skip to content

windows build action fix #13

windows build action fix

windows build action fix #13

# Name of the GitHub Actions workflow
name: Build and Deploy
# Trigger the workflow on push to the specified branch
on:
pull_request:
branches:
- main
push:
branches:
- main
# Define the jobs to be run
jobs:
# Define the build job for macOS
build:
# Specify the runner environment
runs-on: macos-latest
# Define the steps to be performed in the build job
steps:
# Add the target architecture for building MacOS Silicon apps
- name: Add target architecture
run: rustup target add aarch64-apple-darwin
# Check out the repository code to the runner
- name: Checkout code
uses: actions/checkout@v4
# Set up the required Node.js version
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"
# Set up the Rust toolchain
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# Check if there is a cache of the pnpm modules and restore it
- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
# Install pnpm (a fast, disk space efficient package manager)
- name: Install pnpm
run: npm install -g pnpm
# Install project dependencies
- name: Install dependencies
run: pnpm i
# Build the project for MacOS Silicon
- name: Build for MacOS Silicon
run: pnpm build:app:silicon
# Archive the MacOS Silicon build artifacts
- name: Archive MacOS Silicon artifacts
uses: actions/upload-artifact@v3
with:
name: macos-silicon
path: src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/*.dmg
if-no-files-found: error
# Pre command for Intel build
- name: rustup command
run: rustup target add x86_64-apple-darwin
# Build the project for MacOS Intel
- name: Build for MacOS Intel
run: pnpm build:app:intell
# Archive the MacOS Intel build artifacts
- name: Archive MacOS Intel artifacts
uses: actions/upload-artifact@v3
with:
name: macos-intel
path: src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/*.dmg
if-no-files-found: error
# Build the project for MacOS Universal (both Silicon and Intel)
- name: Build for MacOS Universal
run: pnpm build:app:universal
# Archive the MacOS Universal build artifacts
- name: Archive MacOS Universal artifacts
uses: actions/upload-artifact@v3
with:
name: macos-universal
path: src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg
if-no-files-found: error
# Define the build job for Windows
windows-build:
# Specify the runner environment
runs-on: windows-latest
# Define the steps to be performed in the Windows build job
steps:
# Add the target architecture for building Windows apps
- name: Add target architecture
run: rustup target add x86_64-pc-windows-msvc
# Check out the repository code to the runner
- name: Checkout code
uses: actions/checkout@v4
# Set up the required Node.js version
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"
# Set up the Rust toolchain
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# Install pnpm (a fast, disk space efficient package manager)
- name: Install pnpm
run: npm install -g pnpm
# Install project dependencies
- name: Install dependencies
run: pnpm i
# Build the project for Windows
- name: Build for Windows
run: pnpm build:app:windows
# Archive Windows build artifacts
- name: Archive Windows artifacts
uses: actions/upload-artifact@v3
with:
name: windows
path: src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.exe
# Define the release job which depends on both the macOS and Windows build jobs
release:
# Specify that this job needs the build and windows-build jobs to complete successfully
needs: [build, windows-build]
# Specify the runner environment
runs-on: ubuntu-latest
# Define the steps to be performed in the release job
steps:
# Download the build artifacts from the build job
- name: Download macOS artifacts
uses: actions/download-artifact@v3
with:
name: macos-silicon
- name: Download Windows artifacts
uses: actions/download-artifact@v3
with:
name: windows
# Generate the tag
- name: Generate tag
id: generate_tag
run: echo "::set-output name=tag::release-$(date +'%Y%m%d%H%M%S')"
# Create a new GitHub release with the generated tag
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.generate_tag.outputs.tag }}
release_name: Release ${{ steps.generate_tag.outputs.tag }}
draft: false
prerelease: false
# Get the file name and assign it to an object
- name: Get Silicon file name
id: get_filename_silicon
run: echo "::set-output name=filename::$(ls src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/*.dmg)"
# Print the file name
- name: Echo the Silicon file name
run: echo "The file name is ${{ steps.get_filename_silicon.outputs.filename }}"
# Upload the MacOS Silicon build artifact to the GitHub release
- name: Upload Release Asset (MacOS Silicon)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.get_filename_silicon.outputs.filename }} # adjusted path
asset_name: Ollama-Gui-MacOS-Silicon.dmg
asset_content_type: application/octet-stream
# Get the file name and assign it to an object
- name: Get Intel file name
id: get_filename_intel
run: echo "::set-output name=filename::$(ls src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/*.dmg)"
# Print the file name
- name: Echo the Intel file name
run: echo "The Intel file name is ${{ steps.get_filename_intel.outputs.filename }}"
# Upload the MacOS Intel build artifact to the GitHub release
- name: Upload Release Asset (MacOS Intel)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.get_filename_intel.outputs.filename }} # adjusted path
asset_name: Ollama-Gui-MacOS-Intel.dmg
asset_content_type: application/octet-stream
# Get the file name and assign it to an object
- name: Get Universal file name
id: get_filename_universal
run: echo "::set-output name=filename::$(ls src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg)"
# Print the file name
- name: Echo the Universal file name
run: echo "The Universal file name is ${{ steps.get_filename_universal.outputs.filename }}"