Merge pull request #31 from navilg/29-k8senv-k8senv-use-kubectl-auto-… #16
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-amd64 && ./k8senv-linux-amd64 -h | |
# K8senv version and Tag name must match | |
- name: Test K8senv version | |
run: | | |
#!/usr/bin/env bash | |
chmod +x k8senv-linux-amd64 | |
version=$(./k8senv-linux-amd64 version | cut -d " " -f 2 | jq .K8senv | tr -d "\"") | |
tag=$(echo "${{ github.ref }}" | rev | cut -d "/" -f 1 | rev) | |
if [ "$tag" != "$version" ]; then | |
echo "Tag version and release doesnot match" | |
exit 1 | |
fi | |
# 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-amd64 && ./k8senv-linux-amd64 -h | |
chmod +x test.sh | |
./test.sh | |
# 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 | |
# test-version: | |
# name: Test version | |
# needs: build | |
# runs-on: ubuntu-latest | |
# steps: | |
# # Download binaries | |
# # https://github.com/marketplace/actions/download-a-build-artifact | |
# - name: 📥 Download | |
# uses: actions/download-artifact@v3 | |
# with: | |
# name: k8senv | |
# - run: | | |
# #!/usr/bin/env bash | |
# chmod +x k8senv-linux-amd64 | |
# version=$(./k8senv-linux-amd64 version | cut -d " " -f 2 | jq .K8senv | tr -d "\"") | |
# tag=$(echo "${{ github.ref }}" | rev | cut -d "/" -f 1 | rev) | |
# if [ "$tag" != "$version" ]; then | |
# echo "Tag version and release doesnot match" | |
# exit 1 | |
# fi | |
pre-release: | |
if: startsWith(github.ref, 'refs/tags/v0.') || endsWith(github.ref, '-beta') || endsWith(github.ref, '-alpha') | |
name: Pre-release | |
needs: [test-linux] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🛎️ Checkout | |
uses: actions/checkout@v3 | |
- name: 📥 Download | |
uses: actions/download-artifact@v3 | |
with: | |
name: k8senv | |
- name: Generate checksums | |
run: | | |
sha256sum k8senv-linux-amd64 > CHECKSUM | |
sha256sum k8senv-linux-arm64 >> CHECKSUM | |
# Release, upload files | |
# https://github.com/marketplace/actions/gh-release | |
- name: ✨ Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
k8senv-linux-amd64 | |
k8senv-linux-arm64 | |
CHECKSUM | |
generate_release_notes: true | |
prerelease: true | |
release: | |
if: false == (startsWith(github.ref, 'refs/tags/v0.') || endsWith(github.ref, '-beta') || endsWith(github.ref, '-alpha')) | |
name: Release | |
needs: [test-linux] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🛎️ Checkout | |
uses: actions/checkout@v3 | |
- name: 📥 Download | |
uses: actions/download-artifact@v3 | |
with: | |
name: k8senv | |
- name: Generate checksums | |
run: | | |
sha256sum k8senv-linux-amd64 > CHECKSUM | |
sha256sum k8senv-linux-arm64 >> CHECKSUM | |
# Release, upload files | |
# https://github.com/marketplace/actions/gh-release | |
- name: ✨ Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
k8senv-linux-amd64 | |
k8senv-linux-arm64 | |
CHECKSUM | |
generate_release_notes: true | |
docker-push: | |
name: docker-push | |
needs: [test-linux] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🛎️ Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Genarate Tag | |
run: | | |
#!/usr/bin/env bash | |
tag=$(echo "${{ github.ref }}" | rev | cut -d "/" -f 1 | rev) | |
echo "TAGID=$tag" >> "$GITHUB_OUTPUT" | |
id: generate-tag | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/k8senv:latest,${{ secrets.DOCKERHUB_USERNAME }}/k8senv:${{ steps.generate-tag.outputs.TAGID }} |