Skip to content

Commit 36df92d

Browse files
committed
fix: get relative license_dir at runtime
macOS not support static build
1 parent 4ad69cc commit 36df92d

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,21 @@ jobs:
4343
uses: crystal-lang/install-crystal@v1
4444
- name: Install shards
4545
run: shards install
46-
- name: unix Build
47-
if: ${{ !startsWith(matrix.os, 'windows') }}
48-
run: just upload
46+
- name: ubuntu Build
47+
if: startsWith(matrix.os, 'ubuntu')
48+
run: |
49+
just static
50+
just upload
51+
- name: macos Build
52+
if: startsWith(matrix.os, 'macos')
53+
run: |
54+
just release
55+
just upload
4956
- name: windows Build
5057
if: startsWith(matrix.os, 'windows')
5158
run: |
5259
C:/msys64/usr/bin/pacman.exe -Sy --noconfirm zip
60+
just static
5361
just upload
5462
- name: Upload Artifact
5563
uses: actions/upload-artifact@v5

Justfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
NAME := "choose"
2-
VERSION := "v0.1.1"
2+
VERSION := "v0.1.2"
33

44
WORKDIR := justfile_directory()
55
GOOS := shell("go env GOOS")
@@ -19,18 +19,21 @@ build:
1919
release:
2020
shards build --release
2121

22+
static:
23+
shards build --release --static
24+
2225
run ARGS="": build
2326
cd src/{{NAME}} && {{WORKDIR}}/bin/{{NAME}} {{ ARGS }}
2427

25-
target: release
28+
target:
2629
mkdir -p target/{{TARGETPLATFORM}}
2730
ln -f bin/{{NAME}} target/{{TARGETPLATFORM}}/
2831
cp -a src/{{NAME}}/{{DATA}} target/{{TARGETPLATFORM}}/
2932
# tree target
3033

3134
cd target/{{TARGETPLATFORM}}/ && ./{{NAME}} list
3235

33-
upload: release
36+
upload:
3437
mkdir -p upload/{{PROGRAM}}
3538
ln -f bin/{{NAME}} upload/{{PROGRAM}}/
3639
cp -a src/{{NAME}}/{{DATA}} upload/{{PROGRAM}}/
@@ -40,7 +43,7 @@ upload: release
4043
cd upload && just zip '-r {{PROGRAM}}.zip {{PROGRAM}}'
4144
cd upload && just sha256sum '{{PROGRAM}}.zip >> {{PROGRAM}}.sha256sum'
4245

43-
upload-single: release
46+
upload-single:
4447
mkdir -p upload
4548
ln -f bin/{{NAME}} upload/{{PROGRAM}}
4649
# tree upload

src/choose.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ require "option_parser"
22
require "./choose/license"
33

44
module Choose
5-
VERSION = "0.1.1"
5+
VERSION = "0.1.2"
66

77
class Cli
88
@@year : String?

src/choose/license.cr

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ class Choose::License
2525

2626
class MoreThanOne < Exception; end
2727

28-
LICENSE_DIR = Path["_license"]
29-
3028
@@width = 80
3129

30+
private def self.license_dir
31+
Path.new(Process.executable_path.to_s).parent / "_license"
32+
end
33+
3234
private def self.auto_wrap(str : String, width : Int32 = @@width)
3335
words = str.split(/\s+/) # one or more spaces
3436
lines = [] of String
@@ -55,14 +57,14 @@ class Choose::License
5557

5658
def self.glob(pattern : String)
5759
pattern = pattern.downcase
58-
if File.exists?(LICENSE_DIR / "#{pattern}.txt")
59-
return [LICENSE_DIR / "#{pattern}.txt"]
60+
if File.exists?(license_dir / "#{pattern}.txt")
61+
return [license_dir / "#{pattern}.txt"]
6062
end
6163

6264
if !pattern.ends_with?("*")
6365
pattern = pattern + "*"
6466
end
65-
Dir.glob(LICENSE_DIR / pattern).map { |x| Path[x] }.sort!
67+
Dir.glob(license_dir / pattern).map { |x| Path[x] }.sort!
6668
end
6769

6870
def self.parse(pattern : String)

0 commit comments

Comments
 (0)