2024-04-03 21:09:35 +00:00
|
|
|
name: go-builder
|
|
|
|
run-name: go-builder
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- release/*
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2024-04-05 23:29:42 +00:00
|
|
|
runs-on: kcrawford/gobuilder
|
2024-04-03 21:09:35 +00:00
|
|
|
container:
|
2024-04-05 23:29:42 +00:00
|
|
|
image: kcrawford/gobuilder:0.0.5
|
2024-04-03 21:09:35 +00:00
|
|
|
steps:
|
|
|
|
- name: Clone
|
|
|
|
run: |
|
|
|
|
mkdir -p ~/.ssh
|
2024-04-11 23:39:32 +00:00
|
|
|
echo "${{ secrets.LOCAL_SSH_KEY }}" | tr -d '\r' > ~/.ssh/id_ed25519
|
2024-04-03 21:09:35 +00:00
|
|
|
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
|