go build / go install should generate tofu binary (#590)

This commit is contained in:
Elbaz 2023-09-27 15:37:55 +03:00 committed by GitHub
parent 2c01380709
commit 8465827f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 13 additions and 10 deletions

View File

@ -62,7 +62,7 @@ jobs:
instructions: |-
mkdir dist out
set -x
go build -ldflags "${{ inputs.ld-flags }}" -o dist/ .
go build -ldflags "${{ inputs.ld-flags }}" -o dist/ ./cmd/tofu
zip -r -j out/${{ env.ARTIFACT_BASENAME }} dist/
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:

View File

@ -32,7 +32,7 @@ jobs:
- name: Build the OpenTofu binary
run: |
go build -o ./bin/tofu
go build -o ./bin/tofu ./cmd/tofu
- name: Run the equivalence tests
run: |

2
.gitignore vendored
View File

@ -18,7 +18,7 @@ website/node_modules
*.test
*.iml
/opentofu
/tofu
website/vendor
vendor/

View File

@ -10,6 +10,8 @@ builds:
- env:
- CGO_ENABLED=0
main: ./cmd/tofu
flags:
- "-mod=readonly"
- "-trimpath"
@ -202,11 +204,11 @@ signs:
- artifacts: checksum
cmd: cosign
certificate: "${artifact}.pem"
args: ["sign-blob", "--oidc-issuer=https://token.actions.githubusercontent.com", "--output-certificate=${certificate}", "--output-signature=${signature}", "${artifact}", "--yes"]
args: [ "sign-blob", "--oidc-issuer=https://token.actions.githubusercontent.com", "--output-certificate=${certificate}", "--output-signature=${signature}", "${artifact}", "--yes" ]
docker_signs:
- artifacts: all
args: ["sign", "--oidc-issuer=https://token.actions.githubusercontent.com", "${artifact}@${digest}", "--yes"]
args: [ "sign", "--oidc-issuer=https://token.actions.githubusercontent.com", "${artifact}@${digest}", "--yes" ]
snapshot:
name_template: "{{ .Version }}-next"

View File

@ -16,7 +16,7 @@ OpenTofu accepts certain options passed using `ldflags` at build time which cont
OpenTofu will include a `-dev` flag when reporting its own version (ex: 1.5.0-dev) unless `version.dev` is set to `no`:
```
go build -ldflags "-w -s -X 'github.com/opentofu/opentofu/version.dev=no'" -o bin/ .
go build -ldflags "-w -s -X 'github.com/opentofu/opentofu/version.dev=no'" -o bin/ ./cmd/tofu
```
### Experimental Features
@ -24,7 +24,7 @@ go build -ldflags "-w -s -X 'github.com/opentofu/opentofu/version.dev=no'" -o bi
Experimental features of OpenTofu will be disabled unless `main.experimentsAllowed` is set to `yes`:
```
go build -ldflags "-w -s -X 'main.experimentsAllowed=yes'" -o bin/ .
go build -ldflags "-w -s -X 'main.experimentsAllowed=yes'" -o bin/ ./cmd/tofu
```
## Go Options

View File

@ -58,7 +58,7 @@ Switch into the root directory of the cloned repository and build OpenTofu using
```
cd opentofu
go install .
go install ./cmd/tofu
```
The first time you run the `go install` command, the Go toolchain will download any library dependencies that you don't already have in your Go modules cache. Subsequent builds will be faster because these dependencies will already be available on your local disk.

View File

@ -210,6 +210,7 @@ func setupBinary() func() {
"build",
"-o", tmpTerraformBinaryDir,
"-ldflags", fmt.Sprintf("-X \"github.com/opentofu/opentofu/version.Prerelease=%s\"", tfversion.Prerelease),
"./cmd/tofu",
)
err = cmd.Run()
if err != nil {

View File

@ -48,7 +48,7 @@ func setup() func() {
return func() {}
}
tmpFilename := e2e.GoBuild("github.com/opentofu/opentofu", "tofu")
tmpFilename := e2e.GoBuild("github.com/opentofu/opentofu/cmd/tofu", "tofu")
// Make the executable available for use in tests
terraformBin = tmpFilename

View File

@ -59,7 +59,7 @@ gox \
-osarch="${XC_EXCLUDE_OSARCH}" \
-ldflags "${LD_FLAGS}" \
-output "pkg/{{.OS}}_{{.Arch}}/tofu" \
.
./cmd/tofu
# Move all the compiled things to the $GOPATH/bin
GOPATH=${GOPATH:-$(go env GOPATH)}