From 514ef962d080e18b6810dd2a61d02cd7ae2caa89 Mon Sep 17 00:00:00 2001 From: Ardika Bagus Date: Fri, 3 Nov 2023 14:22:52 +0700 Subject: [PATCH] ci: add CI related Signed-off-by: Ardika Bagus --- .github/workflows/release.yaml | 42 +++++++++++++++++++++++++++++++++ .github/workflows/test.yaml | 40 +++++++++++++++++++++++++++++++ .goreleaser.yml | 43 ++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/test.yaml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..30c701a --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,42 @@ +name: Release + +on: + push: + tags: + - "*" + +permissions: + contents: write + +jobs: + test: + uses: ./.github/workflows/test.yaml + + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ^1.21.x + + - name: Get Tag + id: tag + uses: devops-actions/action-get-tag@v1.0.2 + with: + strip_v: true + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE_VERSION: ${{ steps.tag.outputs.tag }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..7e2e884 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,40 @@ +name: Test + +on: + pull_request: + branches: + - main + paths: + - "**/*.go" + + workflow_call: + +jobs: + audit: + name: Auditing the code + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ^1.21.x + + - name: Install make + run: | + sudo apt update -y + sudo apt install make curl git -y + + - name: Run audit + run: | + make lint + make test + + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + file: ./output/coverage.out diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..fc56246 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,43 @@ +version: 1 +before: + hooks: + - go mod tidy + +builds: + - binary: helmize + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + goarm: + - "6" + - "7" + ldflags: + - -X github.com/ardikabs/helmize/cmd.Version={{.Version}} + - -X github.com/ardikabs/helmize/cmd.GitCommit={{.Commit}} + ignore: + - goos: windows + goarch: arm64 + +archives: + - format: binary + +changelog: + filters: + exclude: + - "^Release version" + - "^Merge pull request" + +checksum: + name_template: "checksums.txt" + +release: + github: + owner: ardikabs + name: helmize + name_template: "Version {{.Version}}"