mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2024-11-04 21:43:42 +00:00
打包时包含源文件
This commit is contained in:
parent
e94fc341de
commit
79fe61e65c
13
builder.go
13
builder.go
@ -29,6 +29,9 @@ func main() {
|
||||
// zip文件名
|
||||
zipBaseName := fmt.Sprintf("gopl-zh-%s-%s", time.Now().Format("20060102"), gitVersion[:6])
|
||||
|
||||
// 导出Git
|
||||
exportGitToZip("./_book/" + zipBaseName + ".source.zip")
|
||||
|
||||
os.Remove(zipBaseName + ".zip")
|
||||
file, err := os.Create(zipBaseName + ".zip")
|
||||
if err != nil {
|
||||
@ -112,6 +115,16 @@ func getGitCommitVersion() (version string) {
|
||||
return "master"
|
||||
}
|
||||
|
||||
// 导出Git到Zip文件
|
||||
func exportGitToZip(filename string) {
|
||||
if !strings.HasSuffix(filename, ".zip") {
|
||||
filename += ".zip"
|
||||
}
|
||||
if _, err := exec.Command(`git`, `archive`, `--format`, `zip`, `--output`, filename, `master`).CombinedOutput(); err != nil {
|
||||
log.Fatal("cpFile: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func cpFile(dst, src string) {
|
||||
err := os.MkdirAll(filepath.Dir(dst), 0666)
|
||||
if err != nil && !os.IsExist(err) {
|
||||
|
Loading…
Reference in New Issue
Block a user