.drone.yml 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 build -o camcap camcap.go
  13. - name: publish-release
  14. image: curlimages/curl
  15. environment:
  16. GOGS_TOKEN:
  17. from_secret: gogs_key
  18. GOGS_API: https://code.unbl.ink/api/v1
  19. REPO: secstate/camcap
  20. TAG: ${DRONE_TAG:=build-$(date -u +%Y%m%d%H%M%S)}
  21. commands:
  22. # Create release (if it doesn't exist yet)
  23. - |
  24. curl -s -X POST "$GOGS_API/repos/$REPO/releases" \
  25. -H "Content-Type: application/json" \
  26. -H "Authorization: token $GOGS_TOKEN" \
  27. -d "{\"tag_name\": \"$TAG\", \"name\": \"$TAG\", \"draft\": false, \"prerelease\": false}" \
  28. || echo "Release may already exist"
  29. # Upload artifact to release
  30. - |
  31. curl -s -X POST "$GOGS_API/repos/$REPO/releases/tags/$TAG/assets" \
  32. -H "Authorization: token $GOGS_TOKEN" \
  33. -F "attachment=@camcap" \
  34. || echo "Upload failed"