diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..a4413d4 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,39 @@ +kind: pipeline +type: docker +name: build-and-release + +steps: + - name: build + image: golang:1.23 + environment: + CGO_ENABLED: 0 + GOOS: linux + GOARCH: amd64 + commands: + - go mod tidy + - go build -o camcap main.go + + - name: publish-release + image: curlimages/curl + environment: + GOGS_TOKEN: + from_secret: gogs_key + GOGS_API: https://code.unbl.ink/api/v1 + REPO: secstate/camcap + TAG: ${DRONE_TAG:=build-$(date -u +%Y%m%d%H%M%S)} + commands: + # Create release (if it doesn't exist yet) + - | + curl -s -X POST "$GOGS_API/repos/$REPO/releases" \ + -H "Content-Type: application/json" \ + -H "Authorization: token $GOGS_TOKEN" \ + -d "{\"tag_name\": \"$TAG\", \"name\": \"$TAG\", \"draft\": false, \"prerelease\": false}" \ + || echo "Release may already exist" + + # Upload artifact to release + - | + curl -s -X POST "$GOGS_API/repos/$REPO/releases/tags/$TAG/assets" \ + -H "Authorization: token $GOGS_TOKEN" \ + -F "attachment=@camcap" \ + || echo "Upload failed" +