diff --git a/.github/workflows/ossign-release-tauri.yml b/.github/workflows/ossign-release-tauri.yml new file mode 100644 index 00000000..de5c5b0b --- /dev/null +++ b/.github/workflows/ossign-release-tauri.yml @@ -0,0 +1,156 @@ +name: Build and Package Tauri + +on: + workflow_dispatch: + inputs: + source_branch: + description: 'The source branch or ref to build from' + default: 'main' + required: true + release_name: + description: 'The name for the release' + required: true + +env: + NODE_VERSION: 22 + +jobs: + release: + runs-on: windows-latest + # environment: OSSign + + permissions: + contents: write + + strategy: + matrix: + include: + - id: windows-x64 + runner: windows-latest + rust_targets: 'x86_64-pc-windows-msvc' + tauri_target: 'x86_64-pc-windows-msvc' + asset_suffix: 'windows-x64' + + - id: windows-arm64 + runner: windows-11-arm + rust_targets: 'aarch64-pc-windows-msvc' + tauri_target: 'aarch64-pc-windows-msvc' + asset_suffix: 'windows-arm64' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + repository: 'Beaver-Notes/Beaver-Notes' + ref: Tauri + fetch-depth: 1 + + - name: Fix tauri + shell: bash + run: | + jq '.bundle.windows.signCommand = "ossign.exe -t pecoff -o %1 %1"' src-tauri/tauri.conf.json > src-tauri/tauri.conf.json.tmp + mv src-tauri/tauri.conf.json.tmp src-tauri/tauri.conf.json + + - uses: ossign/ossign@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + installOnly: true + + # package.json is the source of truth for the release version. + - name: Read version from package.json + id: version + shell: bash + run: | + echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT" + + - name: Setup Node with Yarn cache + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + + # Use same yarn version everywhere + - name: Enable Corepack + shell: bash + run: | + corepack enable + corepack prepare yarn@stable --activate + yarn --version + + # Install the Rust targets needed for each matrix job + - name: Setup Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.rust_targets }} + + - name: Rust cache + uses: Swatinem/rust-cache@v2 + with: + workspaces: | + src-tauri -> target + + - name: Install JS dependencies + shell: bash + run: | + yarn install --frozen-lockfile + + - name: Build Windows bundles + shell: bash + env: + CI: 'true' + OSSIGN_CONFIG_BASE64: ${{ secrets.OSSIGN_CONFIG_BASE64 }} + run: | + yarn tauri build --verbose --target "${{ matrix.tauri_target }}" --bundles nsis --ci || true + + - name: Stage Windows assets + shell: pwsh + run: | + $ErrorActionPreference = "Stop" + + $Version = "${{ steps.version.outputs.version }}" + $Target = "${{ matrix.rust_targets }}" + $OutDir = "release-assets" + New-Item -ItemType Directory -Force -Path $OutDir | Out-Null + + Get-ChildItem "src-tauri/target/$Target/release/bundle" -Recurse -File | + Where-Object { $_.Extension -in ".exe", ".msi", ".sig", ".json", ".zip" } | + ForEach-Object { Copy-Item $_.FullName -Destination $OutDir -Force } + + $Binary = "src-tauri/target/$Target/release/beaver-notes.exe" + $PortableName = "Beaver Notes-$Version-portable-${{ matrix.asset_suffix }}.zip" + Compress-Archive -Path $Binary -DestinationPath (Join-Path $OutDir $PortableName) -Force + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.asset_suffix }} + path: release-assets/* + if-no-files-found: error + + publish: + runs-on: ubuntu-latest + needs: release + permissions: + contents: write + steps: + - name: Get artifacts (amd64) + uses: actions/download-artifact@v4 + with: + path: dist-artifacts + merge-multiple: true + + - name: Release + uses: softprops/action-gh-release@v2 + with: + files: | + dist-artifacts/* + README.md + name: ${{ github.event.inputs.release_name }} + tag_name: ${{ github.run_id }} + body: | + # Signed Release ${{ github.event.inputs.release_name }} + + These are the distributable files for the signed release of Beaver-Notes ${{ github.event.inputs.release_name }} + + The source code was fetched from https://github.com/Beaver-Notes/Beaver-Notes@${{ github.event.inputs.source_branch }} + diff --git a/.github/workflows/ossign-release.yml b/.github/workflows/ossign-release.yml deleted file mode 100644 index ac4b7157..00000000 --- a/.github/workflows/ossign-release.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Build and Package - -on: - workflow_dispatch: - inputs: - source_branch: - description: 'The source branch or ref to build from' - default: 'main' - required: true - release_name: - description: 'The name for the release' - required: true - -jobs: - release: - environment: OSSign - runs-on: windows-latest - - permissions: - contents: write - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - repository: 'Beaver-Notes/Beaver-Notes' - ref: ${{ github.event.inputs.source_branch }} - fetch-depth: 1 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 22 - - - name: Install dependencies - run: yarn install --frozen-lockfile --network-timeout 1000000 - - - name: build Vite bundles - run: yarn build - - - name: Build and conditionally publish Electron app - shell: bash - env: - AST_VAULT: ${{ secrets.AST_VAULT }} - AST_CERT: ${{ secrets.AST_CERT }} - AST_IDENT: ${{ secrets.AST_IDENT }} - AST_SECRET: ${{ secrets.AST_SECRET }} - AST_TENANT: ${{ secrets.AST_TENANT }} - AST_TIMESTAMP: ${{ secrets.AST_TIMESTAMP }} - AST_TD: ${{ secrets.AST_TD }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - curl -L https://github.com/vcsjones/AzureSignTool/releases/download/v6.0.1/AzureSignTool-x64.exe -o AzureSignTool.exe - yarn electron-builder build --config electron-builder.config.cjs --publish never - - - name: Release - uses: softprops/action-gh-release@v2 - with: - files: | - dist/* - README.md - package.json - yarn.lock - name: ${{ github.event.inputs.release_name }} - tag_name: ${{ github.run_id }} - body: | - # Signed Release ${{ github.event.inputs.release_name }} - - These are the distributable files for the signed release of Beaver-Notes ${{ github.event.inputs.release_name }} - - The source code was fetched from https://github.com/Beaver-Notes/Beaver-Notes@${{ github.event.inputs.source_branch }} - -