Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from MarvNC/automate-release
Browse files Browse the repository at this point in the history
Automate Releases from Tags
MarvNC authored Dec 23, 2023
2 parents 22b7081 + ed9e60d commit b4b98cc
Showing 5 changed files with 65 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/workflows/build-dicts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and Release Dictionaries on Tag

on:
workflow_dispatch:
push:
tags:
- v*

jobs:
build-release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up node environment
uses: actions/setup-node@v4
with:
node-version: '21'

- name: Install dependencies
run: npm install

- name: Build
run: ./scripts/buildAll.sh

- name: Create Release With gh CLI and Upload ./dist/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
run: |
gh release create "$tag" ./dist/*.zip --notes-from-tag
2 changes: 2 additions & 0 deletions inputs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ja,zh
2022-12-01
28 changes: 28 additions & 0 deletions scripts/buildAll.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Read input from inputs.txt
input_file="inputs.txt"
IFS=',' read -r -a langs < <(sed -n '1p' "$input_file")
date_val=$(sed -n '2p' "$input_file")

# Format date for file naming
dateFile=$(date -d "$date_val" +"%Y.%m.%d")

# Output array and dateFile
echo "langs array: ${langs[@]}"
echo "date_val variable: $date_val"
echo "dateFile variable: $dateFile"

# For each lang, run downloadDump.sh with <lang> <dateFile>
for lang in "${langs[@]}"
do
echo "Running downloadDump.sh with $lang and $dateFile"
./scripts/downloadDump.sh "$lang" "$dateFile"
done

# Run node src/convertWikipedia.js with <lang> <date_val> for each lang
for lang in "${langs[@]}"
do
echo "Running convertWikipedia.js with $lang and $date_val"
node src/convertWikipedia.js "$lang" "$date_val"
done
File renamed without changes.
4 changes: 3 additions & 1 deletion src/convertWikipedia.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ import { parseLine } from './parseLine.js';
import { languagesAllowed } from './constants.js';

const linkCharacter = '⧉';
const exportDirectory = './dist';

/**
*
* @param {string} lang
@@ -64,7 +66,7 @@ div.gloss-sc-div[data-sc-wikipedia=term-specifier] {
attribution: `https://${lang.toLowerCase()}.wikipedia.org/`,
});

await dict.export('./');
await dict.export(exportDirectory);
console.log(`Exported to ${outputZipName(lang, date, version)}`);
})().catch((e) => {
console.error(e);

0 comments on commit b4b98cc

Please sign in to comment.