diff --git a/.github/workflows/actions/build/action.yml b/.github/workflows/actions/build/action.yml new file mode 100644 index 00000000..82d10489 --- /dev/null +++ b/.github/workflows/actions/build/action.yml @@ -0,0 +1,61 @@ +name: '👷 Build Design System' +inputs: + build: + description: 'Build packages' + default: true +runs: + using: 'composite' + steps: + - name: Checkout project + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Git Identity + run: | + git config --global user.name 'baopso' + git config --global user.email 'Group.CH_Open-Source@baloise.ch' + git remote set-url origin https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Stetup Node.JS + uses: actions/setup-node@v3 + with: + node-version: 20 + cache: 'npm' + + - name: Update NPM registry path + run: npm run registry + + - name: Clean install + run: npm ci + + - name: Define Nx cache + uses: nrwl/nx-set-shas@v4 + + - name: Check format + run: npx nx format:check + + - name: Check spelling + run: npm run spell + + - name: Lint & Test + if: inputs.build == 'false' + run: npx nx run-many -t lint test + + - name: Lint & Test & Build + if: inputs.build == 'true' + run: npx nx run-many -t lint test build + + - name: Releae dry-run + if: inputs.build == 'true' + run: npx nx release publish -d + + - name: Upload E2E artifacts + if: inputs.build == 'true' + uses: ./.github/workflows/actions/upload-archive + with: + name: test-e2e + output: test/TestE2eBuild.zip + paths: test/generated diff --git a/.github/workflows/actions/upload-archive/action.yml b/.github/workflows/actions/upload-archive/action.yml new file mode 100644 index 00000000..fdf335ff --- /dev/null +++ b/.github/workflows/actions/upload-archive/action.yml @@ -0,0 +1,19 @@ +name: 'Archive Upload' +description: 'Compresses and uploads an archive to be reused across jobs' +inputs: + paths: + description: 'Paths to files or directories to archive' + output: + description: 'Output file name' + name: + description: 'Archive name' +runs: + using: 'composite' + steps: + - name: Create Archive + run: zip -q -r ${{ inputs.output }} ${{ inputs.paths }} + shell: bash + - uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.name }} + path: ${{ inputs.output }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 915972e0..dc1eac97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,121 +6,23 @@ on: - main - changeset-release/main pull_request: + branches: ['**'] + types: [opened, synchronize, reopened] + merge_group: + workflow_dispatch: concurrency: group: ${{ github.ref }} cancel-in-progress: true jobs: - main: - name: 👷 CI + build: + name: 👷 Build Design System runs-on: ubuntu-latest env: HUSKY: 0 steps: - - name: Checkout project - uses: actions/checkout@v4 + - name: 👷 Build Design System + uses: ./.github/workflows/actions/build with: - fetch-depth: 0 - - - name: Stetup Node.JS - uses: actions/setup-node@v3 - with: - node-version: 20 - cache: 'npm' - - - name: Update NPM registry path - run: npm run registry - - - name: Clean install - run: npm ci - - - name: Define Nx cache - uses: nrwl/nx-set-shas@v4 - - # - name: Prepare build - # run: npx nx run-many -t prepare - - - name: Check format - run: npx nx format:check - - - name: Check spelling - run: npm run spell - - - name: Lint & test - run: npx nx run-many -t lint test - # run: npx nx affected -t lint test - - - name: Changeset - if: github.ref == 'refs/heads/main' - id: changesets - uses: changesets/action@v1 - with: - publish: npx nx run-many -t build - env: - HUSKY_DISABLED: 1 - BAL_DS_RELEASE: true - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - - - name: Changeset outputs - shell: bash - run: | - echo "Changeset published - ${{ steps.changesets.outputs.published }}" - echo "Changeset publishedPackages - ${{ steps.changesets.outputs.publishedPackages }}" - echo "Changeset hasChangesets - ${{ steps.changesets.outputs.hasChangesets }}" - echo "Changeset pullRequestNumber - ${{ steps.changesets.outputs.pullRequestNumber }}" - - - name: Build - if: steps.changesets.outputs.published == 'false' - run: npx nx run-many -t build - # run: npx nx affected -t build - - - name: Releae dry-run - if: github.ref == 'refs/heads/main' && steps.changesets.outputs.hasChangesets == 'true' && steps.changesets.outputs.published == 'false' - run: npx nx release publish -d - - # - name: Update lock file - # if: steps.changesets.outputs.published == 'true' - # run: npm install - # shell: bash - - # - name: Commit lock file - # if: steps.changesets.outputs.published == 'true' - # uses: EndBug/add-and-commit@v9 - # with: - # add: 'package-lock.json' - # message: 'chore(): update lock file' - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # - name: Tag release - # if: steps.changesets.outputs.published == 'true' - # uses: thejeff77/action-push-tag@v1.0.0 - # with: - # tag: 'v${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }}' - # message: 'v${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }}' - - # - name: Update changelog file - # if: steps.changesets.outputs.published == 'true' - # run: awk 'NR==1 {print "# Changelog"} NR!=1' packages/tokens/CHANGELOG.md > CHANGELOG.md - # shell: bash - - # - name: Commit changelog - # if: steps.changesets.outputs.published == 'true' - # uses: EndBug/add-and-commit@v9 - # with: - # add: 'CHANGELOG.md' - # message: 'chore(): update changelog' - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # - name: Merge main -> production - # if: steps.changesets.outputs.published == 'true' - # uses: devmasx/merge-branch@master - # with: - # type: now - # from_branch: main - # target_branch: production - # message: ':bookmark: release: ${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }}' - # github_token: ${{ secrets.GITHUB_TOKEN }} + build: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..03159109 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,92 @@ +name: Release + +on: + push: + branches: + - main + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + Release: + name: 🚀 Release + runs-on: ubuntu-latest + timeout-minutes: 15 + env: + HUSKY: 0 + steps: + - name: 👷 Build Design System + uses: ./.github/workflows/actions/build + with: + build: false + + - uses: ./.github/workflows/actions/setup-release + with: + token: ${{ secrets.GITHUB_TOKEN }} + npm-token: ${{ secrets.NPM_TOKEN }} + + - name: Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + publish: npm run release + env: + HUSKY_DISABLED: 1 + BAL_DS_RELEASE: true + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + + - name: Echo Changeset output + shell: bash + run: | + echo "Changeset published - ${{ steps.changesets.outputs.published }}" + echo "Changeset publishedPackages - ${{ steps.changesets.outputs.publishedPackages }}" + echo "Changeset hasChangesets - ${{ steps.changesets.outputs.hasChangesets }}" + echo "Changeset pullRequestNumber - ${{ steps.changesets.outputs.pullRequestNumber }}" + + - name: Update lock file + if: steps.changesets.outputs.published == 'true' + run: npm install + shell: bash + + - name: Commit lock file + if: steps.changesets.outputs.published == 'true' + uses: EndBug/add-and-commit@v9 + with: + add: 'package-lock.json' + message: 'chore(): update lock file' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Tag release + if: steps.changesets.outputs.published == 'true' + uses: thejeff77/action-push-tag@v1.0.0 + with: + tag: 'v${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }}' + message: 'v${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }}' + + - name: Update changelog file + if: steps.changesets.outputs.published == 'true' + run: awk 'NR==1 {print "# Changelog"} NR!=1' packages/components/CHANGELOG.md > CHANGELOG.md + shell: bash + + - name: Commit changelog + if: steps.changesets.outputs.published == 'true' + uses: EndBug/add-and-commit@v9 + with: + add: 'CHANGELOG.md' + message: 'chore(): update changelog' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Merge main -> production + if: steps.changesets.outputs.published == 'true' + uses: devmasx/merge-branch@master + with: + type: now + from_branch: main + target_branch: production + message: ':bookmark: release: ${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }}' + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.prettierignore b/.prettierignore index 58a87aeb..2a1c16f8 100644 --- a/.prettierignore +++ b/.prettierignore @@ -23,3 +23,4 @@ e2e/cypress/snapshots e2e/cypress/videos package-lock.json +*.svg diff --git a/README.md b/README.md index 4ddfe4bc..66ff92da 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,9 @@ Check out the [documentation](https://design.baloise.dev) | [Maps](https://design.baloise.dev) | ![npm](https://img.shields.io/npm/v/@baloise/design-system-maps) | Google Maps styles and icons. | | [Fonts](https://design.baloise.dev) | ![npm](https://img.shields.io/npm/v/@baloise/design-system-fonts) | Web-Font of the design system. | | [Testing](https://design.baloise.dev) | ![npm](https://img.shields.io/npm/v/@baloise/design-system-testing) | Testing package with custom and overridden commands for each component. | + +CI PR +Release +Snapshot +Nightly +Visual Base