Move to Github Action (#105)

* Move to Github Action

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* Move to Github Action

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* fix code generation

* Add release and chart workflows

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* Add release and chart workflows

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* Add release and chart workflows

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* Add release and chart workflows

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* test release and charts

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* test release and charts

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* test release and charts

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* test release and charts

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* test release and charts

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* Fix GHA migration

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* Fix GHA migration

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

---------

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
This commit is contained in:
Hussein Galal
2024-05-21 00:00:47 +03:00
committed by GitHub
parent 0d6bf4922a
commit 3879912b57
8 changed files with 116 additions and 166 deletions

View File

@@ -1,160 +0,0 @@
---
kind: pipeline
name: amd64
platform:
os: linux
arch: amd64
steps:
- name: build
image: rancher/dapper:v0.6.0
environment:
CROSS: 'true'
commands:
- dapper ci
- echo "${DRONE_TAG}-amd64" | sed -e 's/+/-/g' >.tags
volumes:
- name: docker
path: /var/run/docker.sock
when:
ref:
exclude:
- refs/tags/chart-*
- name: package-chart
image: rancher/dapper:v0.6.0
environment:
GITHUB_TOKEN:
from_secret: github_token
commands:
- dapper package-chart
volumes:
- name: docker
path: /var/run/docker.sock
when:
ref:
- refs/tags/chart-*
instance:
- drone-publish.rancher.io
event:
- tag
- name: release-chart
image: plugins/github-release
settings:
api_key:
from_secret: github_token
checksum:
- sha256
checksum_file: CHECKSUMsum.txt
checksum_flatten: true
files:
- "deploy/*"
when:
instance:
- drone-publish.rancher.io
ref:
include:
- refs/tags/chart-*
event:
- tag
- name: index-chart
image: rancher/dapper:v0.6.0
environment:
GITHUB_TOKEN:
from_secret: github_token
commands:
- dapper index-chart
volumes:
- name: docker
path: /var/run/docker.sock
when:
ref:
- refs/tags/chart-*
instance:
- drone-publish.rancher.io
event:
- tag
- name: github_binary_release
image: plugins/github-release
settings:
api_key:
from_secret: github_token
prerelease: true
checksum:
- sha256
checksum_file: CHECKSUMsum-amd64.txt
checksum_flatten: true
files:
- "bin/*"
when:
instance:
- drone-publish.rancher.io
ref:
include:
- refs/head/master
- refs/tags/*
exclude:
- refs/tags/chart-*
event:
- tag
- name: docker-publish
image: plugins/docker
settings:
dockerfile: package/Dockerfile
password:
from_secret: docker_password
repo: "rancher/k3k"
username:
from_secret: docker_username
when:
instance:
- drone-publish.rancher.io
ref:
include:
- refs/head/master
- refs/tags/*
exclude:
- refs/tags/chart-*
event:
- tag
volumes:
- name: docker
host:
path: /var/run/docker.sock
---
kind: pipeline
type: docker
name: manifest
platform:
os: linux
arch: amd64
steps:
- name: push-runtime-manifest
image: plugins/manifest
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
spec: manifest-runtime.tmpl
when:
event:
- tag
instance:
- drone-publish.rancher.io
ref:
include:
- refs/head/master
- refs/tags/*
exclude:
- refs/tags/chart-*
depends_on:
- amd64

22
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,22 @@
on:
push:
branches:
- master
pull_request:
name: Build
permissions:
contents: read
jobs:
build-cross-arch:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cross Arch Build
run: |
make ci
env:
CROSS: "true"

30
.github/workflows/chart.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
on:
push:
tags:
- "chart-*"
name: Chart
permissions:
contents: write
id-token: write
jobs:
chart-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Package Chart
run: |
make package-chart;
- name: Release Chart
uses: softprops/action-gh-release@v2
with:
files: |
deploy/*
- name: Index Chart
run: |
make index-chart

52
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,52 @@
on:
push:
tags:
- "v*"
name: Release
permissions:
contents: write
id-token: write
jobs:
release-cross-arch:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cross Arch Build
run: |
make ci
env:
CROSS: "true"
- name: "Read secrets"
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials password | DOCKER_PASSWORD ;
- name: release binaries
uses: softprops/action-gh-release@v2
with:
files: |
bin/*
- name: Login to Container Registry
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Build container image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: rancher/k3k:${{ github.ref_name }}
file: package/Dockerfile
platforms: linux/amd64

View File

@@ -1,5 +1,4 @@
TARGETS := $(shell ls ops)
.dapper:
@echo Downloading dapper
@curl -sL https://releases.rancher.com/dapper/latest/dapper-$$(uname -s)-$$(uname -m) > .dapper.tmp
@@ -12,4 +11,4 @@ $(TARGETS): .dapper
.DEFAULT_GOAL := default
.PHONY: $(TARGETS)
.PHONY: $(TARGETS)

View File

@@ -2,5 +2,5 @@ apiVersion: v2
name: k3k
description: A Helm chart for K3K
type: application
version: 0.1.4-r1
version: 0.1.5-r5
appVersion: 0.2.0

View File

@@ -4,6 +4,7 @@ set -o errexit
set -o nounset
set -o pipefail
set -x
CODEGEN_GIT_PKG=https://github.com/kubernetes/code-generator.git
git clone --depth 1 ${CODEGEN_GIT_PKG} || true

View File

@@ -5,7 +5,7 @@ if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
fi
COMMIT=$(git rev-parse --short HEAD)
GIT_TAG=${DRONE_TAG:-$(git tag -l --contains HEAD | head -n 1)}
GIT_TAG=${TAG:-$(git tag -l --contains HEAD | head -n 1)}
if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
VERSION=$GIT_TAG
@@ -19,9 +19,15 @@ fi
SUFFIX="-${ARCH}"
TAG=${TAG:-${VERSION}${SUFFIX}}
if [[ $VERSION = "chart*" ]]; then
TAG=${TAG:-${VERSION}}
else
TAG=${TAG:-${VERSION}${SUFFIX}}
fi
REPO=${REPO:-rancher}
if echo $TAG | grep -q dirty; then
if echo $TAG | grep dirty; then
TAG=dev
fi