github.com/opentofu/opentofu@v1.7.1/.github/workflows/build-opentofu-oss.yml (about) 1 --- 2 name: build_opentofu 3 4 # This workflow is intended to be called by the build workflow. The crt make 5 # targets that are utilized automatically determine build metadata and 6 # handle building and packing OpenTofu. 7 8 on: 9 workflow_call: 10 inputs: 11 cgo-enabled: 12 type: string 13 default: 0 14 required: true 15 goos: 16 required: true 17 type: string 18 goarch: 19 required: true 20 type: string 21 go-version: 22 type: string 23 package-name: 24 type: string 25 default: tofu 26 bin-name: 27 type: string 28 default: tofu 29 product-version: 30 type: string 31 required: true 32 ld-flags: 33 type: string 34 required: true 35 runson: 36 type: string 37 required: true 38 39 jobs: 40 build: 41 runs-on: ${{ inputs.runson }} 42 name: OpenTofu ${{ inputs.goos }} ${{ inputs.goarch }} v${{ inputs.product-version }} 43 steps: 44 - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 45 - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 46 with: 47 go-version: ${{ inputs.go-version }} 48 - name: Determine artifact basename 49 run: echo "ARTIFACT_BASENAME=${{ inputs.package-name }}_${{ inputs.product-version }}_${{ inputs.goos }}_${{ inputs.goarch }}.zip" >> $GITHUB_ENV 50 - name: Build OpenTofu 51 env: 52 GOOS: ${{ inputs.goos }} 53 GOARCH: ${{ inputs.goarch }} 54 GO_LDFLAGS: ${{ inputs.ld-flags }} 55 ACTIONSOS: ${{ inputs.runson }} 56 CGO_ENABLED: ${{ inputs.cgo-enabled }} 57 uses: hashicorp/actions-go-build@v0.1.7 58 with: 59 bin_name: ${{ inputs.bin-name }} 60 product_name: ${{ inputs.product-name }} 61 product_version: ${{ inputs.product-version }} 62 go_version: ${{ inputs.go-version }} 63 os: ${{ inputs.goos }} 64 arch: ${{ inputs.goarch }} 65 reproducible: nope 66 instructions: |- 67 mkdir dist out 68 set -x 69 go build -ldflags "${{ inputs.ld-flags }}" -o dist/ ./cmd/tofu 70 zip -r -j out/${{ env.ARTIFACT_BASENAME }} dist/ 71 - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 72 with: 73 name: ${{ env.ARTIFACT_BASENAME }} 74 path: out/${{ env.ARTIFACT_BASENAME }} 75 if-no-files-found: error 76 - if: ${{ inputs.goos == 'linux' }} 77 uses: hashicorp/actions-packaging-linux@v1 78 with: 79 name: "opentofu" 80 description: "OpenTofu enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned." 81 arch: ${{ inputs.goarch }} 82 version: ${{ inputs.product-version }} 83 maintainer: "HashiCorp" 84 homepage: "https://opentofu.org/" 85 license: "MPL-2.0" 86 binary: "dist/tofu" 87 deb_depends: "git" 88 rpm_depends: "git" 89 - if: ${{ inputs.goos == 'linux' }} 90 name: Determine package file names 91 run: | 92 echo "RPM_PACKAGE=$(basename out/*.rpm)" >> $GITHUB_ENV 93 echo "DEB_PACKAGE=$(basename out/*.deb)" >> $GITHUB_ENV 94 - if: ${{ inputs.goos == 'linux' }} 95 uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 96 with: 97 name: ${{ env.RPM_PACKAGE }} 98 path: out/${{ env.RPM_PACKAGE }} 99 if-no-files-found: error 100 - if: ${{ inputs.goos == 'linux' }} 101 uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 102 with: 103 name: ${{ env.DEB_PACKAGE }} 104 path: out/${{ env.DEB_PACKAGE }} 105 if-no-files-found: error