Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci/GitHub Actions #12

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

name: Build with ${{ matrix.node-version }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v3
with:
version: 8.15.6
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- run: pnpm install --frozen-lockfile
- run: pnpm run build

test:
strategy:
matrix:
node-version: [20.x]

name: Run all tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Retrieve Git history, needed to verify commits
- uses: pnpm/action-setup@v3
with:
version: 8.15.6
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- run: pnpm install --frozen-lockfile

- name: Build Next.js
run: pnpm run build

- if: github.event_name == 'pull_request'
name: Validate all commits from PR
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

- name: Linter
run: pnpm run lint

- name: Type checking
run: pnpm run check-types
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release

on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches:
- main

jobs:
release:
strategy:
matrix:
node-version: [20.x]

name: Create a new release
runs-on: ubuntu-latest

permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pnpm/action-setup@v3
with:
version: 8.15.6
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- run: HUSKY=0 pnpm install --frozen-lockfile

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit $1
7 changes: 7 additions & 0 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { UserConfig } from "@commitlint/types";

const Configuration: UserConfig = {
extends: ["@commitlint/config-conventional"],
};

export default Configuration;
42 changes: 37 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "my-app",
"name": "nextjs-project-template",
"version": "0.1.0",
"private": true,
"scripts": {
Expand All @@ -11,7 +11,8 @@
"lint:strict": "next lint '*/**/*.{js,jsx,ts,tsx}'",
"prettier": "prettier --write */**/*.{js,jsx,json,ts,tsx,scss,css,md}",
"prepare": "husky",
"cm": "cz"
"cm": "cz",
"check-types": "tsc --noEmit --pretty"
},
"dependencies": {
"@radix-ui/react-avatar": "^1.0.4",
Expand Down Expand Up @@ -40,26 +41,57 @@
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@commitlint/cli": "19.2.1",
"@commitlint/config-conventional": "19.1.0",
"@commitlint/cz-commitlint": "19.2.0",
"@commitlint/types": "19.0.3",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1",
"@types/node": "20.12.5",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "~10.4.19",
"commitizen": "4.3.0",
"cz-conventional-changelog": "3.3.0",
"eslint": "9.0.0",
"eslint": "8.57.0",
"eslint-config-next": "14.1.4",
"eslint-config-prettier": "9.1.0",
"husky": "9.0.11",
"lint-staged": "15.2.2",
"postcss": "^8",
"prettier": "3.2.5",
"prettier-plugin-tailwindcss": "0.5.13",
"semantic-release": "23.0.7",
"tailwindcss": "^3.4.3",
"typescript": "~5.4.4"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
"path": "@commitlint/cz-commitlint"
}
}
},
"release": {
"branches": [
"main"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
"@semantic-release/git",
"@semantic-release/github"
]
},
"author": "rikhall1515 (https://github.com/rikhall1515)"
}
Loading
Loading