-
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.
* Base workflows files created, need to be filled * Add build stage * Fix build stage * Added test CI, makefile test cmd * Modified release stage. * Output go version * Fix tests step * Fix typos * Edit test stage with codecov. * Fix test codecov step * Added coverage badge. * Fix release stage. * Add goreleaser config * Add quay readme badge * Add version command, edit CI * Fixed dockerfile ldflags. * Fix missing docker args * Fix ldflags dockerfile. * Update readme
- Loading branch information
1 parent
3432345
commit 30e96a0
Showing
10 changed files
with
235 additions
and
6 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,22 @@ | ||
name: Build app | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '^1.17.8' | ||
|
||
- name: Show Go version | ||
run: go version | ||
|
||
- name: Check out source code | ||
uses: actions/checkout@v1 | ||
|
||
- name: Build | ||
run: make build |
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,35 @@ | ||
name: Release binaries | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Fetch all tags | ||
run: git fetch --force --tags | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '^1.17.8' | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,57 @@ | ||
name: Release app | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Prepare | ||
id: prep | ||
run: | | ||
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1)) | ||
GIT_COMMIT=$(git rev-parse --short HEAD) | ||
BUILD_DATE=$(date '+%FT%TZ') | ||
echo ::set-output name=version::${VERSION} | ||
echo ::set-output name=git_commit::${GIT_COMMIT} | ||
echo ::set-output name=build_date::${BUILD_DATE} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
with: | ||
platforms: all | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
with: | ||
install: true | ||
version: latest | ||
|
||
- name: Login to Quay | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_USERNAME }} | ||
password: ${{ secrets.QUAY_ROBOT_TOKEN }} | ||
|
||
- name: Build and Push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
build-args: | | ||
VERSION=${{ steps.prep.outputs.version }} | ||
GIT_COMMIT=${{ steps.prep.outputs.git_commit }} | ||
BUILD_DATE=${{ steps.prep.outputs.build_date }} | ||
context: ./ | ||
platforms: linux/amd64,linux/arm/v7,linux/arm64 | ||
push: true | ||
tags: | | ||
quay.io/cguertin14/k3supdater:latest | ||
quay.io/cguertin14/k3supdater:${{ github.sha }} | ||
quay.io/cguertin14/k3supdater:${{ steps.prep.outputs.version }} |
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,32 @@ | ||
name: Test app | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '^1.17.8' | ||
|
||
- name: Show Go version | ||
run: go version | ||
|
||
- name: Check out source code | ||
uses: actions/checkout@v1 | ||
|
||
- name: Run tests | ||
run: make test | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: tests-results | ||
path: coverage.html | ||
retention-days: 5 | ||
|
||
- name: Upload coverage to Codecov | ||
run: bash <(curl -s https://codecov.io/bash) |
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 |
---|---|---|
|
@@ -14,4 +14,5 @@ | |
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
k3supdater | ||
k3supdater | ||
coverage.* |
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,30 @@ | ||
project_name: k3supdater | ||
|
||
before: | ||
hooks: | ||
- go mod download | ||
|
||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
|
||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
|
||
binary: "{{ .ProjectName }}" | ||
|
||
ldflags: | ||
- -X github.com/cguertin14/k3supdater/cmd.BuildDate="{{ .Date }}" | ||
- -X github.com/cguertin14/k3supdater/cmd.GitCommit="{{ .Commit }}" | ||
- -X github.com/cguertin14/k3supdater/cmd.Version="{{ .Version }}" | ||
|
||
|
||
changelog: | ||
sort: asc | ||
|
||
release: | ||
github: | ||
owner: cguertin14 | ||
name: k3supdater |
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 |
---|---|---|
|
@@ -6,11 +6,17 @@ LABEL maintainer="Charles Guertin <[email protected]>" | |
ARG TARGETOS | ||
ARG TARGETARCH | ||
ARG TARGETVARIANT="" | ||
ARG BUILD_DATE | ||
ARG VERSION | ||
ARG GIT_COMMIT | ||
|
||
ENV CGO_ENABLED=0 \ | ||
GOOS=${TARGETOS} \ | ||
GOARCH=${TARGETARCH} \ | ||
GOARM=${TARGETVARIANT} | ||
GOARM=${TARGETVARIANT} \ | ||
BUILD_DATE=${BUILD_DATE} \ | ||
VERSION=${VERSION} \ | ||
GIT_COMMIT=${GIT_COMMIT} | ||
|
||
RUN apk add --no-cache --update ca-certificates make | ||
|
||
|
@@ -20,7 +26,9 @@ COPY go.* ./ | |
RUN go mod download | ||
|
||
COPY . ./ | ||
RUN make build | ||
RUN go build \ | ||
-ldflags "-X github.com/cguertin14/k3supdater/cmd.Version=${VERSION} -X github.com/cguertin14/k3supdater/cmd.BuildDate=${BUILD_DATE} -X github.com/cguertin14/k3supdater/cmd.GitCommit=${GIT_COMMIT}" \ | ||
-o ./k3supdater . | ||
|
||
# Add user & group | ||
RUN addgroup -S updater-group && \ | ||
|
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
// GitCommit | ||
// The latest git commit hash | ||
GitCommit string | ||
|
||
// BuildDate | ||
// The date when the build was made | ||
BuildDate string | ||
|
||
// Version | ||
// The version of the app | ||
Version string | ||
) | ||
|
||
var ( | ||
versionCmd = &cobra.Command{ | ||
Use: "version", | ||
Short: "Show k3supdater's installed version", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Printf( | ||
"Version: %s, GitCommit: %s, BuildDate: %s\n", | ||
Version, GitCommit, BuildDate, | ||
) | ||
}, | ||
} | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(versionCmd) | ||
} |