Skip to content

v0.12.2 use softprops/action-gh-release@v2 to create binary releases #41

v0.12.2 use softprops/action-gh-release@v2 to create binary releases

v0.12.2 use softprops/action-gh-release@v2 to create binary releases #41

Workflow file for this run

---
name: CI
on: [push, pull_request]
jobs:
check:
name: Check
runs-on: ubuntu-latest
container: golangci/golangci-lint:v1.60.3
steps:
- uses: actions/checkout@v4
- name: 'Remove .git directory (fix for "error obtaining VCS status: exit status 128")'
run: rm -fr ./.git
- name: Run GolangCI linters
run: golangci-lint run -v
unit-test:
name: Unit test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run Unit tests
run: make ci-test
- uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
file: ./.test_coverage.txt
fail_ci_if_error: false
helm-chart-test:
name: Helm chart test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Execute Helm tests
env:
HELM_VERSION: v3.6.3
run: |
echo "Getting dependencies..."
curl -L https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar -xz && mv ./linux-amd64/helm /usr/local/bin && chmod +x /usr/local/bin/helm
make ci-helm-test
integration-test-cli:
name: Integration test CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Execute tests
run: |
# Build binary.
echo "Building binary..."
make ci-build
sudo mv ./bin/sloth /usr/local/bin/
# Execute integration tests.
echo "Executing integration tests..."
make ci-integration-cli
tagged-release-binaries:
# Only on tags.
if: startsWith(github.ref, 'refs/tags/')
# needs: [check, unit-test, integration-test-cli, integration-test-k8s, helm-chart-test]
needs: [check, unit-test, integration-test-cli, helm-chart-test]
name: Tagged release binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract tag
shell: bash
run: echo "tag=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/tags/}}" >> $GITHUB_OUTPUT
id: extract_tag
- name: Build binaries
env:
VERSION: "${{ steps.extract_tag.outputs.tag }}"
run: |
mkdir -p ./bin
chmod -R 0777 ./bin
make build-all
- name: Generate Changelog
run: "./scripts/read_changelog.sh ${{ steps.extract_tag.outputs.tag }} >> ${{ github.workspace }}-CHANGELOG.txt"
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: "bin/*"
body_path: "${{ github.workspace }}-CHANGELOG.txt"
make_latest: true
fail_on_unmatched_files: true
rolling-release-images:
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
env:
PROD_IMAGE_NAME: ghcr.io/${GITHUB_REPOSITORY}
# needs: [check, unit-test, integration-test-cli, integration-test-k8s, helm-chart-test]
needs: [check, unit-test, integration-test-cli, helm-chart-test]
name: Release images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Docker login
run: docker login ghcr.io -u ${{ github.actor }} -p "${{ secrets.GITHUB_TOKEN }}"
- name: Build and publish docker images
run: make build-publish-image-all
env:
VERSION: "branch-${{ steps.extract_branch.outputs.branch }}"
tagged-release-images:
# Only on tags.
if: startsWith(github.ref, 'refs/tags/')
env:
TAG_IMAGE_LATEST: "true"
PROD_IMAGE_NAME: ghcr.io/${GITHUB_REPOSITORY}
# needs: [check, unit-test, integration-test-cli, integration-test-k8s, helm-chart-test]
needs: [check, unit-test, integration-test-cli, helm-chart-test]
name: Tagged release images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract tag
shell: bash
run: echo "tag=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/tags/}}" >> $GITHUB_OUTPUT
id: extract_tag
- name: Docker login
run: docker login ghcr.io -u ${{ github.actor }} -p "${{ secrets.GITHUB_TOKEN }}"
- name: Build and publish docker images
env:
VERSION: "${{ steps.extract_tag.outputs.tag }}"
run: make build-publish-image-all
# integration-test-k8s:
# name: Integration test Kubernetes
# runs-on: ubuntu-latest
# strategy:
# matrix:
# kubernetes: [1.31.0]
# steps:
# - uses: actions/checkout@v4
#
# - uses: actions/setup-go@v5
# with:
# go-version-file: go.mod
#
# - name: Execute tests
# env:
# KIND_VERSION: v0.24.0
# run: |
# # Get dependencies.
# echo "Installing 'king' & 'kubectl'."
# curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/
# curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v${{ matrix.kubernetes }}/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
#
# # Start cluster.
# echo -e "\nStarting ${{ matrix.kubernetes }} Kubernetes cluster..."
# kind create cluster --image kindest/node:v${{ matrix.kubernetes }}
# kind get kubeconfig > /tmp/test.kubeconfig
#
# # Register CRDs.
# echo -e "\nCreating our CRDs."
# kubectl apply -f ./pkg/kubernetes/gen/crd/
# kubectl apply -f ./test/integration/crd
#
# # Build binary.
# echo -e "\nBuilding binary."
# make ci-build
# sudo mv ./bin/sloth /usr/local/bin/
#
# # Execute integration tests.
# echo -e "\nExecuting integration tests."
# export SLOTH_INTEGRATION_KUBE_CONFIG=/tmp/test.kubeconfig
# make ci-integration-k8s