Skip to content

Commit d11192f

Browse files
authored
internal: add JSR publish flow with deno prod/dev builds (#4616)
1 parent a57c204 commit d11192f

File tree

15 files changed

+268
-58
lines changed

15 files changed

+268
-58
lines changed

.github/workflows/release.yml

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ jobs:
1515
tag: ${{ steps.release_metadata.outputs.tag }}
1616
dist_tag: ${{ steps.release_metadata.outputs.dist_tag }}
1717
prerelease: ${{ steps.release_metadata.outputs.prerelease }}
18-
tarball_name: ${{ steps.release_metadata.outputs.tarball_name }}
1918
concurrency:
2019
group: ${{ github.workflow }}-${{ github.ref_name }}
2120
cancel-in-progress: true
@@ -50,7 +49,6 @@ jobs:
5049
"dist_tag=\(.distTag)",
5150
"prerelease=\(.prerelease)",
5251
"package_spec=\(.packageSpec)",
53-
"tarball_name=\(.tarballName)",
5452
"should_publish=\(.shouldPublish)"
5553
' <<< "${release_metadata_json}" >> "${GITHUB_OUTPUT}"
5654
jq -r '.releaseNotes' <<< "${release_metadata_json}" > ./release-notes.md
@@ -67,16 +65,23 @@ jobs:
6765
if: steps.release_metadata.outputs.should_publish == 'true'
6866
run: npm run build:npm
6967

70-
- name: Pack npmDist package
68+
- name: Upload npmDist package
7169
if: steps.release_metadata.outputs.should_publish == 'true'
72-
run: npm pack ./npmDist --pack-destination . > /dev/null
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: npmDist
73+
path: ./npmDist
74+
75+
- name: Build Deno package
76+
if: steps.release_metadata.outputs.should_publish == 'true'
77+
run: npm run build:deno
7378

74-
- name: Upload npm package tarball
79+
- name: Upload denoDist package
7580
if: steps.release_metadata.outputs.should_publish == 'true'
7681
uses: actions/upload-artifact@v4
7782
with:
78-
name: npmDist-tarball
79-
path: ./${{ steps.release_metadata.outputs.tarball_name }}
83+
name: denoDist
84+
path: ./denoDist
8085

8186
- name: Upload release notes
8287
if: steps.release_metadata.outputs.should_publish == 'true'
@@ -89,7 +94,7 @@ jobs:
8994
name: Publish npm package
9095
needs: check-publish
9196
# Keep this guard on every job for defense-in-depth in case job dependencies are refactored.
92-
if: ${{ !github.event.repository.fork && github.repository == 'graphql/graphql-js' && github.ref_name == '17.x.x' && needs.check-publish.outputs.should_publish == 'true' && needs.check-publish.result == 'success' }}
97+
if: ${{ !github.event.repository.fork && github.repository == 'graphql/graphql-js' && github.ref_name == '17.x.x' && needs.check-publish.outputs.should_publish == 'true' }}
9398
runs-on: ubuntu-latest
9499
environment: release
95100
permissions:
@@ -109,22 +114,54 @@ jobs:
109114
- name: Download npmDist package
110115
uses: actions/download-artifact@v4
111116
with:
112-
name: npmDist-tarball
113-
path: ./artifacts
117+
name: npmDist
118+
path: ./npmDist
114119

115-
- name: Dry-run npm publish
120+
- name: Publish to npm
121+
working-directory: ./npmDist
116122
run: |
117123
if [ -n "${{ needs.check-publish.outputs.dist_tag }}" ]; then
118-
npm publish --provenance --tag "${{ needs.check-publish.outputs.dist_tag }}" "./artifacts/${{ needs.check-publish.outputs.tarball_name }}"
124+
npm publish --provenance --tag "${{ needs.check-publish.outputs.dist_tag }}"
119125
else
120-
npm publish --provenance "./artifacts/${{ needs.check-publish.outputs.tarball_name }}"
126+
npm publish --provenance
121127
fi
122128
129+
publish-jsr:
130+
name: Publish JSR package
131+
needs: check-publish
132+
# Keep this guard on every job for defense-in-depth in case job dependencies are refactored.
133+
if: ${{ !github.event.repository.fork && github.repository == 'graphql/graphql-js' && github.ref_name == '17.x.x' && needs.check-publish.outputs.should_publish == 'true' }}
134+
runs-on: ubuntu-latest
135+
environment: release
136+
permissions:
137+
contents: read # for actions/checkout
138+
id-token: write # for JSR trusted publishing via OIDC
139+
steps:
140+
- name: Checkout repo
141+
uses: actions/checkout@v4
142+
with:
143+
persist-credentials: false
144+
145+
- name: Download denoDist package
146+
uses: actions/download-artifact@v4
147+
with:
148+
name: denoDist
149+
path: ./denoDist
150+
151+
- name: Setup Deno
152+
uses: denoland/setup-deno@v2
153+
with:
154+
deno-version: v2.x
155+
156+
- name: Publish to JSR
157+
working-directory: ./denoDist
158+
run: deno publish
159+
123160
create-release:
124161
name: Create release
125162
needs: check-publish
126163
# Keep this guard on every job for defense-in-depth in case job dependencies are refactored.
127-
if: ${{ !github.event.repository.fork && github.repository == 'graphql/graphql-js' && github.ref_name == '17.x.x' && needs.check-publish.outputs.should_publish == 'true' && needs.check-publish.result == 'success' }}
164+
if: ${{ !github.event.repository.fork && github.repository == 'graphql/graphql-js' && github.ref_name == '17.x.x' && needs.check-publish.outputs.should_publish == 'true' }}
128165
runs-on: ubuntu-latest
129166
environment: release
130167
permissions:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"imports": {
3+
"graphql": "../graphql-deno-dist/__dev__/index.ts",
4+
"graphql/": "../graphql-deno-dist/__dev__/"
5+
}
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"description": "graphql-js development mode should work with Deno with deno build",
3+
"private": true,
4+
"scripts": {
5+
"test": "docker run --rm --volume \"$PWD/..\":/usr/src/app -w /usr/src/app/dev-deno-with-deno-build denoland/deno:alpine-\"$DENO_VERSION\" deno run test.js"
6+
}
7+
}
File renamed without changes.

integrationTests/dev-deno/package.json renamed to integrationTests/dev-deno-with-node-build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"description": "graphql-js development mode should work with Deno",
2+
"description": "graphql-js development mode should work with Deno with node build",
33
"private": true,
44
"scripts": {
55
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app denoland/deno:alpine-\"$DENO_VERSION\" deno run --conditions=development test.js"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { isObjectType } from 'graphql';
2+
3+
class GraphQLObjectType {
4+
get [Symbol.toStringTag]() {
5+
return 'GraphQLObjectType';
6+
}
7+
}
8+
9+
try {
10+
isObjectType(new GraphQLObjectType());
11+
throw new Error(
12+
'Expected isObjectType to throw an error in Deno development mode.',
13+
);
14+
} catch (error) {
15+
if (!error.message.includes('from another module or realm')) {
16+
throw error;
17+
}
18+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"imports": {
3+
"graphql": "../graphql-deno-dist/index.ts",
4+
"graphql/": "../graphql-deno-dist/"
5+
}
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"description": "graphql-js production mode should work with Deno with deno build",
3+
"private": true,
4+
"scripts": {
5+
"test": "docker run --rm --volume \"$PWD/..\":/usr/src/app -w /usr/src/app/prod-deno-with-deno-build denoland/deno:alpine-\"$DENO_VERSION\" deno run test.js"
6+
}
7+
}
File renamed without changes.

integrationTests/prod-deno/package.json renamed to integrationTests/prod-deno-with-node-build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"description": "graphql-js production mode should work with Deno",
2+
"description": "graphql-js production mode should work with Deno with node build",
33
"private": true,
44
"scripts": {
55
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app denoland/deno:alpine-\"$DENO_VERSION\" deno run test.js"

0 commit comments

Comments
 (0)