зеркало из https://github.com/mozilla/mig.git
Modifying the agent build process to record the name of agent binaries in releases.json
This commit is contained in:
Родитель
5a3aeb1880
Коммит
9b9b28872a
|
@ -1,24 +1,11 @@
|
|||
{
|
||||
"agent": {
|
||||
"latest": "20180807-0.e8eb90a1.prod",
|
||||
"latest": "",
|
||||
"releases": [
|
||||
{
|
||||
"tag": "20180807-0.e8eb90a1.prod",
|
||||
"date": "2018/8/7",
|
||||
"notes": "Read the correct ident on CentOS 7",
|
||||
"sha256": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
"agentConfig": {
|
||||
"latest": "20180409-0.e8eb90a.prod",
|
||||
"releases": [
|
||||
{
|
||||
"tag": "20180807-0.e8eb90a1.prod",
|
||||
"date": "2018/8/7",
|
||||
"notes": "First release of the snazzy config tool",
|
||||
"sha256": ""
|
||||
}
|
||||
]
|
||||
"latest": "",
|
||||
"releases": []
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
BUILDREV=$(date +%Y%m%d)-0.$(git log --pretty=format:'%h' -n 1).prod
|
||||
RELEASEDIR=releases
|
||||
TAG=$(date +%Y%m%d)-0.$(git log --pretty=format:'%h' -n 1)
|
||||
|
||||
BUILDS=(
|
||||
# FORMAT
|
||||
# GOOS GOARCH BINSUFFIX
|
||||
"darwin 386 darwin-i386-$TAG.prod"
|
||||
"darwin amd64 darwin-amd64-$TAG.prod"
|
||||
"linux 386 linux-i386-$TAG.prod"
|
||||
"linux amd64 linux-amd64-$TAG.prod"
|
||||
"windows 386 windows-i386-$TAG.prod.exe"
|
||||
"windows amd64 windows-amd64-$TAG.prod.exe"
|
||||
)
|
||||
|
||||
|
||||
# update_releases invokes the update_release_json tool to record an agent update.
|
||||
# It expects to be called with three arguments:
|
||||
|
@ -7,16 +20,24 @@ BUILDREV=$(date +%Y%m%d)-0.$(git log --pretty=format:'%h' -n 1).prod
|
|||
# 3. The path to the new agent binary.
|
||||
function update_releases() {
|
||||
releasejson=$(go run tools/update_release_json.go \
|
||||
-releases $1 \
|
||||
-releases $RELEASEDIR/$1 \
|
||||
-component agent \
|
||||
-tag $2 \
|
||||
-sha256 $(cat $3 | openssl sha256))
|
||||
-binary $3 \
|
||||
-sha256 $(cat $RELEASEDIR/$3 | openssl sha256))
|
||||
|
||||
echo "$releasejson" > $1
|
||||
echo "$releasejson" > $RELEASEDIR/$1
|
||||
}
|
||||
|
||||
|
||||
GOOS=darwin GOARCH=386 go build -o releases/mig-agent-$BUILDREV github.com/mozilla/mig/mig-agent
|
||||
if [ $? -eq 0 ]; then
|
||||
update_releases releases/releases.json $BUILDREV releases/mig-agent-$BUILDREV
|
||||
fi
|
||||
for build in "${BUILDS[@]}"; do
|
||||
IFS=" " read -ra args <<< "$build"
|
||||
echo "Building an agent for ${args[0]}/${args[1]}"
|
||||
GOOS=${args[0]} GOARCH=${args[1]} go build -o $RELEASEDIR/mig-agent-${args[2]} github.com/mozilla/mig/mig-agent
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "+ Build succeeded"
|
||||
update_releases releases.json $TAG mig-agent-${args[2]}
|
||||
else
|
||||
echo "- Build failed";
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -30,6 +30,7 @@ type Component struct {
|
|||
// Release contains information about a release of any component.
|
||||
type Release struct {
|
||||
Tag string `json:"tag"`
|
||||
Binary string `json:"binary"`
|
||||
Date string `json:"date"`
|
||||
Notes string `json:"notes"`
|
||||
Sha256 string `json:"sha256"`
|
||||
|
@ -45,11 +46,12 @@ func formatDate(date time.Time) string {
|
|||
|
||||
// setLatestRelease updates a component with a new release, setting the
|
||||
// latest release tag and adding to its release history.
|
||||
func setLatestRelease(comp *Component, tag, notes, sha256 string) {
|
||||
func setLatestRelease(comp *Component, binaryName, tag, notes, sha256 string) {
|
||||
comp.LatestReleaseTag = tag
|
||||
|
||||
comp.ReleaseHistory = append(comp.ReleaseHistory, Release{
|
||||
Tag: tag,
|
||||
Binary: binaryName,
|
||||
Date: formatDate(time.Now()),
|
||||
Notes: notes,
|
||||
Sha256: sha256,
|
||||
|
@ -94,7 +96,7 @@ func isUniqueTag(comp Component, tag string) bool {
|
|||
// how to use this tool.
|
||||
func usage() {
|
||||
fmt.Fprintf(os.Stderr, "This program is used to update a JSON file describing releases of MIG components.\n\n")
|
||||
fmt.Fprintf(os.Stderr, "Note that the -component and -tag arguments are required.\n\n")
|
||||
fmt.Fprintf(os.Stderr, "Note that the -component, -binary and -tag arguments are required.\n\n")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
|
@ -111,6 +113,10 @@ func main() {
|
|||
fmt.Sprintf(
|
||||
"The name of the component to update. Must be one of: %s",
|
||||
strings.Join(knownComponents(), ", ")))
|
||||
binary := flag.String(
|
||||
"binary",
|
||||
"",
|
||||
"The name of the binary file")
|
||||
tag := flag.String(
|
||||
"tag",
|
||||
"",
|
||||
|
@ -147,12 +153,16 @@ func main() {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
if *binary == "" {
|
||||
fmt.Fprintf(os.Stderr, "No binary name supplied.\n")
|
||||
}
|
||||
|
||||
if *tag == "" {
|
||||
fmt.Fprintf(os.Stderr, "No tag identifier supplied.\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
setLatestRelease(component, *tag, *notes, *sha256)
|
||||
setLatestRelease(component, *binary, *tag, *notes, *sha256)
|
||||
|
||||
prefix := ""
|
||||
indent := " "
|
||||
|
|
Загрузка…
Ссылка в новой задаче