Skip to content

Commit

Permalink
build: release cycle created with github actions
Browse files Browse the repository at this point in the history
Signed-off-by: Batuhan Apaydın <[email protected]>
  • Loading branch information
developer-guy committed Sep 1, 2021
1 parent d1f26c4 commit 6601f2d
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 69 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
59 changes: 59 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# Copyright 2021 The Sigstore Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: "CodeQL"

on:
push:
branches: [ main ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'go' ]

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# .github/workflows/goreleaser.yml
name: release

on:
push:
tags:
- '*'

jobs:
goreleaser:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Docker Login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_PAT }}
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
29 changes: 0 additions & 29 deletions .gitlab-ci.yml

This file was deleted.

42 changes: 15 additions & 27 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project_name: kink

env:
- GO111MODULE=on
- CGO_ENABLED=1
- CGO_ENABLED=0

before:
hooks:
Expand All @@ -17,10 +17,8 @@ builds:
goarch:
- amd64
ldflags:
- "{{ .Env.LDFLAGS }}"
- -s -w -X github.com/Trendyol/kink/cmd.GitVersion={{ .Version }} -X github.com/Trendyol/kink/cmd.gitCommit={{ .ShortCommit }} -X github.com/Trendyol/kink/cmd.buildDate={{ .CommitDate }}
no_unique_dist_dir: true
env:
- CGO_ENABLED=0

- id: darwin-amd64
binary: kink-darwin-{{ .Arch }}
Expand All @@ -30,11 +28,8 @@ builds:
goarch:
- amd64
ldflags:
- "{{ .Env.LDFLAGS }}"
- -s -w -X github.com/Trendyol/kink/cmd.GitVersion={{ .Version }} -X github.com/Trendyol/kink/cmd.gitCommit={{ .ShortCommit }} -X github.com/Trendyol/kink/cmd.buildDate={{ .CommitDate }}
no_unique_dist_dir: true
env:
- CC=o64-clang
- CXX=o64-clang++

- id: windows-amd64
binary: kink-windows-{{ .Arch }}
Expand All @@ -44,30 +39,26 @@ builds:
goarch:
- amd64
ldflags:
- -s -w -X github.com/Trendyol/kink/cmd.GitVersion={{ .Version }} -X github.com/Trendyol/kink/cmd.gitCommit={{ .ShortCommit }} -X github.com/Trendyol/kink/cmd.buildDate={{ .CommitDate }}
- -buildmode=exe
- "{{ .Env.LDFLAGS }}"
no_unique_dist_dir: true
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++

dockers:
- image_templates: [ "registry.trendyol.com/platform/base/poc/kink:{{ .Tag }}" ]
- image_templates: [ "ghcr.io/trendyol/{{ .ProjectName }}:{{ .Version }}-amd64" ]
dockerfile: Dockerfile.goreleaser
goos: linux
goarch: amd64
use: buildx
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://gitlab.com/goreleaser/example
- --label=org.opencontainers.image.source=https://gitlab.com/goreleaser/example
- --label=org.opencontainers.image.url=https://github.com/Trendyol/kink
- --label=org.opencontainers.image.source=https://github.com/Trendyol/kink
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
gomod:
proxy: true
env:
- GOPRIVATE=gitlab.trendyol.com
archives:
- format: tar.gz
replacements:
Expand Down Expand Up @@ -97,12 +88,9 @@ changelog:
- Merge pull request
- Merge branch
# .goreleaser.yml
gitlab_urls:
api: https://gitlab.trendyol.com/api/v4/
download: https://gitlab.trendyol.com
skip_tls_verify: false
release:
gitlab:
owner: ""
name: 8141
disable: false
# Repo in which the release will be created.
# Default is extracted from the origin remote URL or empty if its private hosted.
github:
owner: Trendyol
name: kink
2 changes: 1 addition & 1 deletion Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.trendyol.com/platform/base/image/distroless:static-nonroot-amd64
FROM distroless:static-nonroot-amd64

ADD kink-linux-amd64 /usr/local/bin/kink

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ifeq ($(DIFF), 1)
GIT_TREESTATE = "dirty"
endif

PKG=gitlab.trendyol.com/platform/base/poc/kink/cmd
PKG=github.com/Trendyol/kink/cmd

LDFLAGS="-X $(PKG).GitVersion=$(GIT_VERSION) -X $(PKG).gitCommit=$(GIT_HASH) -X $(PKG).gitTreeState=$(GIT_TREESTATE) -X $(PKG).buildDate=$(BUILD_DATE)"

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ and [Kubernetes](https://gitlab.trendyol.com/platform/base/poc/running-kind-clus
. Then, **_kink_** allows you to create Kubernetes Pods based on Docker images we provide and connect to the cluster
running inside a Pod. In order the connect to the cluster running inside a Pod, **_kink_** does some tricks such as
creating **_Kubernetes Service_**
and [adding node IP](https://gitlab.trendyol.com/platform/base/poc/kink/-/blob/master/cmd/run.go#L145-152) which is
and [adding node IP](https://github.com/Trendyol/kink/-/blob/master/cmd/run.go#L145-152) which is
scheduled on to
the [CERT_SANS](https://gitlab.trendyol.com/platform/base/poc/running-kind-cluster-in-pod-images/-/blob/master/kind-cluster/entrypoint-wrapper.sh#L17)
addresses to make the connection secure over HTTPS.

> **_kink_** uses labels to follow the user activities because we have to provide multi-tenancy support for our users in order to avoid stepping each other toes in same Kubernetes environment,
> you can see the label which we are currently using to achieve uniqueness.
> https://gitlab.trendyol.com/platform/base/poc/kink/-/blob/master/cmd/run.go#L91
> https://github.com/Trendyol/kink/-/blob/master/cmd/run.go#L91
## Installation

If you have Go 1.16+, you can directly install by running:

```shell
export GOPRIVATE="gitlab.trendyol.com"
go install gitlab.trendyol.com/platform/base/poc/kink@latest
go install github.com/Trendyol/kink@latest
```

and the resulting binary will be placed at $HOME/go/bin/kink.
Expand Down
2 changes: 1 addition & 1 deletion cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

"github.com/AlecAivazis/survey/v2"
"github.com/spf13/cobra"
"gitlab.trendyol.com/platform/base/poc/kink/pkg/kubernetes"
"github.com/Trendyol/kink/pkg/kubernetes"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/client-go/kubernetes/typed/core/v1"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"os/user"

"github.com/spf13/cobra"
"gitlab.trendyol.com/platform/base/poc/kink/pkg/kubernetes"
"github.com/Trendyol/kink/pkg/kubernetes"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/listSupportedVersions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/google/go-containerregistry/pkg/crane"
"github.com/spf13/cobra"
"gitlab.trendyol.com/platform/base/poc/kink/pkg/types"
"github.com/Trendyol/kink/pkg/types"
)

// NewListSupportedVersionsCmd represents the listSupportedVersions command
Expand Down
2 changes: 1 addition & 1 deletion cmd/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"fmt"
"github.com/google/go-containerregistry/pkg/name"
"github.com/spf13/cobra"
"gitlab.trendyol.com/platform/base/poc/kink/pkg/kubernetes"
"github.com/Trendyol/kink/pkg/kubernetes"
"io/ioutil"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"log"
Expand Down
4 changes: 2 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import (
"github.com/k0kubun/go-ansi"
"github.com/schollz/progressbar/v3"
"github.com/spf13/cobra"
"gitlab.trendyol.com/platform/base/poc/kink/pkg/kubernetes"
"gitlab.trendyol.com/platform/base/poc/kink/pkg/types"
"github.com/Trendyol/kink/pkg/kubernetes"
"github.com/Trendyol/kink/pkg/types"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module gitlab.trendyol.com/platform/base/poc/kink
module github.com/Trendyol/kink

go 1.17

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/
package main

import "gitlab.trendyol.com/platform/base/poc/kink/cmd"
import "github.com/Trendyol/kink/cmd"

func main() {
cmd.Execute()
Expand Down

0 comments on commit 6601f2d

Please sign in to comment.