Skip to content

Commit

Permalink
feat: add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
thezzisu committed Dec 11, 2023
1 parent ddd1254 commit 02aaee4
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on:
push:
branches: [master]
paths:
- "**/*.go"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: "path/to/go.mod"

- name: Build
run: ./build.sh

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: build
path: build/releases
63 changes: 63 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

BUILD_DIR=$(dirname "$0")/build/releases
mkdir -p $BUILD_DIR
cd $BUILD_DIR

sum="sha256sum"
VERSION=$(git describe --tags --always --dirty)

# AMD64
OSES=(linux darwin windows freebsd)
for os in ${OSES[@]}; do
suffix=""
if [ "$os" == "windows" ]
then
suffix=".exe"
fi
env GOOS=$os GOARCH=amd64 go build -o azukiiro_${os}_amd64${suffix} github.com/zhzxdev/azukiiro
tar -zcf azukiiro-${os}-amd64-$VERSION.tar.gz azukiiro_${os}_amd64${suffix}
rm azukiiro_${os}_amd64${suffix}
HASH=$($sum azukiiro-${os}-amd64-$VERSION.tar.gz)
echo "$HASH azukiiro-${os}-amd64-$VERSION.tar.gz" > azukiiro-$VERSION.sha256
done

# 386
OSES=(linux windows)
for os in ${OSES[@]}; do
suffix=""
if [ "$os" == "windows" ]
then
suffix=".exe"
fi
env GOOS=$os GOARCH=386 go build -o azukiiro_${os}_386${suffix} github.com/zhzxdev/azukiiro
tar -zcf azukiiro-${os}-386-$VERSION.tar.gz azukiiro_${os}_386${suffix}
rm azukiiro_${os}_386${suffix}
HASH=$($sum azukiiro-${os}-386-$VERSION.tar.gz)
echo "$HASH azukiiro-${os}-386-$VERSION.tar.gz" > azukiiro-$VERSION.sha256
done

# ARM
ARMS=(5 6 7)
for v in ${ARMS[@]}; do
env GOOS=linux GOARCH=arm GOARM=$v go build -o azukiiro_linux_arm$v github.com/zhzxdev/azukiiro
tar -zcf azukiiro-linux-arm$v-$VERSION.tar.gz azukiiro_linux_arm$v
rm azukiiro_linux_arm$v
HASH=$($sum azukiiro-linux-arm$v-$VERSION.tar.gz)
echo "$HASH azukiiro-linux-arm$v-$VERSION.tar.gz" > azukiiro-$VERSION.sha256
done

# ARM64
OSES=(linux darwin windows)
for os in ${OSES[@]}; do
suffix=""
if [ "$os" == "windows" ]
then
suffix=".exe"
fi
env GOOS=$os GOARCH=arm64 go build -o azukiiro_${os}_arm64${suffix} github.com/zhzxdev/azukiiro
tar -zcf azukiiro-${os}-arm64-$VERSION.tar.gz azukiiro_${os}_arm64${suffix}
rm azukiiro_${os}_arm64${suffix}
HASH=$($sum azukiiro-${os}-arm64-$VERSION.tar.gz)
echo "$HASH azukiiro-${os}-arm64-$VERSION.tar.gz" > azukiiro-$VERSION.sha256
done

0 comments on commit 02aaee4

Please sign in to comment.