File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 14
14
stable : ' true'
15
15
go-version : ' ^1.16.1'
16
16
- name : build
17
- run : go get github.com/mitchellh/gox && mkdir dist && perl build.pl && ls -al dist/
17
+ run : |
18
+ export PATH=$PATH:$(go env GOPATH)/bin
19
+ go get github.com/mitchellh/gox
20
+ mkdir dist
21
+ perl build.pl
22
+ ls -al dist/
18
23
- name : Upload binaries to release
19
24
uses : svenstaro/upload-release-action@v2
20
25
with :
24
29
asset_name : mything
25
30
tag : ${{ github.ref }}
26
31
overwrite : true
27
- file_glob : true
32
+ file_glob : true
Original file line number Diff line number Diff line change 1
- * .exe
1
+ * .exe
2
+ with-env
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "flag"
4
5
"fmt"
5
6
"os"
6
7
"os/exec"
7
8
"path/filepath"
9
+ "runtime/debug"
8
10
9
11
"github.com/joho/godotenv"
10
12
)
11
13
14
+ var (
15
+ showVersion = flag .Bool ("version" , false , "pring progream version" )
16
+ )
17
+
12
18
// first load env from ~/.env
13
19
// second load env from .env
14
20
func init () {
21
+ flag .Parse ()
22
+ if * showVersion {
23
+ PrintVersion ()
24
+ os .Exit (0 )
25
+ }
26
+ if len (os .Args ) < 2 {
27
+ fmt .Printf ("Usage: with-env {command}\n " )
28
+ os .Exit (1 )
29
+ }
15
30
home , _ := os .UserHomeDir ()
16
31
loadEnv (filepath .Join (home , ".env" ), ".env" )
17
32
}
@@ -33,3 +48,10 @@ func main() {
33
48
os .Exit (1 )
34
49
}
35
50
}
51
+
52
+ func PrintVersion () {
53
+ info , ok := debug .ReadBuildInfo ()
54
+ if ok {
55
+ println (info .Main .Version , info .Main .Sum )
56
+ }
57
+ }
You can’t perform that action at this time.
0 commit comments