Skip to content

Commit

Permalink
configure CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
itsjavi committed Aug 31, 2024
1 parent 78e4f6c commit 9d541cf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 42 deletions.
13 changes: 0 additions & 13 deletions .github/actions/setup-project/action.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
name: "Setup project"
description: "Sets up project with dependencies and credentials"

inputs:
PACKAGE_REGISTRY_TOKEN:
required: true

env:
NODE_VERSION: 22
PNPM_VERSION: 9.9.0

# TODO: Uncomment the following code blocks if we have plan to publish to Github Package Registry instead of NPM.

runs:
using: "composite"
steps:
Expand All @@ -24,7 +18,6 @@ runs:
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
# registry-url: https://npm.pkg.github.com
cache: "pnpm"
cache-dependency-path: "./pnpm-lock.yaml"

Expand All @@ -34,12 +27,6 @@ runs:
path: "**/node_modules"
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}

# - name: "Authenticate with GitHub package registry (publish)"
# shell: bash
# run: echo "//npm.pkg.github.com/:_authToken=${{ inputs.PACKAGE_REGISTRY_TOKEN }}" > ~/.npmrc

- name: "Install project dependencies"
shell: bash
run: pnpm install --frozen-lockfile
# env:
# NODE_AUTH_TOKEN: ${{ inputs.PACKAGE_REGISTRY_TOKEN }}
2 changes: 0 additions & 2 deletions .github/workflows/check-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:

- name: "Setup Project"
uses: ./.github/actions/setup-project
# with:
# PACKAGE_REGISTRY_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}

- name: "Check code quality"
uses: ./.github/actions/check-code-quality
8 changes: 3 additions & 5 deletions .github/workflows/publish-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
Use the following command to install it:
```sh
pnpm i @itsjavi/template-react-component-library@0.0.0-dev-${{ github.sha }}
pnpm i @itsjavi/glassy-ui@0.0.0-dev-${{ github.sha }}
```
jobs:
Expand All @@ -28,19 +28,17 @@ jobs:

- name: "Setup Project"
uses: ./.github/actions/setup-project
# with:
# PACKAGE_REGISTRY_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}

- name: "Check code quality"
uses: ./.github/actions/check-code-quality

# - name: "Authenticate with GitHub package registry (publish)"
# run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.PACKAGE_REGISTRY_TOKEN }}" > ~/.npmrc
# run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc

- name: "Publish tagged component package for selected branch"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm version --no-git-tag-version "${{ env.PACKAGE_VERSION }}"
pnpm publish --no-git-checks --tag "${{ env.PACKAGE_TAG }}"
Expand Down
23 changes: 8 additions & 15 deletions .github/workflows/publish-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ jobs:

- name: "Setup Project"
uses: ./.github/actions/setup-project
# with:
# PACKAGE_REGISTRY_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}

- name: "Check code quality"
uses: ./.github/actions/check-code-quality

# - name: "Authenticate with GitHub package registry (publish)"
# run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.PACKAGE_REGISTRY_TOKEN }}" > ~/.npmrc
# run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc

- name: "Prepare git"
run: |
Expand All @@ -39,19 +37,19 @@ jobs:
git branch -u origin/main main
- name: "Increase build versions"
run: pnpm standard-version --tag-prefix --commit-all
run: pnpm release --tag-prefix --commit-all

- name: "Push new version to git"
run: |
git add .
git push --follow-tags
## Uncomment when we have a package to publish
# - name: "Publish package"
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}
# run: pnpm publish --no-git-checks
# Uncomment when we have a package to publish
- name: "Publish package"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm publish --no-git-checks

publishStorybook:
name: "Publish Storybook to GitHub Pages"
Expand All @@ -62,11 +60,6 @@ jobs:

- name: "Setup Project"
uses: ./.github/actions/setup-project
# with:
# PACKAGE_REGISTRY_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}

# - name: "Authenticate with GitHub package registry (publish)"
# run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.PACKAGE_REGISTRY_TOKEN }}" > ~/.npmrc

- name: "Build storybook"
run: pnpm build:storybook
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/upgrade-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ jobs:

- name: "Setup Project"
uses: ./.github/actions/setup-project
# with:
# PACKAGE_REGISTRY_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}

- name: "Upgrade dependencies"
run: pnpm run upgrade-deps
# env:
# NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}

- name: "Check and fix code style"
run: pnpm lint:fix
Expand Down Expand Up @@ -56,8 +52,6 @@ jobs:

- name: "Setup Project"
uses: ./.github/actions/setup-project
# with:
# PACKAGE_REGISTRY_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}

- name: "Check and fix code style"
run: pnpm lint:fix
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@itsjavi/template-react-component-library",
"name": "@itsjavi/glassy-ui",
"version": "0.1.3",
"private": true,
"license": "MIT",
Expand All @@ -26,6 +26,7 @@
"lint:fix": "sort-package-json && biome check --write .",
"prepare": "sort-package-json",
"prepublishOnly": "pnpm run lint && pnpm run build && publint",
"release": "standard-version",
"storybook": "storybook dev -p 6006",
"test": "echo \"No tests yet\"",
"test:ci": "echo \"No tests yet\"",
Expand Down

0 comments on commit 9d541cf

Please sign in to comment.