From 6a5a2aa00c2130cc24588be5f31dbd64a8f19530 Mon Sep 17 00:00:00 2001 From: "K.B.Dharun Krishna" Date: Sun, 3 Mar 2024 18:12:32 +0530 Subject: [PATCH 1/3] feat: switch translations workflow to use GitHub releases Signed-off-by: K.B.Dharun Krishna --- .github/workflows/translations.yml | 100 +++++++++++++++++------------ 1 file changed, 59 insertions(+), 41 deletions(-) diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml index 7aaf544..e335995 100644 --- a/.github/workflows/translations.yml +++ b/.github/workflows/translations.yml @@ -1,48 +1,66 @@ +name: Generate and publish translations + on: - workflow_dispatch: + push: + tags: + - '*' schedule: - - cron: "0 0 1 * *" + # This will run at 00:00 UTC on the first day of every month + - cron: '0 0 1 * *' + workflow_dispatch: + +env: + GH_TOKEN: ${{ github.token }} + +permissions: + contents: write # to upload assets to releases jobs: translations: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - - name: Initialize project - run: | - npm ci - - name: Build - run: | - npm run build - - name: Fetch sources - run: | - wget https://github.com/tldr-pages/tldr/archive/refs/heads/main.zip --output-document /tmp/main.zip - unzip /tmp/main.zip -d /tmp - - name: Execute - run: | - npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output /tmp/datasets - - name: Package artifacts - run: | - mkdir /tmp/dist - tar czf /tmp/dist/tldr-pages-translation-pairs.tar.gz --directory /tmp datasets - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: /tmp/dist - - deploy: - needs: translations - runs-on: ubuntu-latest - permissions: - pages: write - id-token: write - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + - name: Install npm dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Fetch sources + run: | + wget https://github.com/tldr-pages/tldr/archive/refs/heads/main.zip --output-document /tmp/main.zip + unzip /tmp/main.zip -d /tmp + + - name: Generate CSV dataset + run: | + npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset --format csv + zip tldr-translations-dataset.zip tldr-translation-pairs-dataset/* + + - name: Generate TMX dataset + run: | + npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset-tmx --format tmx + zip tldr-translations-dataset-tmx.zip tldr-translation-pairs-dataset-tmx/* + + - name: Generate JSON dataset + run: | + npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset-json --format json + zip tldr-translations-dataset-json.zip tldr-translation-pairs-dataset-json/* + + - name: Generate XML dataset + run: | + npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset-xml --format xml + zip tldr-translations-dataset-xml.zip tldr-translation-pairs-dataset-xml/* + + - name: Deploy to Release + if: github.repository == 'tldr-pages/tldr-translation-pairs-gen' && github.ref == 'refs/heads/main' + run: | + export RELEASE_TAG="$(git describe --tags --abbrev=0)" + gh release --repo tldr-pages/tldr-translation-pairs-gen upload --clobber "$RELEASE_TAG" -- *.zip From 5710ffbc3b3286acc9958a355573e5e2fa3bfbf2 Mon Sep 17 00:00:00 2001 From: "K.B.Dharun Krishna" Date: Sun, 3 Mar 2024 19:05:24 +0530 Subject: [PATCH 2/3] fix: seperate deploy and release assets workflows Signed-off-by: K.B.Dharun Krishna --- .github/workflows/translations-release.yml | 66 ++++++++++++++ .github/workflows/translations.yml | 100 +++++++++------------ 2 files changed, 107 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/translations-release.yml diff --git a/.github/workflows/translations-release.yml b/.github/workflows/translations-release.yml new file mode 100644 index 0000000..90d83e9 --- /dev/null +++ b/.github/workflows/translations-release.yml @@ -0,0 +1,66 @@ +name: Generate and publish translations to releases + +on: + push: + tags: + - '*' + schedule: + # This will run at 00:00 UTC on the first day of every month + - cron: '0 0 1 * *' + workflow_dispatch: + +env: + GH_TOKEN: ${{ github.token }} + +permissions: + contents: write # to upload assets to releases + +jobs: + translations: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + - name: Install npm dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Fetch sources + run: | + wget https://github.com/tldr-pages/tldr/archive/refs/heads/main.zip --output-document /tmp/main.zip + unzip /tmp/main.zip -d /tmp + + - name: Generate CSV dataset + run: | + npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset --format csv + zip tldr-translations-dataset.zip tldr-translation-pairs-dataset/* + + - name: Generate TMX dataset + run: | + npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset-tmx --format tmx + zip tldr-translations-dataset-tmx.zip tldr-translation-pairs-dataset-tmx/* + + - name: Generate JSON dataset + run: | + npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset-json --format json + zip tldr-translations-dataset-json.zip tldr-translation-pairs-dataset-json/* + + - name: Generate XML dataset + run: | + npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset-xml --format xml + zip tldr-translations-dataset-xml.zip tldr-translation-pairs-dataset-xml/* + + - name: Deploy to Release + if: github.repository == 'tldr-pages/tldr-translation-pairs-gen' && github.ref == 'refs/heads/main' + run: | + export RELEASE_TAG="$(git describe --tags --abbrev=0)" + gh release --repo tldr-pages/tldr-translation-pairs-gen upload --clobber "$RELEASE_TAG" -- *.zip diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml index e335995..7aaf544 100644 --- a/.github/workflows/translations.yml +++ b/.github/workflows/translations.yml @@ -1,66 +1,48 @@ -name: Generate and publish translations - on: - push: - tags: - - '*' - schedule: - # This will run at 00:00 UTC on the first day of every month - - cron: '0 0 1 * *' workflow_dispatch: - -env: - GH_TOKEN: ${{ github.token }} - -permissions: - contents: write # to upload assets to releases + schedule: + - cron: "0 0 1 * *" jobs: translations: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - - - name: Install npm dependencies - run: npm ci - - - name: Build - run: npm run build - - - name: Fetch sources - run: | - wget https://github.com/tldr-pages/tldr/archive/refs/heads/main.zip --output-document /tmp/main.zip - unzip /tmp/main.zip -d /tmp - - - name: Generate CSV dataset - run: | - npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset --format csv - zip tldr-translations-dataset.zip tldr-translation-pairs-dataset/* - - - name: Generate TMX dataset - run: | - npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset-tmx --format tmx - zip tldr-translations-dataset-tmx.zip tldr-translation-pairs-dataset-tmx/* - - - name: Generate JSON dataset - run: | - npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset-json --format json - zip tldr-translations-dataset-json.zip tldr-translation-pairs-dataset-json/* - - - name: Generate XML dataset - run: | - npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset-xml --format xml - zip tldr-translations-dataset-xml.zip tldr-translation-pairs-dataset-xml/* - - - name: Deploy to Release - if: github.repository == 'tldr-pages/tldr-translation-pairs-gen' && github.ref == 'refs/heads/main' - run: | - export RELEASE_TAG="$(git describe --tags --abbrev=0)" - gh release --repo tldr-pages/tldr-translation-pairs-gen upload --clobber "$RELEASE_TAG" -- *.zip + - name: Checkout code + uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Initialize project + run: | + npm ci + - name: Build + run: | + npm run build + - name: Fetch sources + run: | + wget https://github.com/tldr-pages/tldr/archive/refs/heads/main.zip --output-document /tmp/main.zip + unzip /tmp/main.zip -d /tmp + - name: Execute + run: | + npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output /tmp/datasets + - name: Package artifacts + run: | + mkdir /tmp/dist + tar czf /tmp/dist/tldr-pages-translation-pairs.tar.gz --directory /tmp datasets + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: /tmp/dist + + deploy: + needs: translations + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 From d41dff7fe3a0307e482a8e776bacee5d3149a381 Mon Sep 17 00:00:00 2001 From: "K.B.Dharun Krishna" Date: Sun, 3 Mar 2024 20:45:56 +0530 Subject: [PATCH 3/3] Update .github/workflows/translations-release.yml Co-authored-by: Seth Falco --- .github/workflows/translations-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/translations-release.yml b/.github/workflows/translations-release.yml index 90d83e9..ba845ab 100644 --- a/.github/workflows/translations-release.yml +++ b/.github/workflows/translations-release.yml @@ -41,8 +41,8 @@ jobs: - name: Generate CSV dataset run: | - npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset --format csv - zip tldr-translations-dataset.zip tldr-translation-pairs-dataset/* + npm run tldr-translation-pairs-gen -- --source /tmp/tldr-main --output tldr-translation-pairs-dataset-csv --format csv + zip tldr-translations-dataset-csv.zip tldr-translation-pairs-dataset-csv/* - name: Generate TMX dataset run: |