support network name overrides in pack to build releases

This commit is contained in:
mike seiler 2023-02-16 10:33:47 -07:00
parent f427c2b566
commit 3e678f2abc
3 changed files with 27 additions and 9 deletions

View File

@ -298,7 +298,7 @@ actors-gen: actors-code-gen fiximports
.PHONY: actors-gen
bundle-gen:
$(GOCC) run ./gen/bundle $(RELEASE)
$(GOCC) run ./gen/bundle $(RELEASE) $(RELEASE_OVERRIDES)
$(GOCC) fmt ./build/...
.PHONY: bundle-gen

View File

@ -52,4 +52,4 @@ popd
echo "Generating metadata..."
make -C ../../ RELEASE="$RELEASE" bundle-gen
make -C ../../ RELEASE="$RELEASE" RELEASE_OVERRIDES="${RELEASE_OVERRIDES[*]}" bundle-gen

View File

@ -2,6 +2,7 @@ package main
import (
"os"
"strings"
"text/template"
"github.com/filecoin-project/lotus/build"
@ -32,19 +33,36 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
}
`))
func splitOverride(override string) (string, string) {
x := strings.Split(override, "=")
return x[0], x[1]
}
func main() {
metadata, err := build.ReadEmbeddedBuiltinActorsMetadata()
if err != nil {
panic(err)
}
// TODO: Re-enable this when we can set the tag for ONLY the appropriate version
// https://github.com/filecoin-project/lotus/issues/10185#issuecomment-1422864836
//if len(os.Args) > 1 {
// for _, m := range metadata {
// m.BundleGitTag = os.Args[1]
// }
//}
// see ./build/actors/pack.sh
// expected args are git bundle tag then number of per network overrides
// overrides are in the format network_name=override
overrides := map[string]string{}
for _, override := range os.Args[2:] {
network, version := splitOverride(override)
overrides[network] = version
}
if len(os.Args) > 1 {
for _, m := range metadata {
override, ok := overrides[m.Network]
if ok {
m.BundleGitTag = override
} else {
m.BundleGitTag = os.Args[1]
}
}
}
fi, err := os.Create("./build/builtin_actors_gen.go")
if err != nil {