Skip to content

Commit 7e69dba

Browse files
committed
Include version with binary
1 parent e1462ef commit 7e69dba

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

.github/workflows/publish.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,54 @@ jobs:
1818

1919
- run: mkdir bin
2020

21+
- name: Get Version
22+
id: vars
23+
run: echo ::set-output name=version::$(echo ${{github.ref_name}} | sed 's/^v//')
24+
25+
- name: Write Version file
26+
run: |
27+
touch VERSION
28+
echo ${{steps.vars.outputs.version}} > VERSION
29+
2130
- name: Compile for Linux arm64
2231
run: |
2332
deno compile \
2433
--target=aarch64-unknown-linux-gnu \
2534
--output=bin/staticalize-linux-arm64 \
35+
--include=VERSION \
2636
--allow-read --allow-write --allow-net main.ts
2737
2838
- name: Compile for macOS arm64
2939
run: |
3040
deno compile \
3141
--target=aarch64-apple-darwin \
3242
--output=bin/staticalize-macos-arm64 \
43+
--include=VERSION \
3344
--allow-read --allow-write --allow-net main.ts
3445
3546
- name: Compile for Linux x64
3647
run: |
3748
deno compile \
3849
--target=x86_64-unknown-linux-gnu \
3950
--output=bin/staticalize-linux \
51+
--include=VERSION \
4052
--allow-read --allow-write --allow-net main.ts
4153
4254
- name: Compile for Windows x64
4355
run: |
4456
deno compile \
4557
--target=x86_64-pc-windows-msvc \
4658
--output=bin/staticalize-windows \
59+
--include=VERSION \
4760
--allow-read --allow-write --allow-net main.ts
4861
4962
- name: Compile for macOS x64
5063
run: |
5164
deno compile \
5265
--target=x86_64-apple-darwin \
5366
--output=bin/staticalize-macos \
54-
--allow-read --allow-write --allow-net main.ts
67+
--include=VERSION \
68+
--allow-read --allow-write --allow-net main.ts
5569
5670
- name: Release
5771
uses: softprops/action-gh-release@v2

main.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { main } from "effection";
1+
import { call, main } from "effection";
22
import { parser } from "npm:zod-opts";
33
import { z } from "npm:zod";
44
import { staticalize } from "./staticalize.ts";
5+
import { join } from "jsr:@std/path";
56

67
const url = () =>
78
z.string().refine((str) => str.match(/^http/), {
@@ -14,7 +15,7 @@ await main(function* (args) {
1415
.description(
1516
"Create a static version of a website by traversing a dynamically evaluated sitemap.xml",
1617
)
17-
.version("0.0.0")
18+
.version(yield* version())
1819
.options({
1920
site: {
2021
alias: "s",
@@ -41,3 +42,11 @@ await main(function* (args) {
4142
dir: options.output,
4243
});
4344
});
45+
46+
function* version() {
47+
try {
48+
return yield* call(() => Deno.readTextFile(join(import.meta.dirname ?? "./", "VERSION")));
49+
} catch {
50+
return "0.0.0"
51+
}
52+
}

0 commit comments

Comments
 (0)