Skip to content

Commit

Permalink
Include version with binary
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Jan 16, 2025
1 parent e1462ef commit 7e69dba
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,54 @@ jobs:

- run: mkdir bin

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

- name: Write Version file
run: |
touch VERSION
echo ${{steps.vars.outputs.version}} > VERSION
- name: Compile for Linux arm64
run: |
deno compile \
--target=aarch64-unknown-linux-gnu \
--output=bin/staticalize-linux-arm64 \
--include=VERSION \
--allow-read --allow-write --allow-net main.ts
- name: Compile for macOS arm64
run: |
deno compile \
--target=aarch64-apple-darwin \
--output=bin/staticalize-macos-arm64 \
--include=VERSION \
--allow-read --allow-write --allow-net main.ts
- name: Compile for Linux x64
run: |
deno compile \
--target=x86_64-unknown-linux-gnu \
--output=bin/staticalize-linux \
--include=VERSION \
--allow-read --allow-write --allow-net main.ts
- name: Compile for Windows x64
run: |
deno compile \
--target=x86_64-pc-windows-msvc \
--output=bin/staticalize-windows \
--include=VERSION \
--allow-read --allow-write --allow-net main.ts
- name: Compile for macOS x64
run: |
deno compile \
--target=x86_64-apple-darwin \
--output=bin/staticalize-macos \
--allow-read --allow-write --allow-net main.ts
--include=VERSION \
--allow-read --allow-write --allow-net main.ts
- name: Release
uses: softprops/action-gh-release@v2
Expand Down
13 changes: 11 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { main } from "effection";
import { call, 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";

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

function* version() {
try {
return yield* call(() => Deno.readTextFile(join(import.meta.dirname ?? "./", "VERSION")));
} catch {
return "0.0.0"
}
}

0 comments on commit 7e69dba

Please sign in to comment.