-
Notifications
You must be signed in to change notification settings - Fork 9
179 lines (150 loc) · 5.58 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Create a new release
on:
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
edition_languages: ${{ steps.load-languages.outputs.edition_languages }}
isos: ${{ steps.load-languages.outputs.isos }}
calver: ${{ steps.tag.outputs.calver }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install jq
run: sudo apt-get install -y jq
- name: Install npm dependencies
run: npm install
- name: Configure git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Tag the repository
id: tag
run: |
# See https://docs.github.com/en/get-started/using-git/dealing-with-special-characters-in-branch-and-tag-names
TAG=v$(date -Iseconds | sed 's/[T:\+]/-/g')
CALVER=$(date +'%y.%m.%d.%H')
echo "$TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "calver=$CALVER" >> $GITHUB_OUTPUT
git tag -a $TAG -m "Published version $TAG" ${GITHUB_SHA}
git push origin $TAG
- name: Load Languages
id: load-languages
run: |
edition_languages=$(jq '[.[] | select(.hasEdition == true) | .language]' languages.json | jq -c 'map(.)')
echo "edition_languages=$edition_languages" >> $GITHUB_OUTPUT
isos=$(jq -r '.[].iso' languages.json | jq -R -s -c 'split("\n") | map(select(. != ""))')
echo "isos=$isos" >> $GITHUB_OUTPUT
- name: Generate markdown table
id: generate_markdown
run: |
./tools/generate-downloads-table.sh
- name: Create pull request if necessary
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "Update downloads.md with list of .zip files"
body: "This PR updates the downloads.md file with a table listing all .zip files."
convert:
needs: prepare
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
edition_language: ${{fromJson(needs.prepare.outputs.edition_languages)}}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Create .env file
run: |
cp .env.example .env
sed -i 's/^DICT_NAME=.*/DICT_NAME=kty/' .env
- name: Install jq
run: sudo apt-get install -y jq
- name: Install gzip
run: sudo apt-get install -y gzip
- name: Run auto.sh script
run: ./auto.sh "${{ matrix.edition_language }}" ? ?
- name: Upload dictionary files
uses: softprops/action-gh-release@v2
with:
name: ${{ needs.prepare.outputs.calver }}
tag_name: ${{ needs.prepare.outputs.tag }}
prerelease: true
generate_release_notes: true
files: "data/language/**/*.zip"
- name: Upload index.json files
uses: softprops/action-gh-release@v2
with:
name: ${{ needs.prepare.outputs.calver }}
tag_name: ${{ needs.prepare.outputs.tag }}
prerelease: true
generate_release_notes: true
files: "data/language/**/*-index.json"
merge-ipa:
needs: ["prepare", "convert"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install npm dependencies
run: npm install
- name: Download IPA dicts
run: |
mapfile -t iso_array < <(printf '%s' '${{needs.prepare.outputs.isos}}' | jq -r '.[]')
edition_languages=$(printf '%s' '${{needs.prepare.outputs.edition_languages}}' | jq -r 'join(" ")')
for source_iso in "${iso_array[@]}"; do
for target_iso in "${iso_array[@]}"; do
filename="kty-${source_iso}-${target_iso}-ipa.zip"
if [ -f "$filename" ]; then
continue
fi
if [[ ! "$edition_languages" == *"$target_iso"* ]]; then
continue
fi
url="https://github.com/yomidevs/kaikki-to-yomitan/releases/download/${{needs.prepare.outputs.tag}}/kty-${source_iso}-${target_iso}-ipa.zip"
curl -s -O -f -L "$url" || echo "Skipping $url due to an error."
done
done
- name: Run merge-ipa
run: node merge-ipa.js
- name: Delete downloaded IPA files
run: rm *.zip
- name: Upload dictionary files
uses: softprops/action-gh-release@v2
with:
name: ${{ needs.prepare.outputs.calver }}
tag_name: ${{ needs.prepare.outputs.tag }}
prerelease: true
generate_release_notes: true
files: "data/language/**/*.zip"
- name: Upload index.json files
uses: softprops/action-gh-release@v2
with:
name: ${{ needs.prepare.outputs.calver }}
tag_name: ${{ needs.prepare.outputs.tag }}
prerelease: true
generate_release_notes: true
files: "data/language/**/*-index.json"