Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 1 addition & 38 deletions docs/PIPELINES-GO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,10 @@

Melange includes built-in pipelines to compile go projects. The first one,
`go/build` gives authors more control on the compiler invocation while
`go/install` focuses on simplicity.

To get started quickly, we offer two working examples:
[go-build.yaml](https://github.com/chainguard-dev/melange/blob/main/examples/go-build.yaml)
and
[go-install.yaml](https://github.com/chainguard-dev/melange/blob/main/examples/go-install.yaml)

## Simple and quick builds with `go/install`

For projects not needing sophisticated interactions with `go build` or control
over how source is downloaded, `go/install` provides a quick and simple way to
compile any publicly available go project.

Internally `go/install` is an interface to the `go install` command. It will
download the source code and dependencies and build them. Any produced binaries
will be installed into the specified directory.

Here's a sample of a one-shot compilation of an example project:

```yaml
package:
name: hello
version: v0.0.1
epoch: 0
description: "A project that will greet the world infinitely"
environment:
contents:
keyring:
- https://packages.wolfi.dev/os/wolfi-signing.rsa.pub
repositories:
- https://packages.wolfi.dev/os
pipeline:
- uses: go/install
with:
package: github.com/puerco/hello
version: HEAD
```

(:bulb: Experiment with this code,
[download it from the examples directory](https://github.com/chainguard-dev/melange/blob/main/examples/go-install.yaml))

## Building golang projects with `go/build`

Expand Down Expand Up @@ -85,7 +49,7 @@ pipeline:

## Build Parameters

Both `go/install` and `go/build` support passing a few parameters to the go
`go/build` support passing a few parameters to the go
compiler by setting them in the melange configuration file. As of this writing,
you can define the following values:

Expand Down Expand Up @@ -150,7 +114,6 @@ pipeline:

For the most up to date supported features check the
[build](https://github.com/chainguard-dev/melange/blob/main/pkg/build/pipelines/go/build.yaml),
[install](https://github.com/chainguard-dev/melange/blob/main/pkg/build/pipelines/go/install.yaml),
and
[bump](https://github.com/chainguard-dev/melange/blob/main/pkg/build/pipelines/go/bump.yaml),
pipeline definitions. Feel free to request more features in
Expand Down
2 changes: 0 additions & 2 deletions examples/go-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# For more information about melange's built-in golang support check out:
# https://github.com/chainguard-dev/melange/blob/main/docs/PIPELINES-GO.md
#
# For an equivalent pipeline that uses go/install to build the same project
# please see go-install.yaml in this directory.
package:
name: hello
version: 0.0.1
Expand Down
3 changes: 0 additions & 3 deletions examples/go-bump.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#
# For more information about melange's built-in golang support check out:
# https://github.com/chainguard-dev/melange/blob/main/docs/PIPELINES-GO.md
#
# For an equivalent pipeline that uses go/install to build the same project
# please see go-install.yaml in this directory.
package:
name: hello
version: 0.0.1
Expand Down
29 changes: 0 additions & 29 deletions examples/go-install.yaml

This file was deleted.

23 changes: 1 addition & 22 deletions pkg/build/pipelines/go/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@


<!-- start:pipeline-reference-gen -->
# Pipeline Reference


- [go/build](#gobuild)
- [go/bump](#gobump)
- [go/covdata](#gocovdata)
- [go/install](#goinstall)

## go/build

Expand Down Expand Up @@ -62,26 +62,5 @@ Get coverage data with the covdata go tool
| cover-dir | false | The GOCOVERDIR path where coverage data files have been generated. It's required to be set as environment variable as well before running the Go binary. | /home/build |
| package | false | The go package to install | go |

## go/install

Run a build using the go compiler

### Inputs

| Name | Required | Description | Default |
| ---- | -------- | ----------- | ------- |
| amd64 | false | GOAMD64 microarchitecture level to use | v2 |
| arm64 | false | GOARM64 microarchitecture level to use | v8.0 |
| experiments | false | A comma-separated list of Golang experiment names (ex: loopvar) to use when building the binary. | |
| go-package | false | The go package to install | go |
| install-dir | false | Directory where binaries will be installed | bin |
| ldflags | false | List of [pattern=]arg to append to the go compiler with -ldflags | |
| package | true | Import path to the package | |
| prefix | false | Prefix to relocate binaries | usr |
| strip | false | Set of strip ldflags passed to the go compiler | -w |
| tags | false | A comma-separated list of build tags to append to the go compiler | |
| toolchaintags | false | A comma-separated list of default toolchain go build tags | netgo,osusergo |
| version | false | Package version to install. This can be a version tag (v1.0.0), a commit hash or another ref (eg latest or HEAD). | |


<!-- end:pipeline-reference-gen -->
92 changes: 0 additions & 92 deletions pkg/build/pipelines/go/install.yaml

This file was deleted.

5 changes: 3 additions & 2 deletions pkg/sca/testdata/go-fips-bin/go-fips-bin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ environment:
- https://packages.wolfi.dev/os

pipeline:
- uses: go/install
- uses: go/build
with:
package: .
packages: .
output: go-fips-bin
# This is an approximation to the real go-fips toolchain
experiments: boringcrypto
Loading