Skip to content

Commit

Permalink
Setup CI/CD (#19)
Browse files Browse the repository at this point in the history
* create CI github action

* add release workflow
  • Loading branch information
gladwindos committed Mar 14, 2024
1 parent 4a77967 commit d783972
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Continuous Integration

on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches: ["main"]

jobs:
ci:
name: Continuous Integration
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"

- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 8

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm lint

- name: Build
run: pnpm build

- name: Test
run: pnpm test
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"

- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 8

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm lint

- name: Build
run: pnpm build

- name: Test
run: pnpm test

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"lint": "turbo lint",
"clean": "turbo clean",
"prepare": "husky",
"purge:node_modules": "rimraf node_modules packages/*/node_modules"
"purge:node_modules": "rimraf node_modules packages/*/node_modules",
"release": "changeset publish"
},
"author": "",
"license": "ISC",
Expand Down

0 comments on commit d783972

Please sign in to comment.