-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
176 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
|
||
- name: Build | ||
run: | | ||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_windows_x64.exe | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_linux_x64 | ||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_linux_arm64 | ||
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_linux_arm | ||
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_linux_386 | ||
CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_linux_mips | ||
CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_linux_mipsle | ||
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_linux_ppc64 | ||
CGO_ENABLED=0 GOOS=linux GOARCH=riscv64 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_linux_riscv64 | ||
CGO_ENABLED=0 GOOS=linux GOARCH=s390x go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_linux_s390x | ||
CGO_ENABLED=0 GOOS=netbsd GOARCH=amd64 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_netbsd_x64 | ||
CGO_ENABLED=0 GOOS=netbsd GOARCH=arm go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_netbsd_arm | ||
CGO_ENABLED=0 GOOS=netbsd GOARCH=arm64 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_netbsd_arm64 | ||
CGO_ENABLED=0 GOOS=openbsd GOARCH=386 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_openbsd_386 | ||
CGO_ENABLED=0 GOOS=openbsd GOARCH=amd64 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_openbsd_x64 | ||
CGO_ENABLED=0 GOOS=openbsd GOARCH=arm go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_openbsd_arm | ||
CGO_ENABLED=0 GOOS=openbsd GOARCH=arm64 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_openbsd_arm64 | ||
CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_freebsd_386 | ||
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_freebsd_x64 | ||
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_freebsd_arm | ||
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o pty_freebsd_arm64 | ||
- uses: "marvinpinto/action-automatic-releases@latest" | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
automatic_release_tag: "latest" | ||
title: Development Build | ||
prerelease: true | ||
files: | | ||
pty_windows_x64.exe | ||
pty_linux_x64 | ||
pty_linux_arm64 | ||
pty_linux_arm | ||
pty_linux_386 | ||
pty_linux_mips | ||
pty_linux_mipsle | ||
pty_linux_ppc64 | ||
pty_linux_riscv64 | ||
pty_linux_s390x | ||
pty_netbsd_x64 | ||
pty_netbsd_arm | ||
pty_netbsd_arm64 | ||
pty_openbsd_386 | ||
pty_openbsd_x64 | ||
pty_openbsd_arm | ||
pty_openbsd_arm64 | ||
pty_freebsd_386 | ||
pty_freebsd_x64 | ||
pty_freebsd_arm | ||
pty_freebsd_arm64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package main | ||
|
||
import ( | ||
"archive/zip" | ||
"io" | ||
"os" | ||
"strings" | ||
|
||
"golang.org/x/text/encoding" | ||
"golang.org/x/text/encoding/japanese" | ||
"golang.org/x/text/encoding/korean" | ||
"golang.org/x/text/encoding/simplifiedchinese" | ||
"golang.org/x/text/encoding/traditionalchinese" | ||
"golang.org/x/text/encoding/unicode" | ||
) | ||
|
||
func getDecoderByCoder(code string) *encoding.Decoder { | ||
code = strings.ToLower(code) | ||
var decoder *encoding.Decoder | ||
switch code { | ||
case "gbk": | ||
decoder = simplifiedchinese.GBK.NewDecoder() | ||
case "big5": | ||
decoder = traditionalchinese.Big5.NewDecoder() | ||
case "shift_jis": | ||
decoder = japanese.ShiftJIS.NewDecoder() | ||
case "euckr": | ||
decoder = korean.EUCKR.NewDecoder() | ||
default: | ||
decoder = unicode.UTF8.NewDecoder() | ||
} | ||
return decoder | ||
} | ||
|
||
func fileToZipWriter(file *os.File, prefix string, zw *zip.Writer) error { | ||
info, err := file.Stat() | ||
if err != nil { | ||
return err | ||
} | ||
if info.IsDir() { | ||
if prefix == "" { | ||
prefix = info.Name() | ||
} else { | ||
prefix = prefix + "/" + info.Name() | ||
} | ||
|
||
fileInfos, err := file.Readdir(-1) | ||
if err != nil { | ||
return err | ||
} | ||
for _, fi := range fileInfos { | ||
f, err := os.Open(file.Name() + "/" + fi.Name()) | ||
if err != nil { | ||
return err | ||
} | ||
err = fileToZipWriter(f, prefix, zw) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
} else { | ||
header, err := zip.FileInfoHeader(info) | ||
if prefix != "" { | ||
header.Name = prefix + "/" + header.Name | ||
} | ||
if err != nil { | ||
return err | ||
} | ||
writer, err := zw.CreateHeader(header) | ||
if err != nil { | ||
return err | ||
} | ||
_, err = io.Copy(writer, file) | ||
file.Close() | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} |