aboutsummaryrefslogtreecommitdiff
path: root/cmd/within.website/build.go
blob: 40ab861326cda5471faf087cbec8485d373142e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//+build ignore

// Builds and deploys the application to minipaas.
package main

import (
	"context"
	"log"
	"os"

	"github.com/Xe/x/internal/kahless"
	"github.com/Xe/x/internal/minipaas"
	"github.com/Xe/x/internal/yeet"
)

func main() {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	env := append(os.Environ(), []string{"CGO_ENABLED=0", "GOOS=linux"}...)
	yeet.ShouldWork(ctx, env, yeet.WD, "go", "build", "-o=web")
	yeet.ShouldWork(ctx, env, yeet.WD, "appsluggr", "-web=web")
	fin, err := os.Open("slug.tar.gz")
	if err != nil {
		log.Fatal(err)
	}
	defer fin.Close()

	fname := "within.website-" + yeet.DateTag + ".tar.gz"
	pubURL, err := kahless.CopyFile(fname, fin)
	if err != nil {
		log.Fatal(err)
	}

	err = minipaas.Exec("tar:from within.website " + pubURL)
	if err != nil {
		log.Fatal(err)
	}
}