diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d8b4590 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..959d29f --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/.gitignore b/.gitignore index 876a8c7..4eb8b10 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ # Dependency directories (remove the comment below to include it) # vendor/ -# NOTES.txt \ No newline at end of file +# NOTES.txt +k8senv-* \ No newline at end of file diff --git a/bin/k8senv b/bin/k8senv deleted file mode 100755 index cd5c945..0000000 Binary files a/bin/k8senv and /dev/null differ diff --git a/build.sh b/build.sh index f6fcd9a..2dbfe70 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,15 @@ #!/usr/bin/env bash -CGO_ENABLED=0 go build -o bin/k8senv *.go \ No newline at end of file +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" \ No newline at end of file