Skip to content

Commit

Permalink
feat: github workflow to build
Browse files Browse the repository at this point in the history
  • Loading branch information
phuchptty committed Jan 6, 2024
1 parent d148686 commit 4167e77
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.5

- name: Get dependencies
run: go mod download

- name: Set permissions
run: chmod +x build-all.sh

- name: Build
run: ./build-all.sh

- name: Create Release
run: ls -la ./build

- uses: ncipollo/release-action@v1
with:
artifacts: ./build/*
27 changes: 27 additions & 0 deletions build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

package=github.com/KMA-Score/kma_score_scanner
package_split=(${package//\// })
package_name=${package_split[-1]}

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

for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}

output_name=$package_name'-'$GOOS'-'$GOARCH

if [ $GOOS = "windows" ]; then
output_name+='.exe'
fi

env GOOS=$GOOS GOARCH=$GOARCH go build -o build/$output_name $package

if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution...'
exit 1
fi
done

0 comments on commit 4167e77

Please sign in to comment.