-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "release" makefile target and github action to run GoReleaser (#75)
This commit adds a goreleaser make target and updates the github actions workflows to run the deploy stages (GoReleaser and Docker) for tags and PRs (PR artifacts aren't pushed anywhere).
- Loading branch information
1 parent
8fbb1e3
commit 00a0e71
Showing
5 changed files
with
130 additions
and
59 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
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,74 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
goreleaser: | ||
name: GoReleaser | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.15 | ||
|
||
- name: Create release | ||
run: | | ||
SNAPSHOT="--snapshot" | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
SNAPSHOT="" | ||
fi | ||
GORELEASER_ARGS="--rm-dist ${SNAPSHOT}" make release | ||
docker: | ||
name: Docker | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Prepare | ||
id: prep | ||
run: | | ||
IMG=quay.io/joelanford/helm-operator | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
TAG=${GITHUB_REF#refs/tags/} | ||
MAJOR_MINOR=${TAG%.*} | ||
echo ::set-output name=tags::${IMG}:${TAG},${IMG}:${MAJOR_MINOR} | ||
elif [[ $GITHUB_REF == refs/pull/* ]]; then | ||
TAG=pr-${{ github.event.number }} | ||
echo ::set-output name=tags::${IMG}:${TAG} | ||
fi | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to Quay | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.QUAY_USERNAME }} | ||
password: ${{ secrets.QUAY_PASSWORD }} | ||
registry: quay.io | ||
|
||
- name: Build helm-operator image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.prep.outputs.tags }} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Binaries for programs and plugins | ||
/bin | ||
/tools/bin | ||
/dist | ||
|
||
# Other IDE files | ||
.idea | ||
|
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,47 @@ | ||
# Global environment variables for builds. | ||
env: | ||
- CGO_ENABLED=0 | ||
- GO111MODULE=on | ||
- GOPROXY=https://proxy.golang.org|direct | ||
- VERSION_PKG=github.com/joelanford/helm-operator/internal/version | ||
|
||
# Hooks to run before any build is run. | ||
before: | ||
hooks: | ||
- go version | grep --quiet "go1\.15\.6" || echo "Go binary version must be 1.15.6" | ||
- go mod download | ||
|
||
# Binary builds. | ||
builds: | ||
# operator-sdk build steps | ||
- id: helm-operator | ||
binary: helm-operator | ||
mod_timestamp: "{{ .CommitTimestamp }}" | ||
asmflags: | ||
- all=-trimpath={{ dir .Env.PWD }} | ||
gcflags: | ||
- all=-trimpath={{ dir .Env.PWD }} | ||
ldflags: | ||
- -s | ||
- -w | ||
- -X {{ .Env.VERSION_PKG }}.ScaffoldVersion={{ .Env.SCAFFOLD_VERSION }} | ||
- -X {{ .Env.VERSION_PKG }}.GitVersion={{ .Env.GIT_VERSION }} | ||
- -X {{ .Env.VERSION_PKG }}.GitCommit={{ .Env.GIT_COMMIT }} | ||
targets: | ||
- darwin_amd64 | ||
- linux_amd64 | ||
- linux_arm64 | ||
- linux_ppc64le | ||
- linux_s390x | ||
|
||
# Use most recent tag and short commit for snapshot version. | ||
snapshot: | ||
name_template: "{{ .Env.GIT_VERSION }}" | ||
|
||
# We don't use archives, so skip creating them. | ||
archives: | ||
- format: binary | ||
name_template: "{{ .Binary }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}" | ||
|
||
checksum: | ||
name_template: "checksums.txt" |
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