From b1cdc5a6dadab6fb72ff877fce9b6aa688ea6f63 Mon Sep 17 00:00:00 2001 From: planctus Date: Thu, 31 Oct 2024 11:11:50 +0200 Subject: [PATCH 1/8] chore(sprite): Releasing sprite in the CDN out of the versioned packages --- .github/workflows/production.yml | 9 +++++++++ scripts/dist-presets.sh | 2 ++ src/resources/icons/scripts/build-sprites.js | 6 ++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 83597078fdb..7a77bb54133 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -44,6 +44,15 @@ jobs: aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws_region: ${{ secrets.AWS_DEFAULT_REGION }} flags: --recursive + - name: Deploy to cdn the unversioned files + uses: keithweaver/aws-s3-github-action@v1.0.0 + with: + command: cp + source: ./dist/unversioned + destination: s3://inno-ecl/ecl/unversioned + aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws_region: ${{ secrets.AWS_DEFAULT_REGION }} - name: Install zip uses: montudor/action-zip@v1 - name: Create the package diff --git a/scripts/dist-presets.sh b/scripts/dist-presets.sh index 0b953419060..d9534f5e2bb 100755 --- a/scripts/dist-presets.sh +++ b/scripts/dist-presets.sh @@ -13,6 +13,8 @@ cd .. # Copy builds rm -rf ./dist/packages mkdir -p ./dist/packages +mkdir -p ./dist/unversioned +mv ./src/presets/ec/dist/images/icons/unversioned/* ./dist/unversioned cp -r ./src/presets/ec/dist ./dist/packages/ec cp -r ./src/presets/reset/dist/styles ./dist/packages/ec cp -r ./src/presets/rtl/dist/styles ./dist/packages/ec diff --git a/src/resources/icons/scripts/build-sprites.js b/src/resources/icons/scripts/build-sprites.js index 1e2a66ae274..2cb99990886 100644 --- a/src/resources/icons/scripts/build-sprites.js +++ b/src/resources/icons/scripts/build-sprites.js @@ -4,11 +4,13 @@ const glob = require('glob'); const writeSprite = require('./write-sprite'); const src = path.resolve(__dirname, '../dist/svg'); -const dest = path.resolve(__dirname, '../dist/sprites'); +let dest = path.resolve(__dirname, '../dist/sprites'); const files = glob .sync('**/*.svg', { cwd: src }) .sort((a, b) => a.localeCompare(b, 'en')); /* Generate 1 sprite with all icons and organize icons per folder */ - writeSprite({ files, cwd: src, dest, outputFile: `icons.svg` }); +/* Generate 1 sprite in the unversioned folder */ +dest = path.resolve(__dirname, '../dist/unversioned'); +writeSprite({ files, cwd: src, dest, outputFile: `icons-current.svg` }); From 89c65c9bca9c2751f25c6fc77cb9a9b5fc9275fd Mon Sep 17 00:00:00 2001 From: planctus Date: Thu, 31 Oct 2024 11:29:23 +0200 Subject: [PATCH 2/8] chore(sprite): Fixing ci step --- .github/workflows/production.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 7a77bb54133..30c303e71b2 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -53,6 +53,7 @@ jobs: aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws_region: ${{ secrets.AWS_DEFAULT_REGION }} + flags: --recursive - name: Install zip uses: montudor/action-zip@v1 - name: Create the package From 6181b6829cb4c8b2257ffdcbfe0e44b2d3a9a477 Mon Sep 17 00:00:00 2001 From: planctus Date: Thu, 31 Oct 2024 13:18:37 +0200 Subject: [PATCH 3/8] chore(CI): Setting up logic to only upload file when the release is the latest --- .github/workflows/production.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 30c303e71b2..7c5f172f126 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -44,7 +44,26 @@ jobs: aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws_region: ${{ secrets.AWS_DEFAULT_REGION }} flags: --recursive - - name: Deploy to cdn the unversioned files + - name: Get Latest Release + uses: joutvhu/get-release@v1 + with: + latest: true + pattern: '^v.*' + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Check if this release is the latest + run: | + if [[ "${{ steps.get_latest.outputs.tag }}" == "${{ github.ref }}" ]]; then + echo "This is the latest release. Deploying to CDN." + echo "deploy=true" >> $GITHUB_ENV + else + echo "This is not the latest release. Not uploading the sprite file." + echo "deploy=false" >> $GITHUB_ENV + fi + + - name: Deploy to CDN the unversioned files + if: env.deploy == 'true' uses: keithweaver/aws-s3-github-action@v1.0.0 with: command: cp From e29aae3b8381c768db9c3ccf3bd4bff25df0fca7 Mon Sep 17 00:00:00 2001 From: planctus Date: Thu, 31 Oct 2024 13:22:53 +0200 Subject: [PATCH 4/8] chore(ci): Trying to fix syntax --- .github/workflows/production.yml | 33 ++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 7c5f172f126..39f6a5d3080 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -6,34 +6,47 @@ on: - '!*' tags: - 'v*' + jobs: deploy-release: runs-on: ubuntu-latest name: build and deploy the release + steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: 20.9.0 + - name: Get tag id: tag uses: dawidd6/action-get-tag@v1 + - name: Install dependencies run: yarn install --frozen-lockfile + - name: Build presets run: yarn dist:presets + - name: Generate sri file run: node scripts/sri.js ${{ steps.tag.outputs.tag }} + - name: Browserstats run: npm run browserstats + - name: Build storybook run: PUBLIC_URL=/component-library yarn dist:storybook + - name: Build website run: PUBLIC_URL=/component-library yarn dist:website + - name: Set version run: echo ${{ steps.tag.outputs.tag }} > dist/website/.version + - name: Set commit run: echo ${{ github.sha }} > dist/website/.commit + - name: Deploy to cdn uses: keithweaver/aws-s3-github-action@v1.0.0 with: @@ -44,15 +57,19 @@ jobs: aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws_region: ${{ secrets.AWS_DEFAULT_REGION }} flags: --recursive + - name: Get Latest Release + id: get_latest uses: joutvhu/get-release@v1 with: latest: true pattern: '^v.*' prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Check if this release is the latest + id: check_latest run: | if [[ "${{ steps.get_latest.outputs.tag }}" == "${{ github.ref }}" ]]; then echo "This is the latest release. Deploying to CDN." @@ -73,36 +90,48 @@ jobs: aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws_region: ${{ secrets.AWS_DEFAULT_REGION }} flags: --recursive + - name: Install zip uses: montudor/action-zip@v1 + - name: Create the package run: zip -r -qq europa-component-library-${{ steps.tag.outputs.tag }}.zip . working-directory: dist/website + - name: Create the EC preset package run: zip -r -qq ec-preset-${{ steps.tag.outputs.tag }}.zip . working-directory: dist/packages/ec + - name: Create the EU preset package run: zip -r -qq eu-preset-${{ steps.tag.outputs.tag }}.zip . working-directory: dist/packages/eu + - name: Create the list of packages run: sh ./scripts/packagesList.sh + - name: Deploy packages to github uses: AButler/upload-release-assets@v2.0 with: files: 'dist/website/europa-component-library-*.zip;dist/packages/europa-component-library-*-sri.json;dist/packages/ec/*.zip;dist/packages/eu/*.zip;ECL-npm-packages' repo-token: ${{ secrets.GITHUB_TOKEN }} release-tag: ${{ steps.tag.outputs.tag }} + - name: Build the archive run: PUBLIC_URL=/component-library/${{ steps.tag.outputs.tag }} yarn dist + - name: Set version run: echo ${{ steps.tag.outputs.tag }} > dist/website/.version + - name: Set commit run: echo ${{ github.sha }} > dist/website/.commit + - name: Install zip uses: montudor/action-zip@v1 + - name: Create the package for the archive run: zip -r -qq europa-component-library-${{ steps.tag.outputs.tag }}-archive.zip . working-directory: dist/website + - name: Deploy archive to github uses: AButler/upload-release-assets@v2.0 with: From 346ec4114306ff98f2624c0e74535ff9beee35f4 Mon Sep 17 00:00:00 2001 From: planctus Date: Thu, 31 Oct 2024 13:24:11 +0200 Subject: [PATCH 5/8] chore(ci): changing pattern for release branch --- .github/workflows/production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 39f6a5d3080..e78ed4bd824 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -63,7 +63,7 @@ jobs: uses: joutvhu/get-release@v1 with: latest: true - pattern: '^v.*' + pattern: '^v*' prerelease: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e688458fe265ff095a8a128ce1585b2a012688e6 Mon Sep 17 00:00:00 2001 From: planctus Date: Thu, 31 Oct 2024 14:01:44 +0200 Subject: [PATCH 6/8] chore(ci): Trying in a different way --- .github/workflows/production.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index e78ed4bd824..979e65fcf3d 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -71,7 +71,14 @@ jobs: - name: Check if this release is the latest id: check_latest run: | - if [[ "${{ steps.get_latest.outputs.tag }}" == "${{ github.ref }}" ]]; then + # Get the latest release tag from the get latest release step + LATEST_TAG="${{ steps.get_latest.outputs.tag }}" + CURRENT_TAG="${{ steps.tag.outputs.tag }}" + + echo "Latest Tag: $LATEST_TAG" + echo "Current Tag: $CURRENT_TAG" + + if [[ "$LATEST_TAG" == "$CURRENT_TAG" ]]; then echo "This is the latest release. Deploying to CDN." echo "deploy=true" >> $GITHUB_ENV else From ec918b04d783b3129ab9e9190ed8371f0ab57fdd Mon Sep 17 00:00:00 2001 From: planctus Date: Thu, 31 Oct 2024 14:28:56 +0200 Subject: [PATCH 7/8] chore(ci): tag_name, not tag --- .github/workflows/production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 979e65fcf3d..61cbc2cd990 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -72,7 +72,7 @@ jobs: id: check_latest run: | # Get the latest release tag from the get latest release step - LATEST_TAG="${{ steps.get_latest.outputs.tag }}" + LATEST_TAG="${{ steps.get_latest.outputs.tag_name }}" CURRENT_TAG="${{ steps.tag.outputs.tag }}" echo "Latest Tag: $LATEST_TAG" From d9f1924e77159678fef013361227ec1c05bfd60f Mon Sep 17 00:00:00 2001 From: planctus Date: Thu, 31 Oct 2024 15:17:28 +0200 Subject: [PATCH 8/8] chore(ci): Uploading also list of icons in a json file --- src/resources/icons/scripts/build-lists.js | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/resources/icons/scripts/build-lists.js b/src/resources/icons/scripts/build-lists.js index cfc2bf7d27d..2df65d84b0a 100644 --- a/src/resources/icons/scripts/build-lists.js +++ b/src/resources/icons/scripts/build-lists.js @@ -3,8 +3,8 @@ const glob = require('glob'); const writeList = require('./write-list'); -const src = path.resolve(__dirname, '../src'); -const dest = path.resolve(__dirname, '../dist/lists'); +const src = path.resolve(__dirname, '../src/all'); +let dest = path.resolve(__dirname, '../dist/lists'); const files = glob .sync('**/*.svg', { cwd: src }) @@ -15,19 +15,5 @@ const files = glob writeList({ dest, files, outputFile: 'all.json' }); -/* Write lists of icons per set */ - -const filesBySet = {}; -files.forEach((file) => { - const [set, filename] = file.split('/'); - if (!filesBySet[set]) filesBySet[set] = []; - filesBySet[set].push(filename); -}); - -Object.keys(filesBySet).forEach((set) => { - writeList({ - dest, - files: filesBySet[set], - outputFile: `${set}.json`, - }); -}); +dest = path.resolve(__dirname, '../dist/unversioned'); +writeList({ dest, files, outputFile: 'icons-current.json' });