Skip to content

Commit 7ac3ab5

Browse files
committed
Add guide links workflow
1 parent fe9b896 commit 7ac3ab5

File tree

4 files changed

+75
-5
lines changed

4 files changed

+75
-5
lines changed

.github/workflows/guide-links.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Guide Links CI
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
pot:
10+
name: Create guide links
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [ 20 ]
16+
17+
steps:
18+
- name: '[setup] Checkout Project'
19+
uses: actions/checkout@v4
20+
21+
- name: '[setup] Node.js ${{ matrix.node-version }}'
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
26+
- name: '[app] Install'
27+
run: |
28+
npm ci
29+
30+
- name: '[app] Create Guide Links'
31+
run: |
32+
npm run guide-links
33+
34+
- name: '[release] Check Prerelease'
35+
id: check_prerelease
36+
run: |
37+
GITHUB_TAG=`echo $GITHUB_REF | cut -d/ -f3`
38+
if [[ $GITHUB_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
39+
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
40+
else
41+
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
42+
fi
43+
44+
- name: '[release] Create & Upload Artifacts'
45+
uses: ncipollo/release-action@v1
46+
with:
47+
allowUpdates: true
48+
artifactErrorsFailBuild: true
49+
artifacts: "guide-links.json"
50+
artifactContentType: application/json
51+
prerelease: ${{ steps.check_prerelease.outputs.is_prerelease }}
52+
replacesArtifacts: true

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ engine-wizard/static/wizard/config.js
1616
# locale
1717
!*/locale
1818
/locale
19+
20+
# guide links
21+
guide-links.json

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
"build:registry": "COMPONENT=registry ./scripts/build.sh",
99
"build:wizard": "COMPONENT=wizard ./scripts/build.sh",
1010
"clean": "rm -rf dist",
11+
"guide-links": "node scripts/create-guide-links.js",
12+
"pot": "mkdir -p locale && npm run pot:registry && npm run pot:wizard",
13+
"pot:registry": "COMPONENT=registry node scripts/create-pot-file.js",
14+
"pot:wizard": "COMPONENT=wizard node scripts/create-pot-file.js",
15+
"review": "elm-review",
1116
"start": "npm run start:wizard",
1217
"start:registry": "COMPONENT=registry webpack serve",
1318
"start:wizard": "COMPONENT=wizard webpack serve",
@@ -16,11 +21,7 @@
1621
"test:registry": "npm run test:elm",
1722
"test:wizard": "npm run test:elm && npm run test:wizard:icon-set && npm run test:wizard:locale",
1823
"test:wizard:icon-set": "COMPONENT=wizard node scripts/test-icon-set.js",
19-
"test:wizard:locale": "COMPONENT=wizard node scripts/test-locale.js",
20-
"review": "elm-review",
21-
"pot": "mkdir -p locale && npm run pot:registry && npm run pot:wizard",
22-
"pot:registry": "COMPONENT=registry node scripts/create-pot-file.js",
23-
"pot:wizard": "COMPONENT=wizard node scripts/create-pot-file.js"
24+
"test:wizard:locale": "COMPONENT=wizard node scripts/test-locale.js"
2425
},
2526
"devDependencies": {
2627
"@lydell/elm": "^0.19.1-14",

scripts/create-guide-links.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const fs = require('fs')
2+
3+
4+
const elmFile = 'engine-wizard/elm/Wizard/Common/GuideLinks.elm'
5+
const fileContent = fs.readFileSync(elmFile, 'utf8')
6+
const keyValueRegex = /\( "(.*?)", "(.*?)" \)/g
7+
const result = {}
8+
9+
let line
10+
while ((line = keyValueRegex.exec(fileContent)) !== null) {
11+
result[line[1]] = line[2]
12+
}
13+
14+
fs.writeFileSync('guide-links.json', JSON.stringify(result, null, 2))

0 commit comments

Comments
 (0)