Skip to content

Commit

Permalink
Added build option and release section
Browse files Browse the repository at this point in the history
  • Loading branch information
akrami committed Jul 11, 2024
1 parent 766ad56 commit 795a1dd
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/binary-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Docker

on:
push:
tags: [ 'v*.*.*' ]
workflow_dispatch:

jobs:
build:
name: Build and Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.22
- name: Build Executables
run: ./build.sh ${{ github.event.release.tag_name }}
- name: Upload to Releases
uses: svenstaro/upload-release-action@master
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
file: ./build/dockonaut_*
file_glob: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ go.work

workspace/*
!workspace/.gitkeep

/build/
30 changes: 30 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

platforms=(
"darwin/amd64"
"darwin/arm64"
"linux/386"
"linux/amd64"
"linux/arm"
"linux/arm64"
"windows/386"
"windows/amd64"
)

[[ -d build ]] || mkdir build
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name=dockonaut'_'$GOOS'-'$GOARCH
if [ $GOOS = "windows" ]; then
output_name+='.exe'
fi

env GOOS=$GOOS GOARCH=$GOARCH go build -o build/$output_name cmd/dockonaut/main.go
if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution...'
exit 1
fi
done
Binary file removed build/dockonaut
Binary file not shown.

0 comments on commit 795a1dd

Please sign in to comment.