From 6e1c6c4a653f9a55fc54f2f5f72c14c7d85307f1 Mon Sep 17 00:00:00 2001 From: Jordan Phillips Date: Sat, 13 Apr 2024 16:42:50 +1000 Subject: [PATCH] chore: add action workflows (#7) * chore: add github push workflow * chore: add type-check and test to push workflow * chore: add workflow for pull requests * chore: update push and pull_request_target actions * chore: add release action * chore: rename actions --- .github/actions/build/action.yml | 15 ++++ .github/actions/cache/action.yml | 15 ++++ .github/actions/init/action.yml | 27 +++++++ .github/actions/install/action.yml | 10 +++ .github/actions/lint/action.yml | 10 +++ .github/actions/release/action.yml | 52 +++++++++++++ .github/actions/test/action.yml | 15 ++++ .github/actions/type-check/action.yml | 15 ++++ .github/workflows/main.yml | 101 -------------------------- .github/workflows/pr-title.yml | 11 +-- .github/workflows/pull-request.yml | 48 ++++++++++++ .github/workflows/push.yml | 51 +++++++++++++ .github/workflows/release.yml | 37 ++++++++++ .gitignore | 1 - VERSION.txt | 1 + package.json | 2 +- packages/react/package.json | 2 +- packages/theme/package.json | 2 +- turbo.json | 17 ++--- 19 files changed, 311 insertions(+), 121 deletions(-) create mode 100644 .github/actions/build/action.yml create mode 100644 .github/actions/cache/action.yml create mode 100644 .github/actions/init/action.yml create mode 100644 .github/actions/install/action.yml create mode 100644 .github/actions/lint/action.yml create mode 100644 .github/actions/release/action.yml create mode 100644 .github/actions/test/action.yml create mode 100644 .github/actions/type-check/action.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/pull-request.yml create mode 100644 .github/workflows/push.yml create mode 100644 .github/workflows/release.yml create mode 100644 VERSION.txt diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 0000000..53251bb --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,15 @@ +name: 'πŸ—οΈ ' +author: 'PHILLIPS71' + +inputs: + COMMAND: + default: 'build' + required: true + +runs: + using: 'composite' + steps: + - name: 'πŸ—οΈ Build' + shell: bash + run: | + pnpm run ${{ inputs.COMMAND }} diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml new file mode 100644 index 0000000..0933d2c --- /dev/null +++ b/.github/actions/cache/action.yml @@ -0,0 +1,15 @@ +name: 'πŸ”ΊοΈ ' +author: 'PHILLIPS71' + +runs: + using: 'composite' + steps: + - name: 'πŸ”ΊοΈ Cache (turbo)' + uses: actions/cache@v4 + with: + path: .cache-turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ github.ref_name }}- + turbo-${{ github.job }}- + turbo- diff --git a/.github/actions/init/action.yml b/.github/actions/init/action.yml new file mode 100644 index 0000000..110a827 --- /dev/null +++ b/.github/actions/init/action.yml @@ -0,0 +1,27 @@ +name: 'πŸ’½οΈ ' +author: 'PHILLIPS71' + +inputs: + node-version: + default: '20' + description: 'πŸ”’ Node version' + required: true + pnpm-version: + default: '8' + description: 'πŸ”’ pnpm version' + required: true + +runs: + using: 'composite' + steps: + - name: 'πŸ”§ pnpm' + uses: pnpm/action-setup@v3 + with: + version: ${{ inputs.pnpm-version }} + + - name: 'πŸ’½οΈ Node ${{ inputs.node-version }}' + uses: actions/setup-node@v4 + with: + cache-dependency-path: pnpm-lock.yaml + cache: 'pnpm' + node-version: ${{ inputs.node-version }} diff --git a/.github/actions/install/action.yml b/.github/actions/install/action.yml new file mode 100644 index 0000000..56f6075 --- /dev/null +++ b/.github/actions/install/action.yml @@ -0,0 +1,10 @@ +name: 'πŸ“¦οΈ ' +author: 'PHILLIPS71' + +runs: + using: 'composite' + steps: + - name: 'πŸ“¦οΈ Dependencies' + shell: bash + run: | + pnpm install --frozen-lockfile diff --git a/.github/actions/lint/action.yml b/.github/actions/lint/action.yml new file mode 100644 index 0000000..c6326ea --- /dev/null +++ b/.github/actions/lint/action.yml @@ -0,0 +1,10 @@ +name: '🚨️ ' +author: 'PHILLIPS71' + +runs: + using: 'composite' + steps: + - name: '🚨️ Lint' + shell: bash + run: | + pnpm run lint diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml new file mode 100644 index 0000000..fd087d0 --- /dev/null +++ b/.github/actions/release/action.yml @@ -0,0 +1,52 @@ +name: '🏷️ ' +author: 'PHILLIPS71' + +inputs: + RELEASE_TYPE: + required: true + RELEASE_IDENTIFIER: + required: false + +runs: + using: 'composite' + steps: + - name: '🏷️ Release' + id: version + uses: giantnodes/semver@latest + with: + path: VERSION.txt + type: ${{ inputs.RELEASE_TYPE }} + identifier: ${{ inputs.RELEASE_IDENTIFIER }} + + - name: '🏷️ Version @giantnodes/design-system' + shell: bash + run: | + pnpm version ${{ steps.version.outputs.version }} --no-git-tag-version + + - name: '🏷️ Version @giantnodes/theme' + working-directory: packages/theme + shell: bash + run: | + pnpm version ${{ steps.version.outputs.version }} --no-git-tag-version + + - name: '🏷️ Version @giantnodes/react' + working-directory: packages/react + shell: bash + run: | + pnpm version ${{ steps.version.outputs.version }} --no-git-tag-version + + - name: '🏷️ Tag & Commit Release' + shell: bash + run: | + git checkout -b release/${{ steps.version.outputs.version }} + git commit -m 'chore(release): ${{ steps.version.outputs.version }}' + git tag ${{ steps.version.outputs.version }} + git push origin release/${{ steps.version.outputs.version }} --tags --force + + - name: '🏷️ Open Pull Request' + uses: thomaseizinger/create-pull-request@master + with: + title: 'chore(release): ${{ steps.version.outputs.version }}' + github_token: ${{ secrets.GITHUB_TOKEN }} + head: release/${{ steps.version.outputs.version }} + base: main diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml new file mode 100644 index 0000000..056da5c --- /dev/null +++ b/.github/actions/test/action.yml @@ -0,0 +1,15 @@ +name: 'πŸ§ͺ ' +author: 'PHILLIPS71' + +inputs: + COMMAND: + default: 'test' + required: true + +runs: + using: 'composite' + steps: + - name: 'πŸ§ͺ Test' + shell: bash + run: | + pnpm run ${{ inputs.COMMAND }} diff --git a/.github/actions/type-check/action.yml b/.github/actions/type-check/action.yml new file mode 100644 index 0000000..4f1d255 --- /dev/null +++ b/.github/actions/type-check/action.yml @@ -0,0 +1,15 @@ +name: '🦺 ' +author: 'PHILLIPS71' + +inputs: + COMMAND: + default: 'type-check' + required: true + +runs: + using: 'composite' + steps: + - name: '🦺 Type Check' + shell: bash + run: | + pnpm run ${{ inputs.COMMAND }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index f5cfacc..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,101 +0,0 @@ -name: main - -on: - push: - branches: [main, next] - pull_request: - -jobs: - build: - name: πŸ—οΈ Build - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: setup pnpm - uses: pnpm/action-setup@v3 - - - name: setup node.js - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - cache: 'pnpm' - - - name: install - run: pnpm install - - - name: build - run: pnpm run build - - typescript: - name: 🦺 Type Check - needs: build - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: setup pnpm - uses: pnpm/action-setup@v3 - - - name: setup node.js - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - cache: 'pnpm' - - - name: install - run: pnpm install - - - name: build - run: pnpm build - - - name: type check - run: pnpm run typecheck - - lint: - name: 🚨 Lint - needs: build - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: setup pnpm - uses: pnpm/action-setup@v3 - - - name: setup node.js - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - cache: 'pnpm' - - - name: install - run: pnpm install - - - name: lint - run: pnpm run lint - - test: - name: πŸ§ͺ Test - needs: build - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: setup pnpm - uses: pnpm/action-setup@v3 - - - name: setup node.js - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - cache: 'pnpm' - - - name: install - run: pnpm install - - - name: test - run: pnpm run test diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml index 6c50290..3174f8f 100644 --- a/.github/workflows/pr-title.yml +++ b/.github/workflows/pr-title.yml @@ -1,16 +1,13 @@ -name: pr-title +name: 'πŸ“ PR Title' on: pull_request_target: - types: - - opened - - reopened - - edited - - synchronize + branches: + - main jobs: main: - name: 🏷️ PR Title + name: πŸ“ PR Title runs-on: ubuntu-latest steps: - uses: amannn/action-semantic-pull-request@v5 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..ce242fc --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,48 @@ +name: 'πŸ”€ Pull Request' + +on: + pull_request_target: + branches: + - main + +concurrency: + group: pull-request-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + pull: + name: 'πŸ‘·οΈ CI' + timeout-minutes: 20 + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: 'πŸ™οΈ Checkout' + uses: actions/checkout@v4 + + - name: 'πŸ’½οΈ Init' + uses: ./.github/actions/init + + - name: 'πŸ“¦ Install' + uses: ./.github/actions/install + + - name: 'πŸ”ΊοΈ Cache (turbo)' + uses: ./.github/actions/cache + + - name: 'πŸ—οΈ Build' + uses: ./.github/actions/build + with: + COMMAND: 'build' + + - name: '🚨️ Lint' + uses: ./.github/actions/lint + + - name: '🦺 Type Check' + uses: ./.github/actions/type-check + with: + COMMAND: 'type-check' + + - name: 'πŸ§ͺ Test' + uses: ./.github/actions/test + with: + COMMAND: 'test' diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..99495ea --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,51 @@ +name: '▢️ Push' + +on: + push: + branches: + - main + - chore/** + - feat/** + - fix/** + +concurrency: + group: push-${{ github.ref }} + cancel-in-progress: true + +jobs: + push: + name: 'πŸ‘·οΈ CI' + timeout-minutes: 20 + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: 'πŸ™οΈ Checkout' + uses: actions/checkout@v4 + + - name: 'πŸ’½οΈ Init' + uses: ./.github/actions/init + + - name: 'πŸ“¦ Install' + uses: ./.github/actions/install + + - name: 'πŸ”ΊοΈ Cache (turbo)' + uses: ./.github/actions/cache + + - name: 'πŸ—οΈ Build' + uses: ./.github/actions/build + with: + COMMAND: 'build' + + - name: '🚨️ Lint' + uses: ./.github/actions/lint + + - name: '🦺 Type Check' + uses: ./.github/actions/type-check + with: + COMMAND: 'type-check' + + - name: 'πŸ§ͺ Test' + uses: ./.github/actions/test + with: + COMMAND: 'test' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9b49670 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: '🏷️ Release' + +on: + workflow_dispatch: + inputs: + type: + type: choice + description: 'SemVer Increment' + default: 'prerelease' + required: true + options: + - prerelease + - prepatch + - patch + - preminor + - minor + - premajor + - major + identifier: + type: choice + description: 'Version Prefix' + required: false + options: + - canary + +jobs: + stage: + runs-on: ubuntu-latest + steps: + - name: 'πŸ™οΈ Checkout' + uses: actions/checkout@v4 + + - name: '🏷️ Release' + uses: ./.github/actions/release + with: + RELEASE_TYPE: ${{ github.event.inputs.type }} + RELEASE_IDENTIFIER: ${{ github.event.inputs.identifier }} diff --git a/.gitignore b/.gitignore index a9e33a8..9de1556 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ coverage # next.js .next/ out/ -build dist/ # misc diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..77d6f4c --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +0.0.0 diff --git a/package.json b/package.json index 9841bba..a521332 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "scripts": { "build": "turbo build", "lint": "turbo lint:eslint", - "typecheck": "turbo typecheck", + "type-check": "turbo type-check", "test": "turbo test" }, "devDependencies": { diff --git a/packages/react/package.json b/packages/react/package.json index b693f6b..6eb50ac 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -27,7 +27,7 @@ "sb:build": "pnpm run sb:build:css && storybook build", "-": "", "test": "jest --passWithNoTests", - "typecheck": "tsc --noEmit" + "type-check": "tsc --noEmit" }, "dependencies": { "@giantnodes/theme": "workspace:*", diff --git a/packages/theme/package.json b/packages/theme/package.json index e7e6600..0d3622c 100644 --- a/packages/theme/package.json +++ b/packages/theme/package.json @@ -21,7 +21,7 @@ "lint:fix": "pnpm run lint:eslint --fix && pnpm run lint:prettier --write", "lint": "pnpm run lint:prettier && pnpm run lint:eslint", "-": "", - "typecheck": "tsc --noEmit" + "type-check": "tsc --noEmit" }, "dependencies": { "tailwind-variants": "^0.2.1" diff --git a/turbo.json b/turbo.json index 29a4860..72fbe8b 100644 --- a/turbo.json +++ b/turbo.json @@ -3,19 +3,18 @@ "globalDependencies": ["tsconfig.json"], "pipeline": { "build": { - "dependsOn": ["^build"], - "outputs": [".next/**", "!.next/cache/**", "dist/**"] - }, - "typecheck": { - "cache": false, - "dependsOn": ["^typecheck"] + "outputs": ["dist/**"], + "dependsOn": ["^build"] }, "test": { - "dependsOn": ["build"], - "outputs": [] + "outputs": ["coverage/**"], + "dependsOn": [] + }, + "type-check": { + "dependsOn": ["^build"] }, "lint:eslint": { - "outputs": [] + "dependsOn": ["^lint:eslint"] } } }