# Windows용 Tauri 앱 게시하기

이 가이드는 Mocco에 게시하는 Tauri 2 앱에 Windows(`windows-x86_64`)를 추가합니다. 먼저 [Tauri 앱 게시하기](https://www.mocco.club/docs/ko/articles/2pegvw-publish-tauri)대로 앱, 업데이터 키, `tauri.conf.json`, CI 키를 설정하세요. 그 내용은 Windows에도 그대로 적용됩니다.

## 번들 고르기

Tauri는 두 종류의 Windows 설치 파일을 만듭니다. MSI가 꼭 필요하지 않다면 **NSIS**를 쓰세요.

| 번들          | `tauri build --bundles` | `src-tauri/target/release/bundle/` 안의 파일 |
| ------------- | ----------------------- | -------------------------------------------- |
| NSIS (`.exe`) | `nsis`                  | `nsis/App_0.2.0_x64-setup.exe`와 `nsis/App_0.2.0_x64-setup.exe.sig` |
| MSI (`.msi`)  | `msi`                   | `msi/App_0.2.0_x64_en-US.msi`와 `msi/App_0.2.0_x64_en-US.msi.sig`   |

NSIS는 관리자 권한 없이 사용자별로 설치되고, 설치 파일이 기존 설치를 그 자리에서 업데이트합니다. MSI는 그룹 정책으로 관리하는 컴퓨터에 맞습니다. `createUpdaterArtifacts: true`이면 Tauri가 설치 파일 자체에 업데이터 서명을 만들므로, 사람들이 내려받는 파일과 앱이 설치하는 파일이 같습니다. (`"v1Compatible"`이면 업데이트 번들은 별도의 `.nsis.zip` 또는 `.msi.zip`이고 자체 `.sig`가 있습니다. 그 파일을 업데이트 번들로 올리세요.)

릴리스에는 플랫폼마다 설치 파일 하나와 업데이트 번들 하나가 있으므로, NSIS와 MSI 중 하나만 게시하세요. 설치된 앱은 설치할 때 쓴 종류의 설치 파일로 업데이트됩니다. MSI에서 NSIS로 바꾸면 기존 MSI 설치에도 NSIS 설치 파일이 전달됩니다.

## 설치 파일 먼저 서명하기

Authenticode 서명은 고객이 하며, 업로드 **전에** 합니다. 서명하지 않으면 설치 파일을 내려받는 사람에게 Windows SmartScreen이 경고를 띄웁니다. `tauri.conf.json`에 설정하세요(`bundle.windows.certificateThumbprint`, 클라우드 서명 서비스라면 `bundle.windows.signCommand`). 그러면 Tauri가 빌드 중에 `.exe`나 `.msi`에 서명한 뒤, 서명된 파일에 대해 업데이터 `.sig`를 만듭니다.

빌드 후에 따로 서명하면 파일의 바이트가 바뀌어 `.sig`가 더는 맞지 않습니다. 업로드 전에 업데이터 서명을 다시 만드세요(`tauri signer sign`). 그렇지 않으면 Mocco가 릴리스를 `The signature doesn't match the file`과 함께 **실패**(Failed)로 표시합니다.

Mocco는 인증서도 업데이터 개인 키도 보관하지 않습니다.

## 릴리스 단계

Windows 러너에서 빌드 후에 다음을 추가합니다.

```yaml
- name: Publish to Mocco
  uses: fi-workers/mocco/actions/desktop-publish@<commit sha>
  with:
    app-id: <app id>
    version: ${{ steps.version.outputs.version }}
    notes-file: RELEASE_NOTES.md
    artifacts: |
      windows-x86_64 installer src-tauri/target/release/bundle/nsis/App_${{ steps.version.outputs.version }}_x64-setup.exe
      windows-x86_64 updater   src-tauri/target/release/bundle/nsis/App_${{ steps.version.outputs.version }}_x64-setup.exe
    channel: stable
  env:
    MOCCO_API_KEY: ${{ secrets.MOCCO_API_KEY }}
```

같은 파일을 종류마다 한 번씩, 두 번 적습니다. `updater` 줄에서는 파일 옆의 `.sig`를 읽습니다. MSI라면 대신 `msi/…_x64_en-US.msi` 두 줄을 쓰세요.

Mocco는 업데이트를 `windows-x86_64` 키와, 새 업데이터 플러그인이 먼저 찾는 키로 함께 제공합니다. 업데이트 번들 이름이 `.msi`나 `.msi.zip`으로 끝나면 `windows-x86_64-msi`, 아니면 `windows-x86_64-nsis`입니다. `tauri.conf.json`은 바꿀 필요가 없습니다. 엔드포인트의 `{{target}}/{{arch}}`가 이미 `windows/x86_64`입니다.

## 모든 플랫폼을 빌드해 릴리스 하나로 게시하기

플랫폼마다 자기 러너에서 빌드한 뒤, 한 작업에서 모든 파일을 릴리스 하나로 게시하세요. 그러면 새 버전이 모든 플랫폼에 한 번에 나타나고, 빌드 하나가 실패하면 아무것도 게시되지 않습니다.

```yaml
name: Release
on:
  push:
    tags: ['v*']

jobs:
  build:
    strategy:
      matrix:
        include:
          - runner: macos-latest
            platform: darwin-aarch64
            bundles: app,dmg
          - runner: windows-latest
            platform: windows-x86_64
            bundles: nsis
          - runner: ubuntu-22.04
            platform: linux-x86_64
            bundles: appimage
    runs-on: ${{ matrix.runner }}
    env:
      TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
      TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
    steps:
      - uses: actions/checkout@<commit sha>
      # Install Node, Rust and (on Linux) the system packages Tauri needs here.
      - run: npm ci
      - run: npm run tauri build -- --bundles ${{ matrix.bundles }}
      - uses: actions/upload-artifact@<commit sha>
        with:
          name: ${{ matrix.platform }}
          path: |
            src-tauri/target/release/bundle/dmg/*.dmg
            src-tauri/target/release/bundle/macos/*.app.tar.gz*
            src-tauri/target/release/bundle/nsis/*-setup.exe*
            src-tauri/target/release/bundle/appimage/*.AppImage*

  publish:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@<commit sha>
        with:
          path: release
      - id: version
        run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
      - name: Publish to Mocco
        uses: fi-workers/mocco/actions/desktop-publish@<commit sha>
        with:
          app-id: <app id>
          version: ${{ steps.version.outputs.version }}
          artifacts: |
            darwin-aarch64 installer release/darwin-aarch64/dmg/App_${{ steps.version.outputs.version }}_aarch64.dmg
            darwin-aarch64 updater   release/darwin-aarch64/macos/App.app.tar.gz
            windows-x86_64 installer release/windows-x86_64/App_${{ steps.version.outputs.version }}_x64-setup.exe
            windows-x86_64 updater   release/windows-x86_64/App_${{ steps.version.outputs.version }}_x64-setup.exe
            linux-x86_64   installer release/linux-x86_64/App_${{ steps.version.outputs.version }}_amd64.AppImage
            linux-x86_64   updater   release/linux-x86_64/App_${{ steps.version.outputs.version }}_amd64.AppImage
          channel: stable
        env:
          MOCCO_API_KEY: ${{ secrets.MOCCO_API_KEY }}
```

`upload-artifact`는 경로들의 공통 루트 아래 폴더 구조를 유지하므로, 내려받은 구조를 한 번 확인하고(`ls -R release`) 경로를 맞추세요. 모든 Action은 커밋으로 고정하세요. 게시 작업에는 Rust도, 서명 키도, Windows 러너도 필요 없습니다. 파일과 `.sig`만 읽습니다.

## 다음 단계

- [Linux용 Tauri 앱 게시하기](https://www.mocco.club/docs/ko/articles/r79gy9-publish-tauri-linux): AppImage, deb, rpm을 다룹니다.
- [curl로 게시하기](https://www.mocco.club/docs/ko/articles/by2fx3-publish-with-curl): 어떤 CI에서든 같은 업로드를 실행합니다. `.exe`의 콘텐츠 유형은 `application/vnd.microsoft.portable-executable`, `.msi`는 `application/x-msi`를 쓰세요.
