Build dictionary #66
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build dictionary | |
on: | |
push: | |
branches: | |
- pkg-moegirl | |
workflow_dispatch: {} | |
jobs: | |
build-and-publish: | |
if: "(contains(github.event_name, 'schedule') || !contains(github.event.commits[0].message, 'ci ckip'))" | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref_name }} | |
persist-credentials: false | |
fetch-depth: "0" | |
path: "toolkit" | |
- name: Build dictionary | |
id: build-dictionary | |
run: | | |
DATE=$(date +%Y%m%d) | |
mkdir $GITHUB_WORKSPACE/artifacts | |
docker run -v $GITHUB_WORKSPACE/artifacts:/artifacts -v $GITHUB_WORKSPACE/toolkit:/toolkit archlinux:base-devel bash /toolkit/utils/build.sh "$DATE" | |
echo "DATE=$DATE" >> "$GITHUB_OUTPUT" | |
- name: Checkout profile | |
uses: actions/checkout@v4 | |
with: | |
ref: pkg-moegirl | |
persist-credentials: false | |
fetch-depth: "0" | |
path: "profile" | |
- name: Update date | |
run: | | |
pushd profile | |
DATE="${{ steps.build-dictionary.outputs.DATE }}" | |
echo $DATE > LATEST | |
cat > recipe.yaml <<EOF | |
# encoding: utf-8 | |
--- | |
recipe: | |
Rx: moegirl-dict | |
description: >- | |
Install moegirl dict from fcitx5-pinyin-moegirl | |
download_files: >- | |
moegirl.dict.yaml::https://github.com/outloudvi/mw2fcitx/releases/download/$DATE/moegirl.dict.yaml | |
install_files: >- | |
moegirl.dict.yaml | |
EOF | |
git add ./LATEST | |
git add ./recipe.yaml | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Actions" | |
git commit -m "chore: version $DATE" | |
popd | |
- name: Push the commit | |
uses: ad-m/github-push-action@master | |
with: | |
branch: pkg-moegirl | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
directory: profile | |
- name: Release | |
shell: bash | |
run: | | |
DATE="${{ steps.build-dictionary.outputs.DATE }}" | |
wget https://github.com/tcnksm/ghr/releases/download/v0.15.0/ghr_v0.15.0_linux_amd64.tar.gz -O ghr.tgz | |
tar xzf ghr.tgz | |
pushd profile | |
export COMMIT=$(git rev-parse HEAD) | |
popd | |
ghr_v0.15.0_linux_amd64/ghr -t ${{ secrets.GITHUB_TOKEN }} -u ${GITHUB_REPOSITORY/\/*/} -r ${GITHUB_REPOSITORY/*\//} -c "$COMMIT" -delete ${DATE} ./artifacts/ |