71 lines
2.4 KiB
YAML
71 lines
2.4 KiB
YAML
name: go-builder
|
|
run-name: go-builder
|
|
on:
|
|
push:
|
|
branches:
|
|
- release/*
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: kcrawford/gobuilder
|
|
container:
|
|
image: kcrawford/gobuilder:0.0.5
|
|
steps:
|
|
- name: Clone
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.LOCAL_SSH_KEY }}" | tr -d '\r' > ~/.ssh/id_ed25519
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
ssh-keyscan git.kcrawford.net >> ~/.ssh/known_hosts
|
|
git clone --branch ${GITHUB_REF_NAME} git@git.kcrawford.net:${{env.GITHUB_REPOSITORY}}.git .
|
|
|
|
- name: Inspect
|
|
run: |
|
|
env
|
|
#while true; do sleep 180; done
|
|
|
|
- name: Create Release
|
|
id: release_num
|
|
run: |
|
|
TAG_NAME=$(basename ${GITHUB_REF_NAME})
|
|
MESSAGE=$(echo ${{ github.event.head_commit.message }})
|
|
|
|
curl -sH "Content-Type: application/json" \
|
|
-H "Authorization: token ${{secrets.REPO_API_RW_TOKEN}}" \
|
|
-X POST ${{env.GITHUB_API_URL}}/repos/${{env.GITHUB_REPOSITORY}}/releases \
|
|
-d '{"body": "Complied Binary Files", "draft": false, "name": "'"${MESSAGE}"'", "prerelease": false, "tag_name": "'"${TAG_NAME}"'" }' \
|
|
--output site.output --write-out %{http_code} > http.response.code 2> error.messages
|
|
|
|
if grep -q 201 http.response.code; then
|
|
id=$(jq '.id' < site.output)
|
|
echo "release_num=${id}" >> $GITHUB_OUTPUT
|
|
else
|
|
jq < site.output
|
|
exit 1
|
|
fi
|
|
|
|
- name: Build and upload
|
|
id: upload
|
|
needs: release_num
|
|
env:
|
|
ID: ${{steps.release_num.outputs.release_num}}
|
|
run: |
|
|
repo=$(basename ${{env.GITHUB_REPOSITORY}})
|
|
go mod download
|
|
for os in linux darwin
|
|
do
|
|
for arch in arm64 amd64
|
|
do
|
|
# Build
|
|
filename=${repo}_${os}_${arch}
|
|
echo "Building for" $filename
|
|
env CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go build -o ${filename}
|
|
|
|
# Upload
|
|
curl -vH 'accept: application/json' \
|
|
-H "Content-Type: multipart/form-data" \
|
|
-H "Authorization: token ${{secrets.REPO_API_RW_TOKEN}}" \
|
|
-X POST ${{env.GITHUB_API_URL}}/repos/${{env.GITHUB_REPOSITORY}}/releases/$ID/assets?name=$filename -F attachment=@"${filename}"
|
|
done
|
|
done
|