feat: bundle: only write git tags for newly packed bundles
This commit is contained in:
parent
4dedced175
commit
f41435d285
@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
@ -40,38 +40,42 @@ func splitOverride(override string) (string, string) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
// read metadata from the embedded bundle, includes all info except git tags
|
||||
metadata, err := build.ReadEmbeddedBuiltinActorsMetadata()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var metadataSpecificVersion []*build.BuiltinActorsMetadata
|
||||
// see ./build/actors/pack.sh
|
||||
// expected args are:
|
||||
// $(GOCC) run ./gen/bundle $(VERSION) $(RELEASE) $(RELEASE_OVERRIDES)
|
||||
// overrides are in the format network_name=override
|
||||
|
||||
// IF args have been provided, extract git tag info from them, otherwise
|
||||
// rely on previously embedded metadata for git tags.
|
||||
if len(os.Args) > 1 {
|
||||
version := os.Args[1]
|
||||
// see ./build/actors/pack.sh
|
||||
// (optional) expected args are:
|
||||
// $(GOCC) run ./gen/bundle $(VERSION) $(RELEASE) $(RELEASE_OVERRIDES)
|
||||
// overrides are in the format network_name=override
|
||||
gitTag := os.Args[2]
|
||||
packedActorsVersion, err := strconv.Atoi(os.Args[1][1:])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
overrides := map[string]string{}
|
||||
for _, override := range os.Args[3:] {
|
||||
k, v := splitOverride(override)
|
||||
overrides[k] = v
|
||||
}
|
||||
for _, m := range metadata {
|
||||
if strings.HasPrefix(version, fmt.Sprintf("v%d", m.Version)) {
|
||||
// correct version
|
||||
if int(m.Version) == packedActorsVersion {
|
||||
override, ok := overrides[m.Network]
|
||||
if ok {
|
||||
m.BundleGitTag = override
|
||||
} else {
|
||||
m.BundleGitTag = os.Args[2]
|
||||
m.BundleGitTag = gitTag
|
||||
}
|
||||
metadataSpecificVersion = append(metadataSpecificVersion, m)
|
||||
} else {
|
||||
m.BundleGitTag = getOldGitTagFromEmbeddedMetadata(m)
|
||||
}
|
||||
}
|
||||
metadata = metadataSpecificVersion
|
||||
|
||||
}
|
||||
|
||||
fi, err := os.Create("./build/builtin_actors_gen.go")
|
||||
@ -85,3 +89,14 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func getOldGitTagFromEmbeddedMetadata(m *build.BuiltinActorsMetadata) string {
|
||||
for _, v := range build.EmbeddedBuiltinActorsMetadata {
|
||||
// if we agree on the manifestCid for the previously embedded metadata, use the previously set tag
|
||||
if m.Version == v.Version && m.Network == v.Network && m.ManifestCid == v.ManifestCid {
|
||||
return m.BundleGitTag
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user