Skip to content

Commit 0e17ee6

Browse files
committed
Update documentation: Script Variables & macOS + Linux build steps 📜
1 parent c39ea53 commit 0e17ee6

File tree

1 file changed

+96
-5
lines changed

1 file changed

+96
-5
lines changed

README.md

+96-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go-build is a multi-project, multi-branch build tool that can compile multiple b
44

55
This is ideal when working with many branches or repositories, as it allows easy publication or viewing of the compiled projects for testing and demonstration.
66

7-
The tool can be used in combination with CI systems such as Travis and Jenkins to bundle artifacts of many projects for download and testing, and additionaly can be used with services such as GitHub Pages and GitLab Pages to publish live, user-testable development artifacts.
7+
The tool can be used in combination with CI systems such as Travis and Jenkins to bundle artifacts of many projects for download and testing, and additionally can be used with services such as GitHub Pages and GitLab Pages to publish live, user-testable development artifacts.
88

99
## Configuration
1010

@@ -20,7 +20,17 @@ location (URL and Path), branches, scrips, and artifacts.
2020
- `path` - Path to use when cloning, and Publishing artifacts (Slugified name)
2121
- `artifacts` - Path to extract built artifacts from
2222
- `branches` - Array of branch names to build or `['*']` for all remote branches.
23-
- `scripts` - Array of script strings to execute (the build process)
23+
- `scripts` - Array of script strings to execute (the build process); May contain script variables (see below).
24+
25+
### Script Variables
26+
The `scripts` section of the `go-build` project configuration may use the following variables which will be replaced before the script is executed:
27+
28+
- `{{.Project}}` - The name (path) of the project.
29+
- `{{.Branch}}` - The branch under which the script is to run.
30+
- `{{.URL}}` - The clone url of the project.
31+
- `{{.Artifacts}}` - The path to the project's output artifacts.
32+
33+
Script variables are processed using go's [template](https://golang.org/pkg/text/template/) package, this gives a powerful set of Actions, Arguments, and Pipelines which can be combined with the above variables within a script.
2434

2535
### Run-time flags
2636

@@ -29,13 +39,94 @@ The following flags can be passed to `go-build` at runtime:
2939

3040
## Prerequisites
3141

32-
`go-build` utilises the `git2go` bindings of `libgit2`, which require that libgit2 is
33-
installed. In order to use SSH-based project urls, `libssh` is also required.
42+
`go-build` utilises the [git2go](https://github.com/libgit2/git2go) bindings of `libgit2`, which require that libgit2 is
43+
installed. In order to use SSH-based project urls, `libssh2` and `libssl` are also required.
44+
45+
## Building
46+
47+
### Building on macOS (darwin)
48+
49+
Ensure `GOPATH` is set, then install prerequisites:
50+
51+
```bash
52+
brew update
53+
brew upgrade # Optional, but recommended
54+
brew install git go upx # Up-to-date git, go compiler and upx packer (optional)
55+
brew install openssl libssh2 libgit2 # libssl, libssh2, libgit2 (required)
56+
```
57+
58+
Then, setup the environment to use the libraries installed via brew:
59+
60+
```bash
61+
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/lib"
62+
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/openssl/lib/pkgconfig"
63+
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/libssh2/lib/pkgconfig"
64+
export OPENSSLDIR=/usr/local/opt/openssl
65+
```
66+
(Optional: Add the above to `~/.bashrc` or `~/.bash_profile` to persist between sessions)
67+
68+
Fetch the go packages:
69+
70+
```bash
71+
go get -d github.com/op/go-logging
72+
go get -d github.com/libgit2/git2go
73+
```
74+
75+
And setup git2go's libgit2 submodule as per their documentation:
76+
77+
```bash
78+
cd $GOPATH/src/github.com/libgit2/git2go
79+
git submodule update --init
80+
make install-static
81+
```
82+
83+
Finally, build `go-build` using the supplied makefile:
84+
85+
```bash
86+
make build
87+
make pack # Optional: Pack the binary using UPX
88+
```
89+
90+
91+
### Building on Ubuntu (linux)
92+
93+
Ensure `GOPATH` is set and the prerequisite libraries are installed,
94+
then setup the environment to use the libraries:
95+
96+
```bash
97+
export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig/
98+
```
99+
(Optional: Add the above to `~/.bashrc` or `~/.bash_profile` to persist between sessions)
100+
101+
Fetch the go packages:
102+
103+
```bash
104+
go get -d github.com/op/go-logging
105+
go get -d github.com/libgit2/git2go
106+
```
107+
108+
And setup git2go's libgit2 submodule as per their documentation:
109+
110+
```bash
111+
cd $GOPATH/src/github.com/libgit2/git2go
112+
git submodule update --init
113+
make install-static
114+
```
115+
116+
Finally, build `go-build` using the supplied makefile:
117+
118+
```bash
119+
make build
120+
make pack # Optional: Pack the binary using UPX
121+
```
122+
123+
### Building on Windows (win32)
34124

125+
Building `go-build` on Windows has not yet been attempted, if you have successfully compiled `libssh2`, `libgit2` and `go-build` to run natively under win32 please feel free to document it here and [open a PR](https://github.com/Danw33/go-build/pulls).
35126

36127
## License
37128

38-
The Multi-Project Build Tool is released under the MIT License
129+
[`go-build`](https://github.com/Danw33/go-build) is released under the MIT License
39130

40131
Copyright © 2017 - 2018 Daniel Wilson
41132

0 commit comments

Comments
 (0)