1+ name : build
2+
3+ # We now default to running this workflow on every push to every branch.
4+ # This provides fast feedback when build issues occur, so they can be
5+ # fixed prior to being merged to the main branch.
6+ #
7+ # If you want to opt out of this, and only run the build on certain branches
8+ # please refer to the documentation on branch filtering here:
9+ #
10+ # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore
11+ #
12+ on : [workflow_dispatch, push]
13+
14+ env :
15+ PKG_NAME : " go-getter"
16+
17+ jobs :
18+ get-go-version :
19+ runs-on : ubuntu-latest
20+ outputs :
21+ go-version : ${{ steps.get-go-version.outputs.go-version }}
22+ steps :
23+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+ - name : Determine Go version
25+ id : get-go-version
26+ # We use .go-version as our source of truth for current Go
27+ # version, because "goenv" can react to it automatically.
28+ # Specify the exact Go version (e.g., 1.22.4) in .go-version
29+ # if your build requires a specific patch version of Go.
30+ # Otherwise, specify the major and minor versions (e.g., 1.22),
31+ # with a caveat that it can lead to builds using different
32+ # patch versions of Go in a workflow run.
33+ run : |
34+ echo "Building with Go $(cat .go-version)"
35+ echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
36+
37+ set-product-version :
38+ runs-on : ubuntu-latest
39+ outputs :
40+ product-version : ${{ steps.set-product-version.outputs.product-version }}
41+ product-base-version : ${{ steps.set-product-version.outputs.base-product-version }}
42+ product-prerelease-version : ${{ steps.set-product-version.outputs.prerelease-product-version }}
43+ product-minor-version : ${{ steps.set-product-version.outputs.minor-product-version }}
44+ steps :
45+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
46+ - name : Set Product version
47+ id : set-product-version
48+ uses : hashicorp/actions-set-product-version@v1
49+
50+ generate-metadata-file :
51+ needs : set-product-version
52+ runs-on : ubuntu-latest
53+ outputs :
54+ filepath : ${{ steps.generate-metadata-file.outputs.filepath }}
55+ steps :
56+ - name : " Checkout directory"
57+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
58+ - name : Generate metadata file
59+ id : generate-metadata-file
60+ uses : hashicorp/actions-generate-metadata@v1
61+ with :
62+ version : ${{ needs.set-product-version.outputs.product-version }}
63+ product : ${{ env.PKG_NAME }}
64+ repositoryOwner : " hashicorp"
65+ - uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
66+ with :
67+ name : metadata.json
68+ path : ${{ steps.generate-metadata-file.outputs.filepath }}
69+
70+ build-other :
71+ needs :
72+ - get-go-version
73+ - set-product-version
74+ runs-on : ubuntu-latest
75+ strategy :
76+ fail-fast : false # recommended during development
77+ matrix :
78+ goos : [freebsd, windows, netbsd, openbsd, solaris]
79+ goarch : ["386", "amd64", "arm"]
80+ go : [ "${{ needs.get-go-version.outputs.go-version }}" ]
81+ exclude :
82+ - goos : solaris
83+ goarch : 386
84+ - goos : solaris
85+ goarch : arm
86+ - goos : windows
87+ goarch : arm
88+
89+ name : Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
90+
91+ steps :
92+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
93+
94+ - uses : hashicorp/actions-go-build@v1
95+ env :
96+ BASE_VERSION : ${{ needs.set-product-version.outputs.product-base-version }}
97+ PRERELEASE_VERSION : ${{ needs.set-product-version.outputs.product-prerelease-version}}
98+ METADATA_VERSION : ${{ env.METADATA }}
99+ with :
100+ product_name : ${{ env.PKG_NAME }}
101+ product_version : ${{ needs.set-product-version.outputs.product-version }}
102+ go_version : ${{ matrix.go }}
103+ os : ${{ matrix.goos }}
104+ arch : ${{ matrix.goarch }}
105+ reproducible : report
106+ instructions : |-
107+ cp LICENSE "$TARGET_DIR/LICENSE.txt"
108+ go build -o "$BIN_PATH" -trimpath -buildvcs=false
109+
110+ build-linux :
111+ needs :
112+ - get-go-version
113+ - set-product-version
114+ runs-on : ubuntu-latest
115+ strategy :
116+ matrix :
117+ goos : [linux]
118+ goarch : ["arm", "arm64", "386", "amd64"]
119+
120+ fail-fast : false # recommended during development
121+
122+ name : Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
123+
124+ steps :
125+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
126+
127+ - uses : hashicorp/actions-go-build@v1
128+ env :
129+ BASE_VERSION : ${{ needs.set-product-version.outputs.product-base-version }}
130+ PRERELEASE_VERSION : ${{ needs.set-product-version.outputs.product-prerelease-version}}
131+ METADATA_VERSION : ${{ env.METADATA }}
132+ with :
133+ product_name : ${{ env.PKG_NAME }}
134+ product_version : ${{ needs.set-product-version.outputs.product-version }}
135+ go_version : ${{ needs.get-go-version.outputs.go-version }}
136+ os : ${{ matrix.goos }}
137+ arch : ${{ matrix.goarch }}
138+ reproducible : report
139+ instructions : |
140+ cp LICENSE "$TARGET_DIR/LICENSE.txt"
141+ go build -o "$BIN_PATH" -trimpath -buildvcs=false
142+ - name : Copy license file to config_dir
143+ if : ${{ matrix.goos == 'linux' }}
144+ env :
145+ LICENSE_DIR : " .release/linux/package/usr/share/doc/${{ env.PKG_NAME }}"
146+ run : |
147+ mkdir -p "$LICENSE_DIR" && cp LICENSE "$LICENSE_DIR/LICENSE.txt"
148+ - name : Package
149+ if : ${{ matrix.goos == 'linux' }}
150+ uses : hashicorp/actions-packaging-linux@v1
151+ with :
152+ name : ${{ github.event.repository.name }}
153+ description : " go-getter is a Go library and command line tool for downloading files and directories from various sources including local filesystems, HTTP(S), Git, Mercurial, Amazon S3, Google Cloud Storage, and Azure Blob Storage."
154+ arch : ${{ matrix.goarch }}
155+ version : ${{ needs.set-product-version.outputs.product-version }}
156+ maintainer : " HashiCorp"
157+ homepage : " https://github.com/hashicorp/go-getter"
158+ license : " MPL-2.0"
159+ binary : " dist/${{ env.PKG_NAME }}"
160+ deb_depends : " openssl"
161+ rpm_depends : " openssl"
162+ config_dir : " .release/linux/package/"
163+
164+ - name : Set Package Names
165+ if : ${{ matrix.goos == 'linux' }}
166+ run : |
167+ echo "RPM_PACKAGE=$(basename out/*.rpm)" >> "$GITHUB_ENV"
168+ echo "DEB_PACKAGE=$(basename out/*.deb)" >> "$GITHUB_ENV"
169+
170+ - uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
171+ if : ${{ matrix.goos == 'linux' }}
172+ with :
173+ name : ${{ env.RPM_PACKAGE }}
174+ path : out/${{ env.RPM_PACKAGE }}
175+
176+ - uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
177+ if : ${{ matrix.goos == 'linux' }}
178+ with :
179+ name : ${{ env.DEB_PACKAGE }}
180+ path : out/${{ env.DEB_PACKAGE }}
181+
182+ build-darwin :
183+ needs :
184+ - get-go-version
185+ - set-product-version
186+ runs-on : macos-latest
187+ strategy :
188+ matrix :
189+ goos : [darwin]
190+ goarch : ["amd64", "arm64"]
191+ fail-fast : true
192+
193+ name : Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
194+
195+ env :
196+ GOOS : ${{ matrix.goos }}
197+ GOARCH : ${{ matrix.goarch }}
198+
199+ steps :
200+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
201+
202+ - uses : hashicorp/actions-go-build@v1
203+ env :
204+ BASE_VERSION : ${{ needs.set-product-version.outputs.product-base-version }}
205+ PRERELEASE_VERSION : ${{ needs.set-product-version.outputs.product-prerelease-version}}
206+ METADATA_VERSION : ${{ env.METADATA }}
207+ with :
208+ product_name : ${{ env.PKG_NAME }}
209+ product_version : ${{ needs.set-product-version.outputs.product-version }}
210+ go_version : ${{ needs.get-go-version.outputs.go-version }}
211+ os : ${{ matrix.goos }}
212+ arch : ${{ matrix.goarch }}
213+ reproducible : report
214+ instructions : |
215+ cp LICENSE "$TARGET_DIR/LICENSE.txt"
216+ go build -o "$BIN_PATH" -trimpath -buildvcs=false
0 commit comments