Skip to content
Permalink
Browse files Browse the repository at this point in the history
script: Use source data from environment when generating assets
  • Loading branch information
calmh committed May 29, 2018
1 parent d60f0e7 commit c51365c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion script/genassets.go
Expand Up @@ -17,6 +17,7 @@ import (
"io"
"os"
"path/filepath"
"strconv"
"strings"
"text/template"
"time"
Expand Down Expand Up @@ -87,9 +88,17 @@ func main() {

filepath.Walk(flag.Arg(0), walkerFor(flag.Arg(0)))
var buf bytes.Buffer

// Generated time is now, except if the SOURCE_DATE_EPOCH environment
// variable is set (for reproducible builds).
generated := time.Now().Unix()
if s, _ := strconv.ParseInt(os.Getenv("SOURCE_DATE_EPOCH"), 10, 64); s > 0 {
generated = s
}

tpl.Execute(&buf, templateVars{
Assets: assets,
Generated: time.Now().Unix(),
Generated: generated,
})
bs, err := format.Source(buf.Bytes())
if err != nil {
Expand Down

0 comments on commit c51365c

Please sign in to comment.