Skip to content

Commit 5f3b256

Browse files
authored
feat: setup autorelease workflow (#10)
* delete auto release cos * update version check workflow * readme changes * add yarn, pnpm install instructions * more readme update
1 parent c4c6390 commit 5f3b256

6 files changed

Lines changed: 247 additions & 14 deletions

File tree

.github/workflows/auto-release.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: auto-release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- "**.md"
9+
- "website/**"
10+
- "docs/**"
11+
- ".github/**"
12+
- "!.github/workflows/**"
13+
14+
concurrency:
15+
group: ${{ github.workflow }}
16+
cancel-in-progress: false
17+
18+
jobs:
19+
auto-release:
20+
name: Auto Release
21+
runs-on: ubuntu-latest
22+
if: "!contains(github.event.head_commit.message, 'release:')"
23+
permissions:
24+
contents: write
25+
pull-requests: read
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 22.x
37+
38+
- name: Configure Git
39+
run: |
40+
git config --global user.name "github-actions[bot]"
41+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
42+
43+
- name: Get latest release
44+
id: latest_release
45+
run: |
46+
# Get the latest release tag, fallback to v0.0.0 if none exists
47+
latest_tag=$(git tag --sort=-version:refname | head -n1 || echo "v0.0.0")
48+
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT
49+
echo "Latest release tag: $latest_tag"
50+
51+
- name: Get commits since last release
52+
id: commits
53+
run: |
54+
latest_tag="${{ steps.latest_release.outputs.latest_tag }}"
55+
if [ "$latest_tag" = "v0.0.0" ]; then
56+
# If no previous release, get all commits
57+
commits=$(git log --oneline --pretty=format:"%s" | head -10)
58+
else
59+
# Get commits since last release
60+
commits=$(git log ${latest_tag}..HEAD --oneline --pretty=format:"%s")
61+
fi
62+
63+
echo "Commits since $latest_tag:"
64+
echo "$commits"
65+
66+
# Check if there are any commits to release
67+
if [ -z "$commits" ]; then
68+
echo "No new commits to release"
69+
echo "should_release=false" >> $GITHUB_OUTPUT
70+
exit 0
71+
fi
72+
73+
echo "should_release=true" >> $GITHUB_OUTPUT
74+
75+
- name: Determine version bump type
76+
id: bump_type
77+
if: steps.commits.outputs.should_release == 'true'
78+
run: |
79+
latest_tag="${{ steps.latest_release.outputs.latest_tag }}"
80+
commits=$(git log ${latest_tag}..HEAD --oneline --pretty=format:"%s" || git log --oneline --pretty=format:"%s" | head -10)
81+
82+
# Default to patch
83+
bump_type="patch"
84+
85+
# Check for breaking changes (major)
86+
if echo "$commits" | grep -qE "^[^:]+!:|BREAKING CHANGE"; then
87+
bump_type="major"
88+
# Check for features (minor)
89+
elif echo "$commits" | grep -qE "^feat(\(.+\))?:"; then
90+
bump_type="minor"
91+
# Check for fixes and other changes (patch)
92+
elif echo "$commits" | grep -qE "^(fix|perf|refactor|style|docs|test|build|ci|chore)(\(.+\))?:"; then
93+
bump_type="patch"
94+
fi
95+
96+
echo "Determined bump type: $bump_type"
97+
echo "bump_type=$bump_type" >> $GITHUB_OUTPUT
98+
99+
- name: Bump version
100+
id: version_bump
101+
if: steps.commits.outputs.should_release == 'true'
102+
run: |
103+
bump_type="${{ steps.bump_type.outputs.bump_type }}"
104+
105+
# Get current version from package.json
106+
current_version=$(node -p "require('./package.json').version")
107+
echo "Current version: $current_version"
108+
109+
# Bump version using npm
110+
npm version $bump_type --no-git-tag-version
111+
112+
# Get new version
113+
new_version=$(node -p "require('./package.json').version")
114+
echo "New version: $new_version"
115+
echo "new_version=$new_version" >> $GITHUB_OUTPUT
116+
117+
- name: Commit version bump and create tag
118+
if: steps.commits.outputs.should_release == 'true'
119+
run: |
120+
new_version="${{ steps.version_bump.outputs.new_version }}"
121+
122+
# Commit the version bump
123+
git add package.json
124+
git commit -m "release: $new_version"
125+
126+
# Create and push tag
127+
git tag "v$new_version"
128+
git push origin main
129+
git push origin "v$new_version"
130+
131+
echo "Created and pushed tag v$new_version"
132+
133+
- name: Summary
134+
run: |
135+
if [ "${{ steps.commits.outputs.should_release }}" = "true" ]; then
136+
echo "✅ Auto-release completed!"
137+
echo "New version: ${{ steps.version_bump.outputs.new_version }}"
138+
echo "Tag created: v${{ steps.version_bump.outputs.new_version }}"
139+
echo ""
140+
echo "The check and release workflows will now run automatically."
141+
else
142+
echo "ℹ️ No new commits to release - skipping auto-release"
143+
fi

.github/workflows/check.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ name: check
22

33
on:
44
push:
5-
branches:
6-
- master
75
tags:
86
- v*
97
pull_request:
108
branches:
11-
- master
9+
- main
1210

1311
concurrency:
1412
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -45,7 +43,7 @@ jobs:
4543
uses: pozetroninc/github-action-get-latest-release@master
4644
id: version_v_github
4745
with:
48-
owner: MichalLytek
46+
owner: scope3data
4947
repo: type-graphql
5048
excludes: prerelease, draft
5149

@@ -105,8 +103,6 @@ jobs:
105103
106104
check:
107105
name: Build & Lint & Test
108-
needs: version
109-
if: always() && (needs.version.result == 'success' || needs.version.result == 'skipped')
110106
runs-on: ubuntu-latest
111107
strategy:
112108
fail-fast: true

.github/workflows/release.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,40 @@ concurrency:
1111
group: ${{ github.workflow }}
1212
cancel-in-progress: true
1313

14+
permissions:
15+
pull-requests: write
16+
contents: read
17+
packages: write
18+
1419
jobs:
1520
release:
16-
name: Release package on NPM
21+
name: Release package on GitHub Packages
1722
runs-on: ubuntu-latest
18-
if: github.event.workflow_run.conclusion == 'success' && github.ref_name == 'master' && startsWith(github.event.workflow_run.head_branch, 'v')
23+
if: github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'v')
1924
permissions:
2025
contents: write
2126
id-token: write
27+
packages: write
2228
steps:
2329
- name: Checkout
2430
uses: actions/checkout@v4
2531
with:
2632
ref: ${{ github.event.workflow_run.head_branch }}
2733

34+
- name: Verify version validation passed
35+
env:
36+
TYPE_GRAPHQL_VERSION: ${{ github.event.workflow_run.head_branch }}
37+
run: |
38+
echo "Verifying release for version: $TYPE_GRAPHQL_VERSION"
39+
40+
# Ensure this is a valid version tag format
41+
if ! printf "%s\n" "$TYPE_GRAPHQL_VERSION" | grep -q -P '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(alpha|beta|rc)\.(0|[1-9][0-9]*))?$'; then
42+
printf '[ERROR]: Invalid version tag format (%s)\n' "$TYPE_GRAPHQL_VERSION"
43+
exit 1
44+
fi
45+
46+
echo "✅ Version tag format is valid"
47+
2848
- name: Determine if version is prerelease
2949
id: prerelease
3050
env:
@@ -43,7 +63,7 @@ jobs:
4363
uses: actions/setup-node@v4
4464
with:
4565
node-version: 22.x
46-
registry-url: "https://registry.npmjs.org"
66+
registry-url: "https://npm.pkg.github.com"
4767

4868
- name: Install latest npm
4969
run: |
@@ -77,7 +97,7 @@ jobs:
7797

7898
- name: Publish
7999
env:
80-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
100+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81101
TYPE_GRAPHQL_PRERELEASE: ${{ steps.prerelease.outputs.value }}
82102
run: |
83103
_tag=

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
engine-strict=true
22
@scope3data:registry=https://npm.pkg.github.com
3-
//npm.pkg.github.com/:_authToken=${NPM_TOKEN}
3+
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,80 @@
33
![logo](./images/logo.png)
44
<!-- prettier-ignore-end -->
55

6+
---
7+
8+
## Performance-Optimized Fork by [Scope3](https://scope3.com/home)
9+
10+
> **Context**: This is a high-performance fork maintained by [Scope3](https://github.com/scope3data) with significant optimization improvements. Our changes have been submitted as [PR #1779](https://github.com/MichalLytek/type-graphql/pull/1779) to the original repository but remain unmerged after 6+ months.
11+
12+
### Performance Improvements
13+
14+
#### What’s Different in the Scope3 Fork?
15+
16+
This fork introduces a major refactor of the TypeGraphQL metadata build process, focused on dramatically improving performance for large schemas. It works very well! Scope3 has been running this fork in production for over 6 months, dropping our schema generation time from 4-5 minutes to under 10 seconds in our K8s deployments.
17+
18+
**Problem:**
19+
Schema generation in the upstream project was exponentially slow for large schemas, taking 30+ seconds with 3k-15k metadata objects due to repeated O(n) array `.filter()` lookups.
20+
21+
**Scope3 Solution:**
22+
We replaced all repeated array lookups with O(1) HashMap-based caching.
23+
24+
- Added cache initialization for all major metadata types (object types, fields, params, middlewares, directives, resolver classes, etc.).
25+
- All metadata lookups now use these caches instead of array `.filter()` calls.
26+
- Refactored resolver and field metadata construction to leverage these caches.
27+
28+
**Technical Details:**
29+
30+
- Introduced `Map` caches for object types, fields, params, middlewares, directives, and resolver classes.
31+
- Added an `initCache()` method to populate these caches before schema building.
32+
- All metadata construction logic now uses these caches for instant lookup.
33+
34+
**Performance Impact:**
35+
36+
- Schema generation time reduced from tens of seconds to milliseconds for large schemas.
37+
- Example:
38+
- `buildClassMetadata`: 31.3s → 268ms (116x faster)
39+
- `buildFieldResolverMetadata`: 314ms → 39ms (8x faster)
40+
- `buildResolversMetadata`: 1.4s → 126ms (11x faster)
41+
42+
**Compatibility:**
43+
44+
- The fork remains 100% backward compatible with the original TypeGraphQL API.
45+
- All original TypeGraphQL tests pass with these changes.
46+
- Scope3 has been running this fork in production for over 6 months.
47+
- All recent upstream changes are documentation-only (sponsor updates).
48+
49+
---
50+
51+
If you want more technical details or code samples, see the source or reach out to Scope3!
52+
53+
### Installation
54+
55+
```bash
56+
# Add to .npmrc
57+
@scope3data:registry=https://npm.pkg.github.com
58+
59+
# Install with npm
60+
npm install @scope3data/type-graphql
61+
62+
# Install with Yarn
63+
yarn add @scope3data/type-graphql
64+
65+
# Install with PNPM
66+
pnpm add @scope3data/type-graphql
67+
```
68+
69+
### What's Coming
70+
71+
- Prisma 6 support – Upgrading to the latest Prisma version
72+
- GraphQL 16.11 – Latest GraphQL version with improved performance and features
73+
74+
### Compatibility
75+
76+
100% backward compatible – drop-in replacement for the original `type-graphql` package.
77+
78+
---
79+
680
# TypeGraphQL
781

882
[![release](https://github.com/MichalLytek/type-graphql/actions/workflows/release.yml/badge.svg)](https://github.com/MichalLytek/type-graphql/actions/workflows/release.yml)

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "type-graphql",
2+
"name": "@scope3data/type-graphql",
33
"version": "2.0.0-rc.3",
44
"private": false,
55
"description": "Create GraphQL schema and resolvers with TypeScript, using classes and decorators!",
@@ -15,11 +15,11 @@
1515
],
1616
"homepage": "https://typegraphql.com",
1717
"bugs": {
18-
"url": "https://github.com/MichalLytek/type-graphql/issues"
18+
"url": "https://github.com/scope3data/type-graphql/issues"
1919
},
2020
"repository": {
2121
"type": "git",
22-
"url": "git+https://github.com/MichalLytek/type-graphql.git"
22+
"url": "git+https://github.com/scope3data/type-graphql.git"
2323
},
2424
"funding": [
2525
{

0 commit comments

Comments
 (0)