Skip to content

Commit

Permalink
new build
Browse files Browse the repository at this point in the history
  • Loading branch information
hirsch88 committed Feb 26, 2024
1 parent 2d948e1 commit 30626ee
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 107 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -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 '[email protected]'
git remote set-url origin https://$GITHUB_ACTOR:[email protected]/$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
19 changes: 19 additions & 0 deletions .github/workflows/actions/upload-archive/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
116 changes: 9 additions & 107 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
# 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
92 changes: 92 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ e2e/cypress/snapshots
e2e/cypress/videos

package-lock.json
*.svg
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 30626ee

Please sign in to comment.