Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "CI"

on:
push:
pull_request:
workflow_dispatch:

jobs:
test:
name: CI/CD Test
# https://github.com/actions/virtual-environments/
runs-on: ubuntu-latest
steps:

- name: 🛎️ Checkout
uses: actions/checkout@v3

- name: 🔧 Setup go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'

# Test
- name: 🌡️ Test
run: go run main.go -h
118 changes: 118 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Release

on:
push:
tags:
- "v*.*.*"

jobs:
build:
name: Build
# https://github.com/actions/virtual-environments/
runs-on: ubuntu-latest
steps:

- name: 🛎️ Checkout
uses: actions/checkout@v3

# https://github.com/marketplace/actions/setup-go-environment
- name: 🔧 Setup go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'

- name: 🍳 Build
run: bash build.sh

# Test binary
- name: 🌡️ Test
run: chmod +x k8senv-linux-x86_64 && k8senv-linux-x86_64 -h

# Upload binaries
# https://github.com/marketplace/actions/upload-a-build-artifact
- name: 📤 Upload
uses: actions/upload-artifact@v3
with:
name: k8senv
path: k8senv*
retention-days: 1

test-linux:
name: Test Linux
needs: build
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v3
# Download binaries
# https://github.com/marketplace/actions/download-a-build-artifact
- name: 📥 Download
uses: actions/download-artifact@v3
with:
name: k8senv
# Test binary
- name: 🌡️ Test
run: chmod +x k8senv-linux-x86_64 && ./k8senv-linux-x86_64 -h

test-macos:
name: Test macOS
needs: build
runs-on: macos-latest
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v3
- name: 📥 Download
uses: actions/download-artifact@v3
with:
name: k8senv
# Test binary
- name: 🌡️ Test
run: chmod +x k8senv-macos-x86_64 && ./k8senv-macos-x86_64 -h

pre-release:
if: startsWith(github.ref, 'refs/tags/v0.') || endsWith(github.ref, '-beta') || endsWith(github.ref, '-alpha')
name: Release
needs: [test-linux, test-macos]
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v3
- name: 📥 Download
uses: actions/download-artifact@v3
with:
name: k8senv
# Release, upload files
# https://github.com/marketplace/actions/gh-release
- name: ✨ Release
uses: softprops/action-gh-release@v1
with:
files: |
k8senv-linux-x86_64
k8senv-linux-arm64
k8senv-macos-x86_64
k8senv-macos-arm64
generate_release_notes: true
prerelease: true
release:
if: !startsWith(github.ref, 'refs/tags/v0.') && !endsWith(github.ref, '-beta') && !endsWith(github.ref, '-alpha')
name: Release
needs: [test-linux, test-macos]
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v3
- name: 📥 Download
uses: actions/download-artifact@v3
with:
name: k8senv
# Release, upload files
# https://github.com/marketplace/actions/gh-release
- name: ✨ Release
uses: softprops/action-gh-release@v1
with:
files: |
k8senv-linux-x86_64
k8senv-linux-arm64
k8senv-macos-x86_64
k8senv-macos-arm64
generate_release_notes: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@

# Dependency directories (remove the comment below to include it)
# vendor/
# NOTES.txt
# NOTES.txt
k8senv-*
Binary file removed bin/k8senv
Binary file not shown.
14 changes: 13 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#!/usr/bin/env bash

CGO_ENABLED=0 go build -o bin/k8senv *.go
go version || exit 1

# Linux
echo "Building for Linux OS with AMD64 Arch"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o k8senv-linux-x86_64 main.go && echo "✅ DONE" || echo "❌ FAILED"
echo "Building for Linux OS with ARM64 Arch"
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o k8senv-linux-arm64 main.go && echo "✅ DONE" || echo "❌ FAILED"

# macOS
echo "Building for MacOS with AMD64 Arch"
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o k8senv-macos-x86_64 main.go && echo "✅ DONE" || echo "❌ FAILED"
echo "Building for MacOS with ARM64 Arch"
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o k8senv-macos-arm64 main.go && echo "✅ DONE" || echo "❌ FAILED"