Skip to content

Commit

Permalink
build/create releases with GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
tmsmr committed Feb 10, 2024
1 parent 72b40e2 commit a09a09b
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 31 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: On Push
name: Tests

on: push
on:
push:
branches:
- '**'
tags-ignore:
- '**'

jobs:
test:
uses: ./.github/workflows/test.yml
uses: ./.github/workflows/tests.yml
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release

on:
push:
tags:
- '*'

jobs:
test:
uses: ./.github/workflows/tests.yml

build:
needs: test
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
- name: Store Binary Name
id: binary-name
run: echo "K4WD_BIN_NAME=k4wd-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }}" >> $GITHUB_OUTPUT
- name: Build Binary
run: CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ${{ steps.binary-name.outputs.K4WD_BIN_NAME }} -ldflags "-s -w" -v ./cmd/k4wd
- name: Store Artifact Name
id: artifact-name
run: echo "K4WD_ART_NAME=k4wd-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.zip' || '.tar.gz' }}" >> $GITHUB_OUTPUT
- name: Create Archive for Linux and MacOS
if: matrix.goos != 'windows'
run: tar -czf ${{ steps.artifact-name.outputs.K4WD_ART_NAME }} ${{ steps.binary-name.outputs.K4WD_BIN_NAME }}
- name: Create Archive for Windows
if: matrix.goos == 'windows'
run: zip ${{ steps.artifact-name.outputs.K4WD_ART_NAME }} ${{ steps.binary-name.outputs.K4WD_BIN_NAME }}
- name: Upload Archive
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact-name.outputs.K4WD_ART_NAME }}
path: ${{ steps.artifact-name.outputs.K4WD_ART_NAME }}

release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download Archives
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Generate Checksums
run: |
cd artifacts
shasum -a 256 * > SHA256SUMS.txt
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/*
28 changes: 0 additions & 28 deletions .github/workflows/test.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
on:
workflow_call:

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
- name: Test k4wd (unit tests)
run: go test -v ./...
integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
- name: Build k4wd
run: go build ./cmd/k4wd
- name: Start k3d
uses: AbsaOSS/k3d-action@v2
with:
cluster-name: k4wd
- name: Apply testing manifests
run: |
sleep 10
kubectl config use-context k3d-k4wd
kubectl apply -k test/integration
kubectl -n k4wd wait --for=condition=Ready pods --all
sleep 10
- name: Test k4wd (including integration tests)
run: K4WD_INTEGRATION_TESTS=true go test -v ./...

0 comments on commit a09a09b

Please sign in to comment.