.drone.yml 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. kind: pipeline
  2. type: docker
  3. name: build-and-release
  4. steps:
  5. - name: build
  6. image: golang:1.23
  7. environment:
  8. CGO_ENABLED: 0
  9. GOOS: linux
  10. GOARCH: amd64
  11. commands:
  12. - go mod tidy
  13. - go build -o camcap main.go
  14. - name: publish-release
  15. image: curlimages/curl
  16. environment:
  17. GOGS_TOKEN:
  18. from_secret: gogs_key
  19. GOGS_API: https://code.unbl.ink/api/v1
  20. REPO: secstate/camcap
  21. TAG: ${DRONE_TAG:=build-$(date -u +%Y%m%d%H%M%S)}
  22. commands:
  23. # Create release (if it doesn't exist yet)
  24. - |
  25. curl -s -X POST "$GOGS_API/repos/$REPO/releases" \
  26. -H "Content-Type: application/json" \
  27. -H "Authorization: token $GOGS_TOKEN" \
  28. -d "{\"tag_name\": \"$TAG\", \"name\": \"$TAG\", \"draft\": false, \"prerelease\": false}" \
  29. || echo "Release may already exist"
  30. # Upload artifact to release
  31. - |
  32. curl -s -X POST "$GOGS_API/repos/$REPO/releases/tags/$TAG/assets" \
  33. -H "Authorization: token $GOGS_TOKEN" \
  34. -F "attachment=@camcap" \
  35. || echo "Upload failed"