Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/release-winget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Windows Release for WinGet

on:
push:
tags:
- "ver.*"
workflow_dispatch:
inputs:
version:
description: "Release version or tag, for example 1.2.0, 1.2.1-rc1, 1.2.1-alpha1, or ver.1.2.0"
required: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-release:
runs-on: windows-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64

- name: Resolve version
id: version
shell: pwsh
run: |
$value = "${{ github.event.inputs.version }}"
if (-not $value -and "${{ github.ref_type }}" -eq "tag") {
$value = "${{ github.ref_name }}"
}
if ($value.StartsWith("ver.")) {
$clean = $value.Substring(4)
} elseif ($value.StartsWith("v")) {
$clean = $value.Substring(1)
} else {
$clean = $value
}
"value=$clean" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append

- name: Build portable release and WinGet manifests
shell: pwsh
run: |
./scripts/release-windows-winget.ps1 `
-Version "${{ steps.version.outputs.value }}" `
-OutputDir release `
-GitHubRepository "${{ github.repository }}" `
-PackageIdentifier "BYVoid.OpenCC" `
-Publisher "BYVoid"

- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: opencc-winget-release-${{ steps.version.outputs.value }}
path: |
release/*.zip
release/*.sha256
release/winget-manifests/**

- name: Publish GitHub release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: |
release/*.zip
release/*.sha256
generate_release_notes: true
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Discussion (Telegram): https://t.me/open_chinese_convert
* [Fedora](https://packages.fedoraproject.org/pkgs/opencc/opencc/)
* [Arch Linux](https://archlinux.org/packages/extra/x86_64/opencc/)
* [macOS](https://formulae.brew.sh/formula/opencc)
* WinGet (`winget install BYVoid.OpenCC`)
* [Bazel](https://registry.bazel.build/modules/opencc)
* [Node.js](https://npmjs.org/package/opencc)
* [Python](https://pypi.org/project/OpenCC/)
Expand All @@ -43,6 +44,8 @@ Discussion (Telegram): https://t.me/open_chinese_convert
* Windows (x86_64): [Latest build](https://ci.appveyor.com/api/projects/Carbo/opencc/artifacts/OpenCC.zip?branch=master&job=Environment:%20nodejs_version=none;%20Platform:%20x64)
* Windows (x86): [Latest build](https://ci.appveyor.com/api/projects/Carbo/opencc/artifacts/OpenCC.zip?branch=master&job=Environment:%20nodejs_version=none;%20Platform:%20x86)

For a versioned Windows release intended for WinGet distribution, see [doc/windows-winget-release.md](doc/windows-winget-release.md).

## Usage 使用

### Online demo 線上轉換展示
Expand Down
146 changes: 146 additions & 0 deletions doc/windows-winget-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Windows Release for WinGet

This repository now includes a Windows release path intended for WinGet distribution.

## Output

Running `scripts/release-windows-winget.ps1` produces:

- `OpenCC-<version>-windows-x64-portable.zip`
- `OpenCC-<version>-windows-x64-portable.zip.sha256`
- `winget-manifests/b/BYVoid/OpenCC/<version>/`

By default the WinGet identity remains `BYVoid.OpenCC`, but the GitHub release source can be pointed at another repository for testing.

The zip is structured as a portable package:

- `OpenCC-<version>-windows-x64/bin/*.exe`
- `OpenCC-<version>-windows-x64/bin/opencc.dll`
- `OpenCC-<version>-windows-x64/share/opencc/*.json`
- `OpenCC-<version>-windows-x64/share/opencc/*.ocd2`

OpenCC now also searches `../share/opencc` relative to the running executable or library on Windows, so the portable package works after WinGet extracts it.

## Directory layout

With the default arguments:

- `BuildDir = build\winget-x64`
- `OutputDir = dist\winget-x64`

the Windows release flow writes files into these locations:

```text
build/
winget-x64/
src/
data/
test/
Release/
Testing/

dist/
winget-x64/
OpenCC-<version>-windows-x64-portable.zip
OpenCC-<version>-windows-x64-portable.zip.sha256
staging/
OpenCC-<version>-windows-x64/
bin/
opencc.exe
opencc_dict.exe
opencc_phrase_extract.exe
opencc.dll
share/
opencc/
*.json
*.ocd2
LICENSE.txt
README.md
winget-manifests/
b/
BYVoid/
OpenCC/
<version>/
BYVoid.OpenCC.yaml
BYVoid.OpenCC.installer.yaml
BYVoid.OpenCC.locale.en-US.yaml
```

The important distinction is:

- `build\winget-x64` is the CMake and test working directory
- `dist\winget-x64\staging\...` is the installed portable tree before zipping
- `dist\winget-x64\OpenCC-<version>-windows-x64-portable.zip` is the final release asset
- `dist\winget-x64\winget-manifests\...` is the manifest payload to copy into `winget-pkgs`

## Local build

Run this from a Visual Studio developer shell or an environment where MSVC is configured:

```powershell
./scripts/release-windows-winget.ps1
```

To build a specific tag or skip tests:

```powershell
./scripts/release-windows-winget.ps1 -Version 1.2.0
./scripts/release-windows-winget.ps1 -Version 1.2.1-rc1
./scripts/release-windows-winget.ps1 -Version 1.2.1-alpha1
./scripts/release-windows-winget.ps1 -Version ver.1.2.0 -SkipTests
```

To test from a fork while keeping the upstream WinGet package identity:

```powershell
./scripts/release-windows-winget.ps1 -Version 1.2.1-rc1 -GitHubRepository frankslin/OpenCC
```

This keeps:

- `PackageIdentifier: BYVoid.OpenCC`
- `manifests/b/BYVoid/OpenCC/<version>/`

but points release URLs at:

- `https://github.com/frankslin/OpenCC`

Accepted version formats are:

- `x.y.z`
- `x.y.z-rcN`
- `x.y.z-alphaN`

Values such as `1.2.0.exp` are rejected.

## GitHub Actions

The workflow `.github/workflows/release-winget.yml` runs on:

- pushed tags matching `ver.*`
- manual `workflow_dispatch`

On a tag build it will:

1. build the x64 portable Windows release
2. upload the zip and checksum to the GitHub release
3. upload the generated WinGet manifests as a workflow artifact

The workflow passes `${{ github.repository }}` into the release script, so fork builds point to the fork's GitHub release URLs automatically while still using the upstream WinGet package identifier by default.

## WinGet submission

The generated manifests are ready to copy into a `winget-pkgs` checkout under:

```text
manifests/b/BYVoid/OpenCC/<version>/
```

Recommended validation flow in a `winget-pkgs` clone:

```powershell
winget validate manifests\b\BYVoid\OpenCC\<version>
winget install --manifest manifests\b\BYVoid\OpenCC\<version>
```

If you later automate WinGet submission, the generated manifest directory can be used directly as the source payload for a PR bot or `wingetcreate update`.
Loading
Loading