Skip to content

Commit

Permalink
feat(ci): add release pipeline flow
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <[email protected]>

feat(ci): add release pipeline flow

Signed-off-by: Bence Csati <[email protected]>

feat(ci): add release pipeline flow

Signed-off-by: Bence Csati <[email protected]>

feat(ci): add release pipeline flow

Signed-off-by: Bence Csati <[email protected]>

feat(ci): add release pipeline flow

Signed-off-by: Bence Csati <[email protected]>

feat(ci): add release pipeline flow

Signed-off-by: Bence Csati <[email protected]>
  • Loading branch information
csatib02 committed Sep 2, 2024
1 parent e84c8df commit 2edf7ac
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 82 deletions.
131 changes: 131 additions & 0 deletions .github/workflows/artifacts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Artifacts

on:
workflow_call:
inputs:
publish:
description: 'Publish artifacts'
required: true
default: false
type: boolean

jobs:
container-image:
name: Container-Image
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up Cosign
if: ${{ inputs.publish }}
uses: sigstore/[email protected]

- name: Gather build metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
flavor: |
latest = false
tags: |
type=ref,event=branch
type=ref,event=pr,prefix=pr-
type=semver,pattern={{raw}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: ${{ inputs.publish }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Build Docker image
uses: docker/build-push-action@v6
if: ${{ inputs.publish == false }}
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=oci,dest=image.tar

- name: Build and push Docker image
id: build
uses: docker/build-push-action@v6
if: ${{ inputs.publish == true }}
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=image, push=true

- name: Sign image with GitHub OIDC Token
if: ${{ inputs.publish && github.repository_owner == 'csatib02' }}
env:
DIGEST: ${{ inputs.publish && steps.build.outputs.digest }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: Kube-Pod-Autocomplete image
path: image.tar

binary:
name: Binary
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: '.go-version'

- name: Run GoReleaser ~ Build
uses: goreleaser/goreleaser-action@v6
if : ${{ inputs.publish == false }}
with:
distribution: goreleaser
version: '~> v2'
args: release --skip=publish --snapshot

- name: Run GoReleaser ~ Release
uses: goreleaser/goreleaser-action@v6
if: ${{ inputs.publish == true }}
with:
distribution: goreleaser
version: '~> v2'
args: goreleaser release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: Kube-Pod-Autocomplete-Binary
path: build/dist
88 changes: 9 additions & 79 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,85 +56,6 @@ jobs:
with:
version: latest

artifacts-container-image:
name: Artifacts-Container-Image
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Gather build metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
flavor: |
latest = false
tags: |
type=ref,event=branch
type=ref,event=pr,prefix=pr-
type=semver,pattern={{raw}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=oci, dest=image.tar

- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: Kube-Pod-Autocomplete-Image
path: image.tar

artifacts-binary:
name: Artifacts-Binary
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: '.go-version'

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --skip=publish --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: Kube-Pod-Autocomplete-Binary
path: build/dist

e2e-test:
name: E2E Test
runs-on: ubuntu-latest
Expand All @@ -150,3 +71,12 @@ jobs:

- name: Run E2E tests
run: make test-e2e

artifacts:
name: Artifacts
uses: ./.github/workflows/artifacts.yaml
with:
publish: false
permissions:
contents: read
packages: write
17 changes: 17 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+"

jobs:
artifacts:
name: Artifacts
uses: ./.github/workflows/artifacts.yaml
with:
publish: true
permissions:
contents: read
packages: write
1 change: 0 additions & 1 deletion internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func TestLoadConfig(t *testing.T) {
if ttp.wantConfig != nil {
assert.Equal(t, ttp.wantConfig, config, "Unexpected config")
}

})
}
}
3 changes: 2 additions & 1 deletion internal/services/autocomplete/autocomplete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package autocomplete
import (
"testing"

"github.com/csatib02/kube-pod-autocomplete/internal/services/autocomplete/model"
"github.com/stretchr/testify/assert"

"github.com/csatib02/kube-pod-autocomplete/internal/services/autocomplete/model"
)

var serviceTest = Service{}
Expand Down
3 changes: 2 additions & 1 deletion internal/services/autocomplete/filter/filteroptions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package filter
import (
"testing"

"github.com/csatib02/kube-pod-autocomplete/internal/services/autocomplete/model"
"github.com/stretchr/testify/assert"

"github.com/csatib02/kube-pod-autocomplete/internal/services/autocomplete/model"
)

var optionsTest = Options{}
Expand Down

0 comments on commit 2edf7ac

Please sign in to comment.