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
76 changes: 60 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,74 @@
name: Java CI
name: Build and Test

on:
push:
branches: [ main ]
pull_request: {}
pull_request: { }

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v5

- uses: actions/setup-java@v5
with:
java-version: 17
distribution: zulu
- uses: actions/setup-java@v5
with:
java-version: 17
distribution: zulu

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}

- name: Build with Gradle
run: ./gradlew -Pversion="" build
- name: Build with Gradle
run: ./gradlew -Pversion="" build

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Jars
path: build/libs/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Jars
path: build/libs/

releaseDraft:
name: Release draft
if: github.event_name != 'pull_request'
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-java@v5
with:
java-version: 17
distribution: zulu
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: true
cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}

- name: Remove Old Release Drafts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/{owner}/{repo}/releases \
--jq '.[] | select(.draft == true) | .id' \
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}

- name: Create Release Draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(./gradlew properties --property version --quiet --console=plain | tail -n 1 | cut -f2- -d ' ')
RELEASE_NOTE="./build/tmp/release_note.txt"
./gradlew getChangelog --unreleased --no-header --quiet --console=plain --output-file=$RELEASE_NOTE

gh release create $VERSION \
--draft \
--title $VERSION
--notes-file $RELEASE_NOTE
79 changes: 79 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Publish
on:
release:
types: [prereleased, released]

jobs:

release:
name: Publish release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:

- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}

- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17

- uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: true
cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}

- name: Publish to Maven Central
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USER }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_GPG_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_GPG_SERCRET_PASSWORD }}
run: ./gradlew publishToMavenCentral --continue --info

- name: Patch Changelog
if: ${{ github.event.release.body != '' }}
env:
CHANGELOG: ${{ github.event.release.body }}
run: |
RELEASE_NOTE="./build/tmp/release_note.txt"
mkdir -p "$(dirname "$RELEASE_NOTE")"
echo "$CHANGELOG" > $RELEASE_NOTE

./gradlew patchChangelog --release-note-file=$RELEASE_NOTE

- name: Upload Release Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.event.release.tag_name }} ./build/libs/*.jar

- name: Create Pull Request
if: ${{ steps.properties.outputs.changelog != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ github.event.release.tag_name }}"
BRANCH="changelog-update-$VERSION"
LABEL="release changelog"

git config user.email "action@github.com"
git config user.name "GitHub Action"

git checkout -b $BRANCH
git commit -am "Changelog update - $VERSION [skip ci]"
git push --set-upstream origin $BRANCH

gh label create "$LABEL" \
--description "Pull requests with release changelog update" \
--force \
|| true

gh pr create \
--title "Changelog update - \`$VERSION\`" \
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
--label "$LABEL" \
--head $BRANCH
63 changes: 47 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,59 @@
# Changelog
# PinIn Changelog

### 1.2.0
## [Unreleased]

Changed match rules:
### Added

> Tone is no longer acceptable when missing vowel, e.g. "测试文本" no longer matches "c4shi", but still matches "ce4shi". Pinyin sequence (音序) can be used as abbreviation in Quanpin (全拼), e.g. "测试文本" matches "cswb" now without any fuzzy option, while in previous versions it only matches "cshwb".
- Support for matching characters in the Unicode Supplementary Planes.

Added switch for accelerator, disabled by default:
## [1.4.0]

> When calling immediate matching functions continuously with different `s1` but same `s2`, for, say, 100 times, they are considered stable calls. If the scenario uses mainly stable calls and most of `s1` contains Chinese characters, using accelerator provides significant speed up. Otherwise, the overhead will slow down the matching process. Accelerate mode is disabled by default for consistency in different scenarios.
### Changed

Fixed several spelling issues in Daqian (大千) keyboard
Changed some APIs
- Simplified format API for easier usage.

### 1.3.0
## [1.3.1]

Added support for customized dictionary loading
Improved `CachedSearcher` math model for massive data
Fixed incorrect spelling in Phonetic keyboard starting with `v`
### Fixed

### 1.3.1
- `DictLoader` accessibility issue.

Fixed `DictLoader` accessibility issue
## [1.3.0]

### 1.4.0
### Added

Changed format API for simplified usage
- Support for customized dictionary loading.

### Changed

- Improved `CachedSearcher` math model for massive data.

### Fixed

- Incorrect spelling in Phonetic keyboard starting with `v`.

## [1.2.0]

### Changed

- Match rules:
- Tone is no longer acceptable when missing vowel.
e.g. 「测试文本」 no longer matches `c4shi`, but still matches `ce4shi`.
- Pinyin sequence (音序) can be used as abbreviation in Quanpin (全拼).
e.g. 「测试文本」 now matches `cswb` without fuzzy option,
while in previous versions it only matched `cshwb`.
- Some APIs updated.

### Added

- Accelerator switch (disabled by default):
- When calling immediate matching functions continuously with different `s1` but same `s2` (e.g., 100 times), they
are considered stable calls.
- If most `s1` contains Chinese characters and the scenario is mainly stable calls, accelerator provides significant
speed up.
- Otherwise, the overhead slows down the process.
- Disabled by default to keep consistent performance across scenarios.

### Fixed

- Several spelling issues in Daqian (大千) keyboard.
34 changes: 33 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ plugins {
java
id("me.champeau.jmh") version "0.7.3"
id("com.gradleup.shadow") version "9.2.0"
id("com.vanniktech.maven.publish") version "0.34.0"
id("org.jetbrains.changelog") version "2.4.0"
}

group = "me.towdium.pinin"
group = "dev.ghostflyby"
version = "1.6.0"

repositories {
Expand All @@ -25,6 +27,10 @@ tasks.test {
testLogging.showStandardStreams = true
}

tasks.jmhJar {
destinationDirectory = layout.buildDirectory.dir("jmhlibs")
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release = 8
Expand All @@ -43,3 +49,29 @@ java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

mavenPublishing {
publishToMavenCentral(automaticRelease = true)
signAllPublications()
pom {
name = "PinIn"
description = "Library for solving Chinese pinyin matching problems"
url = "https://github.com/ghostflyby/PinIn"
licenses {
license {
name = "MIT License"
url = "https://spdx.org/licenses/MIT.html"
}
}
developers {
developer {
id = "ghostflyby"
email = "ghostflyby+maven@outlook.com"
}
}
scm {
url = "https://github.com/ghostflyby/PinIn.git"
tag = "v$version"
}
}
}