-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Actions for Docker build and Go build
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
Showing
4 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
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
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 }} |
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
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 |
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
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 |