Skip to content

Commit

Permalink
chore(ci): added new workflows (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
DuCanhGH authored Jun 13, 2023
1 parent 043e780 commit 63c1998
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 44 deletions.
5 changes: 4 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.2.0/schema.json",
"changelog": "@changesets/cli/changelog",
"changelog": [
"@changesets/changelog-github",
{ "repo": "DuCanhGH/next-pwa" }
],
"commit": false,
"fixed": [],
"linked": [],
Expand Down
2 changes: 2 additions & 0 deletions .changeset/sour-laws-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
18 changes: 18 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build and test
on: [workflow_call]
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_REMOTE_ONLY: true
jobs:
# TODO: add tests
build_and_test:
name: 🔎 Typecheck, check formatting and lint
uses: ./.github/workflows/build-reusable.yml
with:
afterBuild: |
pnpm typecheck &&
pnpm format:check &&
pnpm lint &&
pnpm docs:lint
secrets: inherit
53 changes: 53 additions & 0 deletions .github/workflows/build-reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build reusable
on:
workflow_call:
inputs:
skipInstallBuild:
required: false
description: "whether to skip pnpm install && pnpm build"
type: string
nodeVersion:
required: false
description: "version of Node.js to use"
type: string
pnpmVersion:
required: false
description: "version of pnpm to use"
type: string
afterBuild:
required: false
description: "additional steps to run"
type: string
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_REMOTE_ONLY: true
jobs:
build:
name: ⬣, 🔎, 🔨 Typecheck, lint, and build on Node ${{ matrix.node-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: ${{ fromJson(inputs.nodeVersion || '["18.x"]') }}
pnpm-version: ${{ fromJson(inputs.pnpmVersion || '["8.x"]') }}
os: [ubuntu-latest]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Use pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ matrix.pnpm-version }}
- name: Use Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install
if: ${{ inputs.skipInstallBuild != 'yes' }}
- name: Build
run: pnpm build
if: ${{ inputs.skipInstallBuild != 'yes' }}
- name: Run after build
run: /bin/bash -c "${{ inputs.afterBuild }}"
1 change: 0 additions & 1 deletion .github/workflows/close-stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
close-issues:
runs-on: ubuntu-latest
Expand Down
57 changes: 15 additions & 42 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,31 @@
name: Test & Publish package to npm
on: [push]
name: Publish packages to npm
on:
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_REMOTE_ONLY: true
jobs:
typecheck_lint_build:
name: ⬣, 🔎, 🔨 Typecheck, lint, and build on Node ${{ matrix.node-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_REMOTE_ONLY: true
strategy:
matrix:
node-version: ["18.x"]
pnpm-version: ["8.x"]
os: [ubuntu-latest]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Use pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ matrix.pnpm-version }}
- name: Use Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Typecheck
run: pnpm typecheck
- name: Lint
run: pnpm lint
test:
name: ⬣, 🔎, 🔨 Test before releasing
uses: ./.github/workflows/build-and-test.yml
publish:
name: 🚀 Release packages
needs: [typecheck_lint_build]
runs-on: ${{ matrix.os }}
needs: [test]
runs-on: [ubuntu-latest]
permissions:
contents: write
id-token: write
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_REMOTE_ONLY: true
strategy:
matrix:
node-version: ["18.x"]
pnpm-version: ["8.x"]
os: [ubuntu-latest]
if: ${{ github.ref == 'refs/heads/master' && (contains(github.event.head_commit.message, '[bump]') || contains(github.event.head_commit.message, 'RELEASING')) }}
if: ${{ contains(github.event.head_commit.message, '[bump]') || github.event.head_commit.message == 'Publish packages' }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/pull-request-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Check a pull request
on:
pull_request:
types: [opened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_REMOTE_ONLY: true
jobs:
ensure_changelog_exists:
name: 🔎 Ensure that .changeset is not empty
runs-on: [ubuntu-latest]
strategy:
matrix:
node-version: ["18.x"]
pnpm-version: ["8.x"]
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Use Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install changeset CLI
run: npm i -g @changesets/cli@$(node -p "require('./package.json').devDependencies['@changesets/cli']")
- name: Ensure that a changelog is added
run: npx changeset status --since=origin/master
test:
name: ⬣, 🔎, 🔨 Test PR
uses: ./.github/workflows/build-and-test.yml
secrets: inherit
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"examples:dev": "cross-env FORCE_COLOR=1 turbo run dev --parallel --filter=./examples/*",
"examples:lint": "cross-env FORCE_COLOR=1 turbo run lint --parallel --filter=./examples/*",
"format": "prettier --write .",
"format:check": "prettier --check .",
"lint": "cross-env FORCE_COLOR=1 turbo run lint --parallel --filter=./packages/*",
"lint-staged": "lint-staged",
"new-changeset": "changeset",
Expand All @@ -27,6 +28,7 @@
"typecheck": "cross-env FORCE_COLOR=1 turbo run typecheck"
},
"devDependencies": {
"@changesets/changelog-github": "0.4.8",
"@changesets/cli": "2.26.1",
"@ducanh2912/next-pwa": "workspace:*",
"@ducanh2912/next-sw": "workspace:*",
Expand Down
58 changes: 58 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 63c1998

Please sign in to comment.