Updated build script, and addded environment option for projects
This commit is contained in:
parent
6e482121ed
commit
481c2574a6
10
README.md
10
README.md
@ -17,9 +17,17 @@ You'll setup a project which will need the following information:
|
|||||||
5. Path to the release file
|
5. Path to the release file
|
||||||
6. Script to set release name / version
|
6. Script to set release name / version
|
||||||
|
|
||||||
|
An optional set of environment strings can be set to define the environment in which the scripts run.
|
||||||
|
```
|
||||||
|
"environment": [
|
||||||
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/go/bin",
|
||||||
|
"GOPATH=@dir"
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
Projects will be defined in a project.json file for now. I may add a web interface later.
|
Projects will be defined in a project.json file for now. I may add a web interface later.
|
||||||
|
|
||||||
@dir in any of the script strings will be replaced with an absolute path to the current working directory of the specific version being worked on.
|
@dir in any of the script strings or environment entries will be replaced with an absolute path to the current working directory of the specific version being worked on.
|
||||||
```
|
```
|
||||||
sh ./build.sh @dir
|
sh ./build.sh @dir
|
||||||
```
|
```
|
||||||
|
6
build.sh
6
build.sh
@ -2,10 +2,8 @@
|
|||||||
|
|
||||||
dir=$1
|
dir=$1
|
||||||
|
|
||||||
export GOPATH=$dir
|
|
||||||
|
|
||||||
echo working dir: $dir
|
|
||||||
|
|
||||||
go get -u git.townsourced.com/townsourced/ironsmith
|
go get -u git.townsourced.com/townsourced/ironsmith
|
||||||
|
|
||||||
|
cd $dir/src/git.townsourced.com/townsourced/ironsmith
|
||||||
|
|
||||||
go-bindata web/... && go build -a -v -o ironsmith
|
go-bindata web/... && go build -a -v -o ironsmith
|
||||||
|
10
cycle.go
10
cycle.go
@ -94,13 +94,13 @@ func (p *Project) fetch() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//fetch project
|
//fetch project
|
||||||
fetchResult, err := runCmd(p.Fetch, tempDir)
|
fetchResult, err := runCmd(p.Fetch, tempDir, p.Environment)
|
||||||
if p.errHandled(err) {
|
if p.errHandled(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetched succesfully, determine version
|
// fetched succesfully, determine version
|
||||||
version, err := runCmd(p.Version, tempDir)
|
version, err := runCmd(p.Version, tempDir, p.Environment)
|
||||||
|
|
||||||
if p.errHandled(err) {
|
if p.errHandled(err) {
|
||||||
return
|
return
|
||||||
@ -152,7 +152,7 @@ func (p *Project) build() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
output, err := runCmd(p.Build, p.workingDir())
|
output, err := runCmd(p.Build, p.workingDir(), p.Environment)
|
||||||
|
|
||||||
if p.errHandled(err) {
|
if p.errHandled(err) {
|
||||||
return
|
return
|
||||||
@ -173,7 +173,7 @@ func (p *Project) test() {
|
|||||||
if p.Test == "" {
|
if p.Test == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
output, err := runCmd(p.Test, p.workingDir())
|
output, err := runCmd(p.Test, p.workingDir(), p.Environment)
|
||||||
|
|
||||||
if p.errHandled(err) {
|
if p.errHandled(err) {
|
||||||
return
|
return
|
||||||
@ -195,7 +195,7 @@ func (p *Project) release() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
output, err := runCmd(p.Release, p.workingDir())
|
output, err := runCmd(p.Release, p.workingDir(), p.Environment)
|
||||||
|
|
||||||
if p.errHandled(err) {
|
if p.errHandled(err) {
|
||||||
return
|
return
|
||||||
|
7
exec.go
7
exec.go
@ -10,9 +10,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func runCmd(cmd, dir string) ([]byte, error) {
|
func runCmd(cmd, dir string, env []string) ([]byte, error) {
|
||||||
s := strings.Fields(strings.Replace(cmd, "@dir", dir, -1))
|
s := strings.Fields(strings.Replace(cmd, "@dir", dir, -1))
|
||||||
|
|
||||||
|
for i := range env {
|
||||||
|
env[i] = strings.Replace(env[i], "@dir", dir, -1)
|
||||||
|
}
|
||||||
|
|
||||||
var args []string
|
var args []string
|
||||||
|
|
||||||
if len(s) > 1 {
|
if len(s) > 1 {
|
||||||
@ -22,6 +26,7 @@ func runCmd(cmd, dir string) ([]byte, error) {
|
|||||||
ec := exec.Command(s[0], args...)
|
ec := exec.Command(s[0], args...)
|
||||||
|
|
||||||
ec.Dir = dir
|
ec.Dir = dir
|
||||||
|
ec.Env = env
|
||||||
|
|
||||||
vlog("Executing command: %s in dir %s\n", cmd, dir)
|
vlog("Executing command: %s in dir %s\n", cmd, dir)
|
||||||
|
|
||||||
|
@ -48,6 +48,8 @@ The project lifecycle goes like this, each step calling the next if successful
|
|||||||
type Project struct {
|
type Project struct {
|
||||||
Name string `json:"name"` // name of the project
|
Name string `json:"name"` // name of the project
|
||||||
|
|
||||||
|
Environment []string `json:"environment"` // Environment for each of the scripts below, if empty will use the current processes environment
|
||||||
|
|
||||||
Fetch string `json:"fetch"` //Script to fetch the latest project code into the current directory
|
Fetch string `json:"fetch"` //Script to fetch the latest project code into the current directory
|
||||||
Build string `json:"build"` //Script to build the latest project code
|
Build string `json:"build"` //Script to build the latest project code
|
||||||
Test string `json:"test"` //Script to test the latest project code
|
Test string `json:"test"` //Script to test the latest project code
|
||||||
|
Loading…
Reference in New Issue
Block a user