forked from microsoft/hcsshim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create composite action to call `actions/setup-go` with common values and logic across different jobs and workflows to reduce duplication and make sure workflows all use the same Go version. Specifically, the action defaults to `oldstable` for the Go version, uses both `go.sum` and `test/go.sum` for the cache dependency, and allows pre-filling the Go module cache after installing Go. It exposes the same outputs as `actions/setup-go` as well. Signed-off-by: Hamza El-Saawy <[email protected]>
- Loading branch information
Showing
4 changed files
with
89 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Setup Go | ||
description: Wraps actions/setup-go with default values. | ||
|
||
branding: | ||
icon: package | ||
color: grey-dark | ||
|
||
inputs: | ||
go-version: | ||
description: The Go version to download. | ||
default: oldstable | ||
cache: | ||
description: Enable caching Go modules and build outputs, | ||
default: true | ||
repo-path: | ||
description: Location this repo is checked out to. | ||
default: ${{ github.workspace }} | ||
fill-module-cache: | ||
description: Pre-fill the Go module cache. | ||
default: false | ||
|
||
outputs: | ||
go-version: | ||
description: The installed Go version. | ||
value: ${{ steps.setup-go.outputs.go-version }} | ||
cache-hit: | ||
description: A boolean value to indicate if there was a cache hit. | ||
value: ${{ steps.setup-go.outputs.cache-hit }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Install Go | ||
id: setup-go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ inputs.go-version }} | ||
cache: ${{ inputs.cache }} | ||
cache-dependency-path: | | ||
${{ inputs.repo-path }}/go.sum | ||
${{ inputs.repo-path }}/test/go.sum | ||
- name: Fill Module Cache | ||
if: ${{ fromJSON(inputs.fill-module-cache) }} | ||
run: | | ||
go mod download | ||
cd test | ||
go mod download | ||
working-directory: ${{ inputs.repo-path }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,19 @@ name: Build & Release | |
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
GO_VERSION: "1.21.x" | ||
- "v*" | ||
|
||
jobs: | ||
build: | ||
runs-on: "windows-2019" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
- name: Install Go | ||
uses: ./.github/actions/setup-go | ||
|
||
- run: go build ./cmd/dmverity-vhd | ||
- run: go build ./cmd/dmverity-vhd | ||
env: | ||
env: | ||
GOOS: linux | ||
GOARCH: amd64 | ||
|
||
|
@@ -39,7 +35,7 @@ jobs: | |
uses: actions/download-artifact@v4 | ||
with: | ||
name: binaries | ||
|
||
- name: Publish draft release | ||
uses: softprops/[email protected] | ||
with: | ||
|
@@ -49,4 +45,3 @@ jobs: | |
files: | | ||
dmverity-vhd.exe | ||
dmverity-vhd | ||