Skip to content

Commit

Permalink
Publish to JSR (#2)
Browse files Browse the repository at this point in the history
* Added properties to deno.json needed by JSR

* Added workflow to publish to JSR
  • Loading branch information
taras authored Jan 17, 2025
1 parent ed1406d commit d846e33
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 35 deletions.
33 changes: 16 additions & 17 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,64 @@ permissions:
contents: write

jobs:
build:
jsr:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- run: deno publish --token=${{ secrets.JSR_API }}

- run: mkdir bin
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get Version
id: vars
run: echo "version=$(echo $GITHUB_REF_NAME | sed 's/^v//')" >> $GITHUB_OUTPUT
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Write Version file
run: |
touch VERSION
echo ${{steps.vars.outputs.version}} > VERSION
- run: mkdir bin

- name: Compile for Linux arm64
run: |
deno compile \
--target=aarch64-unknown-linux-gnu \
--output=bin/staticalize-linux-arm64 \
--include=VERSION \
--include=deno.json \
--allow-read --allow-write --allow-net --allow-env main.ts
- name: Compile for macOS arm64
run: |
deno compile \
--target=aarch64-apple-darwin \
--output=bin/staticalize-macos-arm64 \
--include=VERSION \
--include=deno.json \
--allow-read --allow-write --allow-net --allow-env main.ts
- name: Compile for Linux x64
run: |
deno compile \
--target=x86_64-unknown-linux-gnu \
--output=bin/staticalize-linux \
--include=VERSION \
--include=deno.json \
--allow-read --allow-write --allow-net --allow-env main.ts
- name: Compile for Windows x64
run: |
deno compile \
--target=x86_64-pc-windows-msvc \
--output=bin/staticalize-windows \
--include=VERSION \
--include=deno.json \
--allow-read --allow-write --allow-net --allow-env main.ts
- name: Compile for macOS x64
run: |
deno compile \
--target=x86_64-apple-darwin \
--output=bin/staticalize-macos \
--include=VERSION \
--include=deno.json \
--allow-read --allow-write --allow-net --allow-env main.ts
- name: Compress binaries
Expand Down
11 changes: 8 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"name": "@frontside/staticalize",
"version": "0.1.0",
"exports": "./mod.ts",
"license": "MIT",
"tasks": {
"dev": "deno run --watch main.ts",
"compile": "deno compile --allow-read --allow-write --allow-env --allow-sys --allow-run --allow-net -o staticalize main.ts"
Expand All @@ -7,9 +11,10 @@
"@std/assert": "jsr:@std/assert@1",
"@std/cli": "jsr:@std/cli@1",
"@std/testing": "jsr:@std/testing@^1.0.0",
"@std/fs": "jsr:@std/fs",
"@libs/xml": "jsr:@libs/xml",
"deno-dom": "jsr:@b-fuze/deno-dom",
"@std/fs": "jsr:@std/fs@1",
"@std/path": "jsr:@std/path@1",
"@libs/xml": "jsr:@libs/xml@^6.0.0",
"deno-dom": "jsr:@b-fuze/[email protected]",
"effection": "npm:[email protected]"
},
"lint": {
Expand Down
16 changes: 4 additions & 12 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { call, main } from "effection";
import { main } from "effection";
import { parser } from "npm:zod-opts";
import { z } from "npm:zod";
import { staticalize } from "./staticalize.ts";
import { join } from "jsr:@std/path";
import denoJson from "./deno.json" with { type: "json" };

const url = () =>
z.string().refine((str) => str.match(/^http/), {
Expand All @@ -15,7 +15,7 @@ await main(function* (args) {
.description(
"Create a static version of a website by traversing a dynamically evaluated sitemap.xml",
)
.version(yield* version())
.version(denoJson.version)
.options({
site: {
alias: "s",
Expand All @@ -41,12 +41,4 @@ await main(function* (args) {
host: new URL(options.site),
dir: options.output,
});
});

function* version() {
try {
return yield* call(() => Deno.readTextFile(join(import.meta.dirname ?? "./", "VERSION")));
} catch {
return "0.0.0"
}
}
});
6 changes: 3 additions & 3 deletions staticalize.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { call, Operation, resource, spawn, useAbortSignal } from "effection";
import { dirname, join, normalize } from "jsr:@std/path";
import { call, type Operation, resource, spawn, useAbortSignal } from "effection";
import { dirname, join, normalize } from "@std/path";
import { ensureDir } from "@std/fs/ensure-dir";
import { stringify } from "@libs/xml/stringify";
import { DOMParser, Element } from "deno-dom";
import { DOMParser, type Element } from "deno-dom";
import { parse } from "@libs/xml/parse";
import { useTaskBuffer } from "./task-buffer.ts";

Expand Down

0 comments on commit d846e33

Please sign in to comment.