~sbinet/star-tex-site

9a6e03d9bf06680daf8d39e651945e49ff337176 — Sebastien Binet 8 months ago 570e664
deploy: optionally generate a specific tag for /x/tex vanity imports
2 files changed, 18 insertions(+), 6 deletions(-)

M cmd_deploy.go
M gen-x-imports.go
M cmd_deploy.go => cmd_deploy.go +9 -3
@@ 10,6 10,7 @@ package main

import (
	"bytes"
	"flag"
	"fmt"
	"io"
	"log"


@@ 25,7 26,12 @@ const (
)

func main() {
	build()
	var (
		vers = flag.String("vers", "main", "tag or branch to process")
	)
	flag.Parse()

	build(*vers)
	upload()
}



@@ 40,8 46,8 @@ func run(cmd string, args ...string) {
	}
}

func build() {
	run("go", "run", "./gen-x-imports.go")
func build(vers string) {
	run("go", "run", "./gen-x-imports.go", "-vers="+vers)
	run("hugo")

	cmd := exec.Command("tar", "zcf", "../../site.tar.gz", ".")

M gen-x-imports.go => gen-x-imports.go +9 -3
@@ 10,6 10,7 @@ package main
import (
	"bytes"
	"encoding/json"
	"flag"
	"go/build"
	"html/template"
	"io"


@@ 30,6 31,12 @@ func main() {
	log.SetPrefix("gen-x-imports: ")
	log.SetFlags(0)

	var (
		vers = flag.String("vers", "main", "tag or branch to process")
	)

	flag.Parse()

	tmp, err := ioutil.TempDir("", "go-star-tex-")
	if err != nil {
		log.Fatal(err)


@@ 38,7 45,7 @@ func main() {

	cmd := exec.Command(
		"git",
		"clone", "--depth=2", "https://"+gitRepo, "star-tex",
		"clone", "--depth=2", "--branch="+*vers, "https://"+gitRepo, "star-tex",
	)
	cmd.Dir = tmp
	cmd.Stdin = os.Stdin


@@ 80,7 87,7 @@ loop:
	}

	for _, pkg := range pkgs {
		log.Printf("pkg: %q", pkg.ImportPath)
		log.Printf("%q", pkg.ImportPath)
		gen(pkg)
	}
}


@@ 91,7 98,6 @@ type Package struct {

func gen(pkg build.Package) {
	name := stdpath.Join("./src", stripPkg(pkg.ImportPath))
	log.Printf("==>: %q", name)
	err := os.MkdirAll(stdpath.Dir(name), 0755)
	if err != nil {
		log.Fatalf("could not make pkg dir: %+v", err)