Skip to content

Commit

Permalink
Publish to JSR (#939)
Browse files Browse the repository at this point in the history
* Generating jsr.json and publishing from GA

* Appending to deno.json instead

* Don't need jsr.json anymore

* Added missing explicit types and replaced jsr dependencies

* Upgraded deno/dnt

* Fix fomatting
  • Loading branch information
taras authored Dec 20, 2024
1 parent 8fee562 commit f1de695
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 62 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/npm-release.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Publish

on:
push:
tags:
- "effection-v*"

permissions:
contents: read
id-token: write

jobs:
publish-npm:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v4

- name: setup deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Get Version
id: vars
run: echo ::set-output name=version::$(echo ${{github.ref_name}} | sed 's/^effection-v//')

- name: Setup Node
uses: actions/[email protected]
with:
node-version: 18.x
registry-url: https://registry.npmjs.com

- name: Build NPM
run: deno task build:npm ${{steps.vars.outputs.version}}

- name: Publish NPM
run: npm publish --access=public
working-directory: ./build/npm
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}

publish-jsr:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v4

- name: setup deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Get Version
id: vars
run: echo ::set-output name=version::$(echo ${{github.ref_name}} | sed 's/^effection-v//')

- name: Build JSR
run: deno task build:jsr ${{steps.vars.outputs.version}}

- name: Publish JSR
run: npx jsr publish --allow-dirty
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

# Local Netlify folder
.netlify
/build/
/build/
7 changes: 7 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
{
"name": "@effection/effection",
"exports": "./mod.ts",
"license": "ISC",
"publish": {
"include": ["lib", "mod.ts", "README.md"]
},
"lock": false,
"tasks": {
"test": "deno test --allow-run=deno",
"test:node": "deno task build:npm 0.0.0 && node test/main/node.mjs hello world",
"build:jsr": "deno run -A tasks/build-jsr.ts",
"build:npm": "deno run -A tasks/build-npm.ts"
},
"lint": {
Expand Down
4 changes: 2 additions & 2 deletions lib/deps.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { assert } from "https://deno.land/std@0.158.0/testing/asserts.ts";
export * from "https://deno.land/x/[email protected].5/mod.ts";
export { assert } from "jsr:@std/[email protected]";
export * from "jsr:@frontside/[email protected].6";
2 changes: 1 addition & 1 deletion lib/each.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function each<T>(stream: Stream<T, unknown>): Operation<Iterable<T>> {
};
}

each.next = function next() {
each.next = function next(): Operation<void> {
return {
name: "each.next()",
*[Symbol.iterator]() {
Expand Down
2 changes: 1 addition & 1 deletion lib/ensure.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Operation } from "./types.ts";
import type { Operation } from "./types.ts";
import { resource } from "./instructions.ts";

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/lift.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { shift } from "./deps.ts";
import { type Operation } from "./types.ts";
import type { Operation } from "./types.ts";

/**
* Convert a simple function into an {@link Operation}
Expand Down
2 changes: 1 addition & 1 deletion lib/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext } from "./context.ts";
import { type Operation } from "./types.ts";
import type { Operation } from "./types.ts";
import { action } from "./instructions.ts";
import { run } from "./run.ts";
import { call } from "./call.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/run/value.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Computation, reset } from "../deps.ts";
import { type Resolve } from "../types.ts";
import type { Resolve } from "../types.ts";
import { shiftSync } from "../shift-sync.ts";

export function* createValue<T>(): Computation<[Resolve<T>, Computation<T>]> {
Expand Down
3 changes: 2 additions & 1 deletion lib/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Stream, Subscription } from "./types.ts";
import { createQueue, type Queue } from "./queue.ts";
import { resource } from "./instructions.ts";
import { createContext } from "./context.ts";
import type { Context } from "./types.ts";

/**
* Convert plain JavaScript function calls into a {@link Stream} that can
Expand Down Expand Up @@ -81,7 +82,7 @@ export interface Signal<T, TClose> extends Stream<T, TClose> {
* }
* ```
*/
export const SignalQueueFactory = createContext(
export const SignalQueueFactory: Context<typeof createQueue> = createContext(
"Signal.createQueue",
createQueue,
);
Expand Down
9 changes: 9 additions & 0 deletions tasks/build-jsr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import jsonDeno from "../deno.json" with { type: "json" };

await Deno.writeTextFile(
new URL("../deno.json", import.meta.url),
JSON.stringify({
...jsonDeno,
version: Deno.env.get("VERSION"),
}),
);
9 changes: 3 additions & 6 deletions tasks/build-npm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
build,
emptyDir,
} from "https://deno.land/x/[email protected]/mod.ts?pin=v123";
import { build, emptyDir } from "jsr:@deno/[email protected]";

const outDir = "./build/npm";

Expand All @@ -21,7 +18,7 @@ await build({
test: false,
typeCheck: false,
compilerOptions: {
lib: ["esnext", "dom"],
lib: ["ESNext", "DOM"],
target: "ES2020",
sourceMap: true,
},
Expand All @@ -31,8 +28,8 @@ await build({
version,
description: "Structured concurrency and effects for JavaScript",
license: "ISC",
author: "[email protected]",
repository: {
author: "[email protected]",
type: "git",
url: "git+https://github.com/thefrontside/effection.git",
},
Expand Down
9 changes: 8 additions & 1 deletion test/resource.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { describe, expect, it } from "./suite.ts";
import { Operation, resource, run, sleep, spawn, suspend } from "../mod.ts";
import {
type Operation,
resource,
run,
sleep,
spawn,
suspend,
} from "../mod.ts";

type State = { status: string };

Expand Down

0 comments on commit f1de695

Please sign in to comment.