Skip to content

Commit 6508853

Browse files
committed
Various changes to CI and publishing related scripts
1 parent 5ca56f2 commit 6508853

File tree

5 files changed

+48
-29
lines changed

5 files changed

+48
-29
lines changed

.github/workflows/ci.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: CI
22
on:
3+
workflow_dispatch:
4+
workflow_call:
35
push:
46
branches:
57
- main
@@ -28,11 +30,11 @@ jobs:
2830
- name: Run tests
2931
run: deno test --permit-no-files
3032
- name: Generate jsr.json
31-
run: deno run --allow-read=. --allow-run=deno scripts/generate-package-manifest.ts --type=jsr | tee jsr.json
33+
run: deno run --allow-all scripts/generate-package-manifest.ts --type=jsr | tee jsr.json
3234
- name: Dry run publish to JSR
3335
run: deno publish --config=jsr.json --dry-run
3436
- name: Generate package.json
35-
run: deno run --allow-read=. --allow-run=deno scripts/generate-package-manifest.ts --type=npm | tee package.json
37+
run: deno run --allow-all scripts/generate-package-manifest.ts --type=npm | tee package.json
3638
- name: Install dependencies
3739
run: deno install
3840
- name: Build

.github/workflows/publish-jsr.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish to JSR
2+
on:
3+
workflow_dispatch:
4+
release:
5+
types: [published]
6+
jobs:
7+
ci:
8+
uses: ./.github/workflows/ci.yml
9+
publish:
10+
name: Publish to JSR
11+
needs: ci
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
id-token: write
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v4
19+
- name: Set up Deno
20+
uses: denoland/setup-deno@v2
21+
with:
22+
deno-version: v2.x
23+
- name: Generate jsr.json
24+
run: deno run --allow-all scripts/generate-package-manifest.ts --type=jsr | tee jsr.json
25+
- name: Publish to JSR
26+
run: deno publish --config=jsr.json

.github/workflows/publish.yml .github/workflows/publish-npm.yml

+7-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
1-
name: Publish
1+
name: Publish to NPM
22
on:
3+
workflow_dispatch:
34
release:
45
types: [published]
56
jobs:
6-
publish-jsr:
7-
name: Publish to JSR
8-
runs-on: ubuntu-latest
9-
permissions:
10-
contents: read
11-
id-token: write
12-
steps:
13-
- name: Check out repository
14-
uses: actions/checkout@v4
15-
- name: Set up Deno
16-
uses: denoland/setup-deno@v2
17-
with:
18-
deno-version: v2.x
19-
- name: Generate jsr.json
20-
run: deno run --allow-read=. --allow-run=deno scripts/generate-package-manifest.ts --type=jsr | tee jsr.json
21-
- name: Publish to JSR
22-
run: deno publish --config=jsr.json
23-
publish-npm:
7+
ci:
8+
uses: ./.github/workflows/ci.yml
9+
publish:
2410
name: Publish to NPM
11+
needs: ci
2512
runs-on: ubuntu-latest
2613
permissions:
2714
contents: read
@@ -39,7 +26,7 @@ jobs:
3926
node-version: '22.x'
4027
registry-url: 'https://registry.npmjs.org'
4128
- name: Generate package.json
42-
run: deno run --allow-read=. --allow-run=deno scripts/generate-package-manifest.ts --type=npm | tee package.json
29+
run: deno run --allow-all scripts/generate-package-manifest.ts --type=npm | tee package.json
4330
- name: Install dependencies
4431
run: deno install
4532
- name: Build

deno.json

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
"version": "0.1.8",
44
"description": "A library for working with arbitrary precision decimal numbers",
55
"license": "MIT",
6+
"author": "Quentin Adam",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/quentinadam/deno-decimal.git"
10+
},
611
"exports": "./src/Decimal.ts",
712
"imports": {
813
"@quentinadam/assert": "jsr:@quentinadam/assert@^0.1.10",

scripts/generate-package-manifest.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ type ConfigurationFile = {
9191
version: string;
9292
description: string;
9393
license: string;
94+
author?: string;
95+
repository?: unknown;
9496
exports?: string | Record<string, string>;
9597
imports?: Record<string, string>;
9698
};
@@ -107,13 +109,10 @@ const configurationFile: ConfigurationFile = JSON.parse(Deno.readTextFileSync('d
107109

108110
const dependencies = await getExportsDependencies();
109111

110-
const scopedName = require(configurationFile.name);
111-
const name = require(scopedName.split('/')[1]);
112-
113112
const manifest = (() => {
114113
if (type === 'jsr') {
115114
return {
116-
name: scopedName,
115+
name: require(configurationFile.name),
117116
version: require(configurationFile.version),
118117
license: require(configurationFile.license),
119118
exports: require(configurationFile.exports),
@@ -127,12 +126,12 @@ const manifest = (() => {
127126
}
128127
if (type === 'npm') {
129128
return {
130-
name: scopedName,
129+
name: require(configurationFile.name),
131130
version: require(configurationFile.version),
132131
description: require(configurationFile.description),
133132
license: require(configurationFile.license),
134-
author: 'Quentin Adam',
135-
repository: { type: 'git', url: `git+https://github.com/quentinadam/deno-${name}.git` },
133+
author: configurationFile.author,
134+
repository: configurationFile.repository,
136135
type: 'module',
137136
exports: ((exports) => {
138137
const replaceFn = (path: string) => path.replace(/^\.\/src\//, './dist/').replace(/\.ts$/, '.js');

0 commit comments

Comments
 (0)