Skip to content

Commit

Permalink
Add GitHub Actions for Docker build and Go build
Browse files Browse the repository at this point in the history
This commit adds four new GitHub Actions workflows for building Docker images and Go binaries. These workflows are triggered on push events to 'features' branch or when any new tags are created. This will automate the process of building and releasing Docker images and compiled binaries for multiple platforms.

Signed-off-by: Christian Roessner <[email protected]>
  • Loading branch information
Christian Roessner committed May 3, 2024
1 parent ccb96e1 commit 124cede
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build-features.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Development Build
on:
push:
branches:
- features
jobs:
build:
name: Dev Build on ${{ matrix.goos }} / ${{ matrix.goarch }}
runs-on: ubuntu-latest
strategy:
matrix:
goos: [darwin, linux, netbsd, openbsd, windows]
goarch: [amd64, arm64]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22.x
- name: Build project
run: |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
cd server && \
go build -mod=vendor -tags="sonic avx" -ldflags="-s" -o nauthilus-${{ matrix.goos }}-${{ matrix.goarch }}-dev .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nauthilus-${{ matrix.goos }}-${{ matrix.goarch }}-dev-binary
path: server/nauthilus-${{ matrix.goos }}-${{ matrix.goarch }}-dev
34 changes: 34 additions & 0 deletions .github/workflows/build-stable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Build
on:
push:
tags:
- '*'
jobs:
build:
name: Release Build on ${{ matrix.goos }} / ${{ matrix.goarch }}
runs-on: ubuntu-latest
strategy:
matrix:
goos: [darwin, linux, netbsd, openbsd, windows]
goarch: [amd64, arm64]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22.x
- name: Build project
run: |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
cd server && \
go build -mod=vendor -tags="sonic avx" -ldflags="-s" -o nauthilus-${{ matrix.goos }}-${{ matrix.goarch }} .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nauthilus-${{ matrix.goos }}-${{ matrix.goarch }}-binary
path: server/nauthilus-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Release
uses: softprops/action-gh-release@v1
with:
files: server/nauthilus-${{ matrix.goos }}-${{ matrix.goarch }}
28 changes: 28 additions & 0 deletions .github/workflows/docker-features.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Development Docker Build
on:
push:
branches:
- features
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/nauthilus:dev
28 changes: 28 additions & 0 deletions .github/workflows/docker-stable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Production Docker Build
on:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/nauthilus:latest

0 comments on commit 124cede

Please sign in to comment.