Skip to content

Commit 6dddc59

Browse files
authored
release stable (#229)
1 parent 1c2542f commit 6dddc59

File tree

16 files changed

+415
-163
lines changed

16 files changed

+415
-163
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
branches:
66
- master
7+
tags:
8+
- '[0-9]+.*'
79
pull_request:
810
workflow_dispatch:
911

@@ -112,18 +114,30 @@ jobs:
112114
path: |
113115
meta.json
114116
117+
- name: Generate version.json
118+
if: ${{ matrix.arch == 'arm64' && matrix.type == 'Release' }}
119+
run: python scripts/generate-version.py
120+
121+
- name: Upload version.json
122+
if: ${{ matrix.arch == 'arm64' && matrix.type == 'Release' }}
123+
uses: actions/upload-artifact@v4
124+
with:
125+
name: version.json
126+
path: |
127+
version.json
128+
115129
- name: Setup tmate session
116130
if: ${{ failure() }}
117131
uses: mxschmitt/action-tmate@v3
118132

119133
compare:
120-
if: ${{ github.ref != 'refs/heads/master' }}
134+
if: ${{ github.event_name == 'pull_request' }}
121135
needs: build
122136
uses: ./.github/workflows/compare.yml
123137

124138
release:
125139
needs: build
126-
if: ${{ github.ref == 'refs/heads/master' && !contains(github.event.head_commit.message, '!release') }}
140+
if: ${{ github.event_name != 'pull_request' }}
127141
runs-on: ubuntu-latest
128142
steps:
129143
- name: Download artifact
@@ -132,6 +146,7 @@ jobs:
132146
merge-multiple: true
133147

134148
- name: Create Nightly release
149+
if: ${{ github.ref == 'refs/heads/master' }}
135150
uses: 'marvinpinto/action-automatic-releases@latest'
136151
with:
137152
repo_token: ${{ secrets.GITHUB_TOKEN }}
@@ -141,3 +156,15 @@ jobs:
141156
files: |
142157
Fcitx5-*.tar.bz2
143158
meta.json
159+
version.json
160+
161+
- name: Create Stable release
162+
if: ${{ github.ref != 'refs/heads/master' }}
163+
uses: 'marvinpinto/action-automatic-releases@latest'
164+
with:
165+
repo_token: ${{ secrets.GITHUB_TOKEN }}
166+
draft: true
167+
prerelease: false
168+
title: ${{ github.ref_name }}
169+
files: |
170+
Fcitx5-*.tar.bz2

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ assets/en.lproj/Localizable.strings
99
assets/po/base.pot
1010
meta.swift
1111
*~
12+
version.json
13+
*.pyc

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ English
66

77
[Fcitx5](https://github.com/fcitx/fcitx5) input method framework ported to macOS.
88

9-
Public beta: please download [installer](https://github.com/fcitx-contrib/fcitx5-macos-installer).
9+
Please download [installer](https://github.com/fcitx-contrib/fcitx5-macos-installer).
1010

1111
## Build
1212
Native build on Intel and Apple Silicon is supported.

README.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
[Fcitx5](https://github.com/fcitx/fcitx5) 输入框架的 macOS 移植。
88

9-
公测进行中,请下载[安装器](https://github.com/fcitx-contrib/fcitx5-macos-installer/blob/master/README.zh-CN.md)
9+
请下载[安装器](https://github.com/fcitx-contrib/fcitx5-macos-installer/blob/master/README.zh-CN.md)
754 Bytes
Binary file not shown.

docs/release.zh-CN.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 发布新版本
2+
3+
* 确保当前位于和 GitHub 同步的 master 分支,工作树干净。
4+
* `python scripts/prepare-release.py`,它会
5+
* 对当前 commit 打 tag;
6+
* 将新版本插入 [version.jsonl](../version.jsonl) 首行;
7+
* 更新 [CMakeLists.txt](../CMakeLists.txt) 中的版本号;
8+
* 将上述两个文件的更改加入暂存区。
9+
* `git push origin 版本号`,这会在 GitHub 上创建一个新的 draft release。
10+
* 编辑更新日志,删除 debug tar,点击 Publish release。
11+
*[fcitx5-plugins](https://github.com/fcitx-contrib/fcitx5-plugins) 中发布新版插件。
12+
* 如果下一个版本将抛弃 macOS 的主/次版本,更改 CMakeLists.txt 中 project 的主/次版本和 CMAKE_OSX_DEPLOYMENT_TARGET。
13+
* 提交更改,`git push origin master`,这将更新 latest 中的 version.json,用户检查更新时将获取到新版信息。
14+
*[fcitx5-macos-installer](https://github.com/fcitx-contrib/fcitx5-macos-installer) 中发布新版安装包。

scripts/common.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import re
2+
import subprocess
3+
4+
def dollar(command: str):
5+
return subprocess.check_output(command, shell=True, text=True).strip()
6+
7+
8+
def get_json(tag: str):
9+
cmake_osx_deployment_target_line = dollar('grep "set(CMAKE_OSX_DEPLOYMENT_TARGET" CMakeLists.txt')
10+
match = re.search(r'CMAKE_OSX_DEPLOYMENT_TARGET ([\d\.]+)\)', cmake_osx_deployment_target_line)
11+
if match is None:
12+
raise Exception('CMakeLists.txt should set CMAKE_OSX_DEPLOYMENT_TARGET properly.')
13+
macos = match.group(1)
14+
return {
15+
'tag': tag,
16+
'macos': macos,
17+
'sha': dollar('git rev-parse HEAD'),
18+
'time': int(dollar('git show --no-patch --format=%ct'))
19+
}

scripts/generate-version.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import json
2+
from common import get_json
3+
4+
versions = []
5+
6+
with open('version.jsonl') as f:
7+
while line := f.readline():
8+
versions.append(json.loads(line))
9+
10+
# Generate sha and time for tag latest.
11+
latest = get_json('latest')
12+
13+
with open('version.json', 'w') as f:
14+
json.dump({
15+
'versions': [latest] + versions
16+
}, f)

scripts/prepare-release.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import json
2+
import os
3+
import re
4+
from common import dollar, get_json
5+
6+
def get_version():
7+
project_line = dollar('grep "project(fcitx5-macos VERSION" CMakeLists.txt')
8+
match = re.search(r'VERSION ([\d\.]+)', project_line)
9+
if match is None:
10+
raise Exception('CMakeLists.txt should set VERSION properly.')
11+
return match.group(1)
12+
13+
version = get_version()
14+
if os.system(f'git tag -a {version} -m "release {version}"') != 0:
15+
raise Exception('Failed to create git tag.')
16+
17+
with open('version.jsonl') as f:
18+
content = f.read()
19+
20+
with open('version.jsonl', 'w') as f:
21+
json.dump(get_json(version), f)
22+
f.write('\n' + content)
23+
24+
major, minor, patch = version.split('.')
25+
26+
if os.system(f'sed -i.bak "s/fcitx5-macos VERSION {major}\\.{minor}\\.{patch}/fcitx5-macos VERSION {major}.{minor}.{int(patch) + 1}/" CMakeLists.txt') != 0:
27+
raise Exception('Failed to update version in CMakeLists.txt.')
28+
os.system('rm CMakeLists.txt.bak')
29+
30+
os.system('git add version.jsonl CMakeLists.txt')

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ execute_process(COMMAND git show --no-patch --format=%ct
66
OUTPUT_VARIABLE UNIX_TIME
77
OUTPUT_STRIP_TRAILING_WHITESPACE
88
)
9+
execute_process(COMMAND bash -c "git describe --exact-match || echo latest"
10+
OUTPUT_VARIABLE RELEASE_TAG
11+
OUTPUT_STRIP_TRAILING_WHITESPACE
12+
)
913
configure_file(config/meta.swift.in ${CMAKE_CURRENT_SOURCE_DIR}/config/meta.swift @ONLY)
1014

1115
file(GLOB CONFIG_UI_FILES CONFIGURE_DEPENDS config/*.swift)

0 commit comments

Comments
 (0)