Skip to content

Commit 03e24a2

Browse files
committed
add ci
1 parent 9ee4f1b commit 03e24a2

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

‎.github/workflows/go.yml‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Go
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags: ["v*.*.*"]
7+
pull_request:
8+
branches: [ main ]
9+
10+
jobs:
11+
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v2
19+
with:
20+
go-version: 1.17
21+
22+
- name: Build
23+
run: |
24+
build() {
25+
export GOOS=$1
26+
export GOARCH=$2
27+
go build -ldflags "-s -w" -o build/cert-copier-${1}-${2}${3} main.go
28+
}
29+
build linux amd64
30+
build windows amd64 .exe
31+
build windows 386 .exe
32+
build darwin amd64
33+
build darwin arm64
34+
- name: Upload a Build Artifact
35+
uses: actions/upload-artifact@v2.2.4
36+
with:
37+
path: build/*
38+
- name: Release
39+
uses: softprops/action-gh-release@v1
40+
if: startsWith(github.ref, 'refs/tags/')
41+
with:
42+
files: build/*

‎main.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"io/ioutil"
1212
"log"
1313
"os"
14+
"path/filepath"
1415
"regexp"
1516
)
1617

@@ -108,7 +109,8 @@ var fileNameRegex = regexp.MustCompile(`[^a-zA-Z0-9_\-.]`)
108109

109110
func main() {
110111
if len(os.Args) != 2 {
111-
log.Fatal("usage: go run main.go $addr, for example: go run main.go github.com:443")
112+
name := filepath.Base(os.Args[0])
113+
log.Fatalf("usage: %s $addr, for example: %s github.com:443", name, name)
112114
}
113115
certs, err := getCertsFromNetwork(os.Args[1])
114116
if err != nil {

0 commit comments

Comments
 (0)