Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from maxchang3/refactor-build
Browse files Browse the repository at this point in the history
  • Loading branch information
maxchang3 committed Jul 13, 2023
2 parents 20b2bae + 293436a commit 998b3bb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,24 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
cache: 'pip'
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
curl https://raw.githubusercontent.com/kfcd/chaizi/master/chaizi-jt.txt >> chaizi-jt.txt
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run build.py
run: python build.py

- name: Cache chaizi-jt.txt file
id: cache-primes
uses: actions/cache@v3
with:
path: ./chaizi-jt.txt
key: ${{ runner.os }}-chaizi-jt-${{ hashFiles('./chaizi-jt.txt') }}

- name: Run Makefile
run: make

- name: Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
./src/chaizi.dict.yaml
./src/chaizi.schema.yaml
./build/chaizi.dict.yaml
./build/chaizi.schema.yaml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
build
chaizi-jt.txt
chaizi.dict.yaml
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.PHONY: all clean
all: chaizi-jt.txt chaizi.schema.yaml chaizi.dict.yaml

chaizi-jt.txt:
if [ -f chaizi-jt.txt ]; then curl https://raw.githubusercontent.com/kfcd/chaizi/master/chaizi-jt.txt >> chaizi-jt.txt

chaizi.schema.yaml:
mkdir -p build && cp src/chaizi.schema.yaml build/chaizi.schema.yaml

chaizi.dict.yaml: chaizi-jt.txt chaizi.schema.yaml build.py
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python build.py

clean:
rm -f chaizi-jt.txt
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def chai():
item = f"{char.strip()}\t{pinyin}"
if (item in yaml): continue # 去重
yaml.append(item)
with open("src/chaizi.dict.yaml", "w") as f:
with open("build/chaizi.dict.yaml", "w") as f:
f.write("\n".join(yaml))

if __name__ == "__main__":
Expand Down

0 comments on commit 998b3bb

Please sign in to comment.