initial commit
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon Marsh 2023-05-27 12:36:10 +01:00
parent 3f95f94ead
commit 7386b995cd
Signed by: burble
GPG Key ID: E9B4156C1659C079
4 changed files with 93 additions and 1 deletions

29
.drone.yml Normal file
View File

@ -0,0 +1,29 @@
---
kind: pipeline
type: docker
name: docker-build
steps:
- name: docker
image: plugins/docker
settings:
registry: git.burble.dn42
repo: git.burble.dn42/burble.dn42/drone-gitea-pkg-plugin
tags: latest
username: burble
password:
from_secret: TOKEN
---
kind: secret
name: TOKEN
get:
path: burble.dn42/kv/data/drone/git.burble.dn42
name: artifact-token
---
kind: signature
hmac: d6a5d74f6b48bb0108f40808e9b88564a5a808ea8cb30e5c4ce17a59f67f1095
...

5
Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM alpine
RUN apk -Uuv add bash curl
ADD upload.sh /usr/local/bin/upload.sh
RUN chmod +x /usr/local/bin/upload.sh
ENTRYPOINT /usr/local/bin/upload.sh

View File

@ -1,3 +1,16 @@
# drone-gitea-pkg-plugin
A small drone plugin to help with uploading packages to gitea.
[![Build Status](https://ci.burble.dn42/api/badges/burble.dn42/drone-gitea-pkg-plugin/status.svg?ref=refs/heads/main)](https://ci.burble.dn42/burble.dn42/drone-gitea-pkg-plugin)
A small drone plugin to help with uploading packages to gitea.
|setting|desc|default|
|-------|----|-------|
|token|Access token for authentication, may be a filename|(mandatory)|
|artifact|Name of artifact in gitea|(mandatory)|
|package|Package name|(mandatory)|
|version|Package version, may be a filename|(mandatory)|
|user|username for authentication|burble|
|url|base URL of gitea|https://git.burble.dn42/api/packages|
|filename|filename to upload|artifact name|

45
upload.sh Normal file
View File

@ -0,0 +1,45 @@
#!/bin/bash -e
##########################################################################
# check mandatory parameters have been provided
if [ -z "$PLUGIN_TOKEN" ] || [ -z "$PLUGIN_ARTIFACT" ] || \
[ -z "$PLUGIN_PACKAGE" ] || [ -z "$PLUGIN_VERSION" ]
then
echo 'token, artifact, package and version are mandatory settings'
exit 1
fi
# other optional parameters
BASE_URL=${PLUGIN_URL:-https://git.burble.dn42/api/packages}
USER=${PLUGIN_USER:-burble}
FILENAME=${PLUGIN_FILENAME:-$PLUGIN_ARTIFACT}
# version or token could be a filename
function maybe_from_file
{
local var="$1"
if [ -r "$var" ]
then
cat "$var"
else
echo "$var"
fi
}
VERSION=$(maybe_from_file "$PLUGIN_VERSION")
TOKEN=$(maybe_from_file "$PLUGIN_TOKEN")
##########################################################################
# finally do the curl thing to upload the artifact
url=$(printf '%s/%s/generic/%s/%s/%s' \
"$BASE_URL" "$USER" "$PLUGIN_PACKAGE" \
"$VERSION" "$PLUGIN_ARTIFACT")
curl --user "${USER}:${TOKEN}" --upload-file="$FILENAME" "$url"
##########################################################################
# end of file