From 67ddca5244581f9ed79a209d7c5007da81aac503 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 24 Oct 2024 19:58:57 +0100 Subject: [PATCH 1/3] fix: Android icons output round and sharp --- .../generators/generateAndroidIcons.ts | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/fetch-icons/generators/generateAndroidIcons.ts b/scripts/fetch-icons/generators/generateAndroidIcons.ts index 3f69e421..bb3dee77 100644 --- a/scripts/fetch-icons/generators/generateAndroidIcons.ts +++ b/scripts/fetch-icons/generators/generateAndroidIcons.ts @@ -12,15 +12,22 @@ export const generateAndroidIcons = (outputDir: string, iconManifest: IconManife createFolder(outputDir); for (const icon of iconManifest) { const definition = icon[1]; - const svg = readFileSync(definition.roundPath).toString(); - try { - const file = generateAndroidIcon(svg); - if (file) { - writeFileSync(`${outputDir}/${getAndroidIconFileName(definition.name)}`, file); - } - } catch (e) { - console.error(`Error generating Android icon for ${definition.name}`); + outputAndroidFile(definition.roundPath, "round", definition.name, outputDir); + outputAndroidFile(definition.sharpPath, "sharp", definition.name, outputDir); + } +}; + +const outputAndroidFile = (svg: string, type: string, iconName: string, outputDir: string) => { + const svg2 = readFileSync(svg).toString(); + try { + const file = generateAndroidIcon(svg2); + if (file) { + writeFileSync(`${outputDir}/${getAndroidIconFileName(iconName, type)}`, file); + } else { + throw new Error("Error generating Android icon"); } + } catch (e) { + console.error(`Error generating Android icon for ${type} ${iconName}`, e); } }; @@ -29,7 +36,7 @@ export const generateAndroidIcons = (outputDir: string, iconManifest: IconManife * @param iconName The name of the icon. * @returns The file name for the Android icon. */ -export const getAndroidIconFileName = (iconName: string) => `ic_${toSnakeCase(iconName)}.xml`; +export const getAndroidIconFileName = (iconName: string, type: String) => `ic_${toSnakeCase(iconName)}_${type}.xml`; /** * Creates the contents of an xml file for an Android icon. From b896a379edf921cc1b9bfade9529a6c45f54a333 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 24 Oct 2024 20:00:58 +0100 Subject: [PATCH 2/3] test: Update test util --- test/fetch-icons/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fetch-icons/utils.ts b/test/fetch-icons/utils.ts index 70fdc54c..a42a0505 100644 --- a/test/fetch-icons/utils.ts +++ b/test/fetch-icons/utils.ts @@ -12,7 +12,7 @@ export function checkIconsExist(manifest: IconManifest) { export function checkAndroidIconFilesExist(manifest: IconManifest, outputDir: string) { manifest.forEach((icon) => { - assert.equal(existsSync(`${outputDir}/${getAndroidIconFileName(icon.name)}`), true); + assert.equal(existsSync(`${outputDir}/${getAndroidIconFileName(icon.name, "round")}`), true); }); } From 6b65d16ce5d93b78ff5e9d5e762c8e69d4e8d596 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 24 Oct 2024 20:16:27 +0100 Subject: [PATCH 3/3] test --- .github/workflows/copy-content.yml | 15 ++++----------- .github/workflows/update_zds_android.yml | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/copy-content.yml b/.github/workflows/copy-content.yml index fcaaa81d..5efe2c74 100644 --- a/.github/workflows/copy-content.yml +++ b/.github/workflows/copy-content.yml @@ -54,6 +54,7 @@ jobs: repository: ${{ inputs.repo }} token: ${{ secrets.PAT }} ref: ${{ inputs.branch }} + fetch-depth: 0 - name: Checkout destination repo (Branch doesn't exist) uses: actions/checkout@v4 @@ -62,6 +63,7 @@ jobs: path: "destination" repository: ${{ inputs.repo }} token: ${{ secrets.PAT }} + fetch-depth: 0 - name: Create branch in destination repo if: ${{ steps.check_branch.outputs.branch_exists == 0 }} @@ -82,22 +84,13 @@ jobs: - name: Copy files run: cp -r source/${{ inputs.source_dir }}/* destination/${{ inputs.destination_dir }} - - name: Stage destination changes + - name: Stage / Push destination changes + continue-on-error: true run: | cd destination git config --global user.name "zeta-icons-bot" git config --global user.email "zeta-icons-bot@github.com" git add -A - - - name: Check if there are changes - id: changed - run: | - cd destination - git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT - - - name: Commit and push changes - if: steps.changed.outputs.changed == 'true' - run: | git commit -m "deps(automated): ${{inputs.commit_msg}} ${{ steps.date.outputs.date }}" git push --set-upstream origin ${{inputs.branch}} -f diff --git a/.github/workflows/update_zds_android.yml b/.github/workflows/update_zds_android.yml index ba55f54d..9ce94674 100644 --- a/.github/workflows/update_zds_android.yml +++ b/.github/workflows/update_zds_android.yml @@ -14,7 +14,7 @@ jobs: with: repo: ZebraDevs/zds-android branch: "update-zeta-icons" - source_dir: "./outputs/android/." + source_dir: "outputs/android" destination_dir: "components/src/main/res/drawable" commit_msg: "Update icons" prerun: rm -f components/src/main/res/drawable/ic_*.xml