Colin Powell 2 недель назад
Родитель
Сommit
664a3bc13f
1 измененных файлов с 39 добавлено и 0 удалено
  1. 39 0
      .drone.yml

+ 39 - 0
.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"
+