Skip to content

Commit

Permalink
ci: check & release
Browse files Browse the repository at this point in the history
  • Loading branch information
unnoq committed Nov 18, 2024
1 parent 4221205 commit b38be7f
Show file tree
Hide file tree
Showing 17 changed files with 836 additions and 23 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.3/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "unnoq/orpc" }],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["@orpc/content"]
}
89 changes: 89 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Main

on:
push:
branches: [main]

jobs:
check-code:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- run: pnpm i

- run: pnpm run lint:check

- run: pnpm run type:check

- run: pnpm run test

- run: pnpm run build

stable-release:
needs: [check-code]

if: ${{ needs.check-code.result == 'success' }}

runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

outputs:
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- name: NPM registry authentication
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- run: pnpm i

- name: Changesets version or deploy and publish on @latest
id: changesets
uses: changesets/action@v1
with:
commit: 'chore(release): version packages'
title: 'chore(release): version packages'
publish: pnpm run release:next
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

next-release:
needs: [stable-release]

if: ${{ needs.stable-release.result == 'success' && needs.stable-release.outputs.hasChangesets == 'true' }}

runs-on: ubuntu-latest

permissions:
contents: read

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- name: NPM registry authentication
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- run: pnpm i

- run: pnpm changeset version --snapshot next
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish
run: pnpm run release:next
30 changes: 30 additions & 0 deletions .github/workflows/pr-quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: pr-quality

on:
pull_request:
branches: [main]

jobs:
check-and-fix-code:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- run: pnpm i

- run: pnpm run lint:fix

- run: pnpm run type:check

- run: pnpm run test

- run: pnpm run build

- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'style: lint & format fixed'
121 changes: 121 additions & 0 deletions .github/workflows/pr-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: pr-release

on:
pull_request:
branches: [main]

jobs:
release:
runs-on: ubuntu-latest

permissions:
contents: read
pull-requests: write

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- name: NPM registry authentication
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- run: pnpm i

- name: Context vars
id: vars
run: |
echo "short_sha=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})" >> $GITHUB_OUTPUT
- name: Find pr-release comment
uses: peter-evans/find-comment@v3
id: pr-fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!--pr-release-->'

- name: Create or update pr-release comment with in process status
uses: peter-evans/create-or-update-comment@v4
id: pr-couc
with:
comment-id: ${{ steps.pr-fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!--pr-release-->
## PR-release for testing
Latest commit: `${{ steps.vars.outputs.short_sha }}`
Status: 👷 In process...
[View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
edit-mode: replace

- name: Publish packages
id: publish
continue-on-error: true
run: |
pnpm changeset version --snapshot unsafe-pr-${{ github.event.pull_request.number }}
pnpm run release:unsafe-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update pr-release comment with failed status
if: steps.publish.outcome != 'success'
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.pr-couc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!--pr-release-->
## PR-release for testing
Latest commit: `${{ steps.vars.outputs.short_sha }}`
Status: ❌ Failed
[View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
edit-mode: replace

- name: Get @dinui/react version
if: steps.publish.outcome == 'success'
uses: martinbeentjes/npm-get-version-action@v1.3.1
id: dinui-react-version
with:
path: packages/react-ui

- name: Get @dinui/cli version
if: steps.publish.outcome == 'success'
uses: martinbeentjes/npm-get-version-action@v1.3.1
id: dinui-cli-version
with:
path: packages/cli

- name: Update pr-release comment with published status
if: steps.publish.outcome == 'success'
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.pr-couc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!--pr-release-->
## PR-release for testing
Latest commit: `${{ steps.vars.outputs.short_sha }}`
Status: ✅ Published
```bash
npm install @orpc/server@${{ steps.dinui-react-version.outputs.current-version}}
npm install @orpc/contract@${{ steps.dinui-react-version.outputs.current-version}}
npm install @orpc/client@${{ steps.dinui-react-version.outputs.current-version}}
npm install @orpc/react@${{ steps.dinui-react-version.outputs.current-version}}
npm install @orpc/openapi@${{ steps.dinui-react-version.outputs.current-version}}
```
[View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }})
edit-mode: replace

- name: Exit with failed status
if: steps.publish.outcome != 'success'
run: exit 1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
!.npmrc
!.*.example
!.vscode/
!.changeset/
!.github/

# Common generated folders
logs/
Expand Down
2 changes: 1 addition & 1 deletion apps/content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "next dev",
"start": "next start",
"postinstall": "fumadocs-mdx",
"check": "tsc -b && pnpm run build"
"type:check": "tsc -b && pnpm run build"
},
"dependencies": {
"fumadocs-core": "14.4.0",
Expand Down
21 changes: 13 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,30 @@
},
"scripts": {
"build": "pnpm run -r build",
"build:packages": "pnpm --filter=\"./packages/*\" run -r build",
"preview": "pnpm run --parallel preview",
"check": "pnpm run -r check && tsc -b",
"type:check": "pnpm run -r type:check && tsc -b",
"test": "vitest run",
"test:watch": "vitest watch",
"test:coverage": "vitest run --coverage",
"test:ui": "vitest --coverage --ui",
"lint": "pnpm biome check --error-on-warnings",
"lint:fix": "pnpm biome check --error-on-warnings --write",
"sherif": "pnpm dlx sherif",
"sherif:fix": "pnpm run sherif --fix",
"knip": "pnpm dlx knip --production",
"knip:fix": "pnpm run knip --production --fix --allow-remove-files"
"lint:check": "pnpm biome check --error-on-warnings",
"lint:fix": "pnpm run lint:check --write",
"sherif:check": "pnpm dlx sherif",
"sherif:fix": "pnpm run sherif:check --fix",
"knip:check": "pnpm dlx knip --production",
"knip:fix": "pnpm run knip:check --fix --allow-remove-files",
"release:stable": "pnpm run build:packages && pnpm changeset publish",
"release:next": "pnpm run release:stable --tag next",
"release:unsafe-pr": "pnpm run release:stable --tag unsafe-pr"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@unnoq/unplugin": "^0.0.0",
"@changesets/cli": "^2.27.9",
"@testing-library/jest-dom": "^6.6.2",
"@testing-library/react": "^16.0.1",
"@types/node": "^22.9.0",
"@unnoq/unplugin": "^0.0.0",
"@vitest/coverage-v8": "^2.1.1",
"@vitest/ui": "^2.1.1",
"jsdom": "^25.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"files": ["dist", "src"],
"scripts": {
"build": "UNPLUGIN_ON_SUCCESS='tsc -b --noCheck' vite build",
"check": "tsc -b"
"type:check": "tsc -b"
},
"devDependencies": {
"zod": "^3.23.8"
Expand Down
2 changes: 1 addition & 1 deletion packages/contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"files": ["dist", "src"],
"scripts": {
"build": "tsup --entry.index=src/index.ts --clean --sourcemap --splitting --format=esm --onSuccess='tsc -b --noCheck'",
"check": "tsc -b"
"type:check": "tsc -b"
},
"dependencies": {
"@orpc/shared": "workspace:*"
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"files": ["dist", "src"],
"scripts": {
"build": "tsup --entry.index=src/index.ts --clean --sourcemap --splitting --format=esm --onSuccess='tsc -b --noCheck'",
"check": "tsc -b"
"type:check": "tsc -b"
},
"devDependencies": {
"@readme/openapi-parser": "^2.6.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"files": ["dist", "src"],
"scripts": {
"build": "UNPLUGIN_ON_SUCCESS='tsc -b --noCheck' vite build",
"check": "tsc -b"
"type:check": "tsc -b"
},
"dependencies": {
"@orpc/client": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"files": ["dist", "src"],
"scripts": {
"build": "tsup --entry.index=src/index.ts --entry.fetch=src/adapters/fetch.ts --clean --sourcemap --splitting --format=esm --onSuccess='tsc -b --noCheck'",
"check": "tsc -b"
"type:check": "tsc -b"
},
"dependencies": {
"@orpc/contract": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"files": ["dist", "src"],
"scripts": {
"build": "UNPLUGIN_ON_SUCCESS='tsc -b --noCheck' vite build",
"check": "tsc -b"
"type:check": "tsc -b"
},
"dependencies": {
"is-what": "^5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/transformer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"files": ["dist", "src"],
"scripts": {
"build": "UNPLUGIN_ON_SUCCESS='tsc -b --noCheck' vite build",
"check": "tsc -b"
"type:check": "tsc -b"
},
"dependencies": {
"@orpc/shared": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"files": ["dist", "src"],
"scripts": {
"build": "UNPLUGIN_ON_SUCCESS='tsc -b --noCheck' vite build",
"check": "tsc -b"
"type:check": "tsc -b"
},
"dependencies": {
"json-schema-typed": "^8.0.1",
Expand Down
Loading

0 comments on commit b38be7f

Please sign in to comment.