diff --git a/.github/workflows/binary-build.yml b/.github/workflows/binary-build.yml new file mode 100644 index 0000000..f713669 --- /dev/null +++ b/.github/workflows/binary-build.yml @@ -0,0 +1,28 @@ +name: Docker + +on: + push: + tags: [ 'v*.*.*' ] + workflow_dispatch: + +jobs: + build: + name: Build and Release + runs-on: ubuntu-latest + permissions: + contents: write + 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 diff --git a/.gitignore b/.gitignore index dda27a9..13390a0 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ go.work workspace/* !workspace/.gitkeep + +/build/ diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..691f373 --- /dev/null +++ b/build.sh @@ -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 diff --git a/build/dockonaut b/build/dockonaut deleted file mode 100755 index ca7838d..0000000 Binary files a/build/dockonaut and /dev/null differ