Skip to content

Commit

Permalink
Refacto - update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rhannachi committed Jul 25, 2023
1 parent 04944ee commit 6a2335e
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 94 deletions.
114 changes: 47 additions & 67 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,17 @@ jobs:
files: ./coverage/storybook/coverage-storybook.json
verbose: true

################################## DEPLOYMENT ########################################
################################## RELEASE #########################################

deployment:
needs: [test]
name: "Deploy on Chromatic"
release:
needs: [ test ]
name: "Release GitHub"
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
environment:
name: Production
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # 👈 Required to retrieve git history

- uses: pnpm/action-setup@v2
with:
Expand All @@ -234,82 +232,55 @@ jobs:
with:
name: my_node_modules_artifact

- name: unzip node_modules
- name: Unzip node_modules
run: tar -xzf node_modules.tar.gz

- name: Publish to Chromatic
id: chromatic
uses: chromaui/action@v1
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
buildScriptName: build

- name: Publish Summary
run: echo -e "| Results | |\n| --- | --- |\n| Build Results | ${{steps.chromatic.outputs.buildUrl}} |\n| Storybook Preview | ${{steps.chromatic.outputs.storybookUrl}} |\n| Component Count | ${{steps.chromatic.outputs.componentCount}} |" >> $GITHUB_STEP_SUMMARY

################################## Tag Main #########################################

extract-version:
needs: [ test ]
name: "Extract version (package.json)"
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
environment:
name: Production
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 8

- name: Step Node
uses: actions/setup-node@v3
with:
node-version: '16.x'
cache: pnpm

- name: Get version
- name: Get package version
id: get-version
run: |
run: |
version=v$(pnpm pkg get version | tr -d '"')
echo "version=$version" >> $GITHUB_OUTPUT
echo "====> $version"
shell: bash

create-tag:
needs: [ extract-version ]
name: "Create Tag"
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
environment:
name: Production
steps:
- uses: actions/checkout@v3

- uses: rickstaa/action-create-tag@v1
- name: "Create Tag ${{ steps.get-version.outputs.version }}"
uses: rickstaa/action-create-tag@v1
id: create-tag
with:
tag: ${{ needs.extract-version.outputs.version }}
tag: ${{ steps.get-version.outputs.version }}
tag_exists_error: false
message: ${{ needs.extract-version.outputs.version }}
message: ${{ steps.get-version.outputs.version }}
- run: |
echo "Tag already present: ${{ steps.create-tag.outputs.tag_exists }}"
release:
needs: [ create-tag ]
- name: Extract release notes from CHANGELOG.md
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v1
with:
changelog_file: CHANGELOG.md

- name: "Create a GitHub release ${{ steps.get-version.outputs.version }}"
uses: ncipollo/release-action@v1
with:
tag: "${{ steps.get-version.outputs.version }}"
name: "Release ${{ steps.get-version.outputs.version }}"
body: |
## Release notes:
${{ steps.extract-release-notes.outputs.release_notes }}
################################## DEPLOYMENT ########################################

publish:
needs: [release]
name: "Publish to Chromatic and NPM"
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
environment:
name: Production
steps:
- uses: actions/checkout@v3

- name: Prepare repository
run: git fetch --unshallow --tags
with:
fetch-depth: 0 # 👈 Required to retrieve git history

- uses: pnpm/action-setup@v2
with:
Expand All @@ -329,9 +300,18 @@ jobs:
- name: unzip node_modules
run: tar -xzf node_modules.tar.gz

- name: Create Release
- name: Publish to NPM
run: pnpm publish --access=public --no-git-checks
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
pnpm release
NPM_TOKEN: ${{secrets.NPM_TOKEN}}

- name: Publish to Chromatic
id: chromatic
uses: chromaui/action@v1
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
buildScriptName: build

- name: Publish Chromatic Summary
run: echo -e "| Results | |\n| --- | --- |\n| Build Results | ${{steps.chromatic.outputs.buildUrl}} |\n| Storybook Preview | ${{steps.chromatic.outputs.storybookUrl}} |\n| Component Count | ${{steps.chromatic.outputs.componentCount}} |" >> $GITHUB_STEP_SUMMARY
57 changes: 30 additions & 27 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
# v1.1.4 (Sat Jul 23 2023)

- add new colors for `Icon`.

#### Authors: 1

# v1.1.3 (Sat Jul 22 2023)

- Update CI to automatically integrate releases.

#### Authors: 1

# v1.1.2 (Sat Jul 22 2023)

- Update CI to automatically integrate releases.

#### Authors: 1

- Ramzi Hannachi ([@rhannachi](https://github.com/rhannachi))

# v1.1.1 (Sat Jul 22 2023)

- Created first version of the design system, with `Checkbox`, `Icon`, `Task`, `TaskSkeleton`, `TasksBox` and `Tasks` components.

#### Authors: 1

- Ramzi Hannachi ([@rhannachi](https://github.com/rhannachi))
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.4] - 2023-07-25
### Features
* add new colors for `Icon`.
### Contributors to this release
* Ramzi Hannachi ([@rhannachi](https://github.com/rhannachi))

## [1.1.3] - 2023-07-23
### Chores
* Update CI to automatically integrate releases.
### Contributors to this release
* Ramzi Hannachi ([@rhannachi](https://github.com/rhannachi))

## [1.1.2] - 2023-07-23
### Chores
* Update CI to automatically integrate releases.
### Contributors to this release
* Ramzi Hannachi ([@rhannachi](https://github.com/rhannachi))

## [1.1.1] - 2023-07-23
### Features
* Created first version of the design system, with `Checkbox`, `Icon`, `Task`, `TaskSkeleton`, `TasksBox` and `Tasks` components.
### Contributors to this release
* Ramzi Hannachi ([@rhannachi](https://github.com/rhannachi))

0 comments on commit 6a2335e

Please sign in to comment.