mirror of
https://github.com/drone-plugins/drone-gitea-release.git
synced 2026-06-16 14:50:24 +08:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9cfb4b925b | |||
| 2087ad8457 | |||
| a3bc2214f7 | |||
| acd080b23a | |||
| 1b3c06c50a | |||
| a7e89f3581 | |||
| 902f8dffe6 | |||
| a109067c06 | |||
| 55aefa6b57 | |||
| b433d4222a | |||
| 238fd28d8e | |||
| ca63c2ddea | |||
| aa19f3b5cd | |||
| d03c8d5b36 | |||
| fc7176bdfc | |||
| b656d40539 | |||
| 1def48823c | |||
| 39b569dc52 | |||
| ad43516f45 | |||
| 4a158980a4 | |||
| f67c35dbc3 | |||
| fb94247a08 | |||
| 41ecb137d0 | |||
| f7bcb7bf0c | |||
| fd61899cae | |||
| fd55e825a2 | |||
| 60da67ff16 | |||
| a6a27ed08b | |||
| 1d0b5301df | |||
| e50d44024d | |||
| 75f4ffd56f | |||
| ea7b7f5dde | |||
| dfc6b9e80e | |||
| f8305bbc00 | |||
| 4937a3d7c3 | |||
| bb5156853a | |||
| c2bec00afd | |||
| f8a7014264 |
@@ -1,68 +0,0 @@
|
||||
version: '{build}'
|
||||
image: 'Visual Studio 2017'
|
||||
platform: 'x64'
|
||||
|
||||
clone_folder: 'c:\gopath\src\github.com\drone-plugins\drone-gitea-release'
|
||||
max_jobs: 1
|
||||
|
||||
environment:
|
||||
GOPATH: c:\gopath
|
||||
DOCKER_USERNAME:
|
||||
secure: '4YzzahbEiMZQJpOCOd1LAw=='
|
||||
DOCKER_PASSWORD:
|
||||
secure: 'VqO/G3Zfslu6zSLdwHKO+Q=='
|
||||
|
||||
install:
|
||||
- ps: |
|
||||
docker version
|
||||
go version
|
||||
- ps: |
|
||||
$env:Path = "c:\gopath\bin;$env:Path"
|
||||
|
||||
build_script:
|
||||
- ps: |
|
||||
go get -u github.com/golang/dep/cmd/dep
|
||||
dep ensure
|
||||
|
||||
if ( $env:APPVEYOR_REPO_TAG -eq 'false' ) {
|
||||
go build -ldflags "-X main.build=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-gitea-release.exe
|
||||
} else {
|
||||
$version = $env:APPVEYOR_REPO_TAG_NAME.substring(1)
|
||||
go build -ldflags "-X main.version=$version -X main.build=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-gitea-release.exe
|
||||
}
|
||||
|
||||
docker pull microsoft/nanoserver:10.0.14393.1593
|
||||
docker build -f Dockerfile.windows -t plugins/gitea-release:windows-amd64 .
|
||||
|
||||
test_script:
|
||||
- ps: |
|
||||
docker run --rm plugins/gitea-release:windows-amd64 --version
|
||||
|
||||
deploy_script:
|
||||
- ps: |
|
||||
$ErrorActionPreference = 'Stop';
|
||||
|
||||
if ( $env:APPVEYOR_PULL_REQUEST_NUMBER ) {
|
||||
Write-Host Nothing to deploy.
|
||||
} else {
|
||||
docker login --username $env:DOCKER_USERNAME --password $env:DOCKER_PASSWORD
|
||||
|
||||
if ( $env:APPVEYOR_REPO_TAG -eq 'true' ) {
|
||||
$major,$minor,$patch = $env:APPVEYOR_REPO_TAG_NAME.substring(1).split('.')
|
||||
|
||||
docker push plugins/gitea-release:windows-amd64
|
||||
|
||||
docker tag plugins/gitea-release:windows-amd64 plugins/gitea-release:$major.$minor.$patch-windows-amd64
|
||||
docker push plugins/gitea-release:$major.$minor.$patch-windows-amd64
|
||||
|
||||
docker tag plugins/gitea-release:windows-amd64 plugins/gitea-release:$major.$minor-windows-amd64
|
||||
docker push plugins/gitea-release:$major.$minor-windows-amd64
|
||||
|
||||
docker tag plugins/gitea-release:windows-amd64 plugins/gitea-release:$major-windows-amd64
|
||||
docker push plugins/gitea-release:$major-windows-amd64
|
||||
} else {
|
||||
if ( $env:APPVEYOR_REPO_BRANCH -eq 'master' ) {
|
||||
docker push plugins/gitea-release:windows-amd64
|
||||
}
|
||||
}
|
||||
}
|
||||
+342
@@ -0,0 +1,342 @@
|
||||
def main(ctx):
|
||||
before = testing(ctx)
|
||||
|
||||
stages = [
|
||||
linux(ctx, "amd64"),
|
||||
linux(ctx, "arm64"),
|
||||
linux(ctx, "arm"),
|
||||
windows(ctx, "1909"),
|
||||
windows(ctx, "1903"),
|
||||
windows(ctx, "1809"),
|
||||
]
|
||||
|
||||
after = manifest(ctx) + gitter(ctx)
|
||||
|
||||
for b in before:
|
||||
for s in stages:
|
||||
s["depends_on"].append(b["name"])
|
||||
|
||||
for s in stages:
|
||||
for a in after:
|
||||
a["depends_on"].append(s["name"])
|
||||
|
||||
return before + stages + after
|
||||
|
||||
def testing(ctx):
|
||||
return [{
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "testing",
|
||||
"platform": {
|
||||
"os": "linux",
|
||||
"arch": "amd64",
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"name": "staticcheck",
|
||||
"image": "golang:1.15",
|
||||
"pull": "always",
|
||||
"commands": [
|
||||
"go run honnef.co/go/tools/cmd/staticcheck ./...",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/go",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "lint",
|
||||
"image": "golang:1.15",
|
||||
"commands": [
|
||||
"go run golang.org/x/lint/golint -set_exit_status ./...",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/go",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "vet",
|
||||
"image": "golang:1.15",
|
||||
"commands": [
|
||||
"go vet ./...",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/go",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "test",
|
||||
"image": "golang:1.15",
|
||||
"commands": [
|
||||
"go test -cover ./...",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/go",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"temp": {},
|
||||
},
|
||||
],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/**",
|
||||
"refs/pull/**",
|
||||
],
|
||||
},
|
||||
}]
|
||||
|
||||
def linux(ctx, arch):
|
||||
if ctx.build.event == "tag":
|
||||
build = [
|
||||
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-gitea-release ./cmd/drone-gitea-release' % (ctx.build.ref.replace("refs/tags/v", ""), arch),
|
||||
]
|
||||
else:
|
||||
build = [
|
||||
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-gitea-release ./cmd/drone-gitea-release' % (ctx.build.commit[0:8], arch),
|
||||
]
|
||||
|
||||
steps = [
|
||||
{
|
||||
"name": "environment",
|
||||
"image": "golang:1.15",
|
||||
"pull": "always",
|
||||
"environment": {
|
||||
"CGO_ENABLED": "0",
|
||||
},
|
||||
"commands": [
|
||||
"go version",
|
||||
"go env",
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "build",
|
||||
"image": "golang:1.15",
|
||||
"environment": {
|
||||
"CGO_ENABLED": "0",
|
||||
},
|
||||
"commands": build,
|
||||
},
|
||||
{
|
||||
"name": "executable",
|
||||
"image": "golang:1.15",
|
||||
"commands": [
|
||||
"./release/linux/%s/drone-gitea-release --help" % (arch),
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
if ctx.build.event != "pull_request":
|
||||
steps.append({
|
||||
"name": "docker",
|
||||
"image": "plugins/docker",
|
||||
"settings": {
|
||||
"dockerfile": "docker/Dockerfile.linux.%s" % (arch),
|
||||
"repo": "plugins/gitea-release",
|
||||
"username": {
|
||||
"from_secret": "docker_username",
|
||||
},
|
||||
"password": {
|
||||
"from_secret": "docker_password",
|
||||
},
|
||||
"auto_tag": True,
|
||||
"auto_tag_suffix": "linux-%s" % (arch),
|
||||
},
|
||||
})
|
||||
|
||||
return {
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "linux-%s" % (arch),
|
||||
"platform": {
|
||||
"os": "linux",
|
||||
"arch": arch,
|
||||
},
|
||||
"steps": steps,
|
||||
"depends_on": [],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/**",
|
||||
"refs/pull/**",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
def windows(ctx, version):
|
||||
docker = [
|
||||
"echo $env:PASSWORD | docker login --username $env:USERNAME --password-stdin",
|
||||
]
|
||||
|
||||
if ctx.build.event == "tag":
|
||||
build = [
|
||||
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe ./cmd/drone-gitea-release' % (ctx.build.ref.replace("refs/tags/v", "")),
|
||||
]
|
||||
|
||||
docker = docker + [
|
||||
"docker build --pull -f docker/Dockerfile.windows.%s -t plugins/gitea-release:%s-windows-%s-amd64 ." % (version, ctx.build.ref.replace("refs/tags/v", ""), version),
|
||||
"docker run --rm plugins/gitea-release:%s-windows-%s-amd64 --help" % (ctx.build.ref.replace("refs/tags/v", ""), version),
|
||||
"docker push plugins/gitea-release:%s-windows-%s-amd64" % (ctx.build.ref.replace("refs/tags/v", ""), version),
|
||||
]
|
||||
else:
|
||||
build = [
|
||||
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe ./cmd/drone-gitea-release' % (ctx.build.commit[0:8]),
|
||||
]
|
||||
|
||||
docker = docker + [
|
||||
"docker build --pull -f docker/Dockerfile.windows.%s -t plugins/gitea-release:windows-%s-amd64 ." % (version, version),
|
||||
"docker run --rm plugins/gitea-release:windows-%s-amd64 --help" % (version),
|
||||
"docker push plugins/gitea-release:windows-%s-amd64" % (version),
|
||||
]
|
||||
|
||||
return {
|
||||
"kind": "pipeline",
|
||||
"type": "ssh",
|
||||
"name": "windows-%s" % (version),
|
||||
"platform": {
|
||||
"os": "windows",
|
||||
},
|
||||
"server": {
|
||||
"host": {
|
||||
"from_secret": "windows_server_%s" % (version),
|
||||
},
|
||||
"user": {
|
||||
"from_secret": "windows_username",
|
||||
},
|
||||
"password": {
|
||||
"from_secret": "windows_password",
|
||||
},
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"name": "environment",
|
||||
"environment": {
|
||||
"CGO_ENABLED": "0",
|
||||
},
|
||||
"commands": [
|
||||
"go version",
|
||||
"go env",
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "build",
|
||||
"environment": {
|
||||
"CGO_ENABLED": "0",
|
||||
},
|
||||
"commands": build,
|
||||
},
|
||||
{
|
||||
"name": "executable",
|
||||
"commands": [
|
||||
"./release/windows/amd64/drone-gitea-release.exe --help",
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "docker",
|
||||
"environment": {
|
||||
"USERNAME": {
|
||||
"from_secret": "docker_username",
|
||||
},
|
||||
"PASSWORD": {
|
||||
"from_secret": "docker_password",
|
||||
},
|
||||
},
|
||||
"commands": docker,
|
||||
},
|
||||
],
|
||||
"depends_on": [],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/**",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
def manifest(ctx):
|
||||
return [{
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "manifest",
|
||||
"steps": [
|
||||
{
|
||||
"name": "manifest",
|
||||
"image": "plugins/manifest",
|
||||
"settings": {
|
||||
"auto_tag": "true",
|
||||
"username": {
|
||||
"from_secret": "docker_username",
|
||||
},
|
||||
"password": {
|
||||
"from_secret": "docker_password",
|
||||
},
|
||||
"spec": "docker/manifest.tmpl",
|
||||
"ignore_missing": "true",
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "microbadger",
|
||||
"image": "plugins/webhook",
|
||||
"settings": {
|
||||
"urls": {
|
||||
"from_secret": "microbadger_url",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"depends_on": [],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/**",
|
||||
],
|
||||
},
|
||||
}]
|
||||
|
||||
def gitter(ctx):
|
||||
return [{
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "gitter",
|
||||
"clone": {
|
||||
"disable": True,
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"name": "gitter",
|
||||
"image": "plugins/gitter",
|
||||
"settings": {
|
||||
"webhook": {
|
||||
"from_secret": "gitter_webhook",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"depends_on": [
|
||||
"manifest",
|
||||
],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/**",
|
||||
],
|
||||
"status": [
|
||||
"failure",
|
||||
],
|
||||
},
|
||||
}]
|
||||
-148
@@ -1,148 +0,0 @@
|
||||
workspace:
|
||||
base: /go
|
||||
path: src/github.com/drone-plugins/drone-gitea-release
|
||||
|
||||
pipeline:
|
||||
deps:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
commands:
|
||||
- go get -u github.com/golang/dep/cmd/dep
|
||||
- dep ensure
|
||||
|
||||
test:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
commands:
|
||||
- go vet ./...
|
||||
- go test -cover ./...
|
||||
|
||||
build_linux_amd64:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
group: build
|
||||
environment:
|
||||
- GOOS=linux
|
||||
- GOARCH=amd64
|
||||
- CGO_ENABLED=0
|
||||
commands:
|
||||
- |
|
||||
if test "${DRONE_TAG}" = ""; then
|
||||
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-gitea-release
|
||||
else
|
||||
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-gitea-release
|
||||
fi
|
||||
|
||||
build_linux_i386:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
group: build
|
||||
environment:
|
||||
- GOOS=linux
|
||||
- GOARCH=386
|
||||
- CGO_ENABLED=0
|
||||
commands:
|
||||
- |
|
||||
if test "${DRONE_TAG}" = ""; then
|
||||
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/i386/drone-gitea-release
|
||||
else
|
||||
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/i386/drone-gitea-release
|
||||
fi
|
||||
|
||||
build_linux_arm64:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
group: build
|
||||
environment:
|
||||
- GOOS=linux
|
||||
- GOARCH=arm64
|
||||
- CGO_ENABLED=0
|
||||
commands:
|
||||
- |
|
||||
if test "${DRONE_TAG}" = ""; then
|
||||
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-gitea-release
|
||||
else
|
||||
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-gitea-release
|
||||
fi
|
||||
|
||||
build_linux_arm:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
group: build
|
||||
environment:
|
||||
- GOOS=linux
|
||||
- GOARCH=arm
|
||||
- CGO_ENABLED=0
|
||||
- GOARM=7
|
||||
commands:
|
||||
- |
|
||||
if test "${DRONE_TAG}" = ""; then
|
||||
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-gitea-release
|
||||
else
|
||||
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-gitea-release
|
||||
fi
|
||||
|
||||
publish_linux_amd64:
|
||||
image: plugins/docker:17.12
|
||||
pull: true
|
||||
secrets: [ docker_username, docker_password ]
|
||||
group: docker
|
||||
repo: plugins/gitea-release
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64
|
||||
dockerfile: Dockerfile
|
||||
when:
|
||||
event: [ push, tag ]
|
||||
|
||||
publish_linux_i386:
|
||||
image: plugins/docker:17.12
|
||||
pull: true
|
||||
secrets: [ docker_username, docker_password ]
|
||||
group: docker
|
||||
repo: plugins/gitea-release
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-i386
|
||||
dockerfile: Dockerfile.i386
|
||||
when:
|
||||
event: [ push, tag ]
|
||||
|
||||
publish_linux_arm64:
|
||||
image: plugins/docker:17.12
|
||||
pull: true
|
||||
secrets: [ docker_username, docker_password ]
|
||||
group: docker
|
||||
repo: plugins/gitea-release
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
dockerfile: Dockerfile.arm64
|
||||
when:
|
||||
event: [ push, tag ]
|
||||
|
||||
publish_linux_arm:
|
||||
image: plugins/docker:17.12
|
||||
pull: true
|
||||
secrets: [ docker_username, docker_password ]
|
||||
group: docker
|
||||
repo: plugins/gitea-release
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm
|
||||
dockerfile: Dockerfile.arm
|
||||
when:
|
||||
event: [ push, tag ]
|
||||
|
||||
manifests:
|
||||
image: plugins/manifest:1
|
||||
pull: true
|
||||
secrets: [ docker_username, docker_password ]
|
||||
spec: manifest.tmpl
|
||||
auto_tag: true
|
||||
ignore_missing: true
|
||||
when:
|
||||
event: [ push, tag ]
|
||||
|
||||
microbadger:
|
||||
image: plugins/webhook:1
|
||||
pull: true
|
||||
secrets: [ webhook_url ]
|
||||
when:
|
||||
status: [ success ]
|
||||
@@ -0,0 +1,9 @@
|
||||
<!-- PLEASE READ BEFORE DELETING
|
||||
|
||||
Bugs or Issues? Due to the high number of false positive issues we receive,
|
||||
please do not create a GitHub issue until you have discussed and verified
|
||||
with community support at:
|
||||
|
||||
https://discourse.drone.io/
|
||||
|
||||
-->
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
repository:
|
||||
name: drone-gitea-release
|
||||
description: Drone plugin for creating and tagging GitHub releases
|
||||
homepage: http://plugins.drone.io/drone-plugins/drone-gitea-release
|
||||
topics: drone, drone-plugin
|
||||
|
||||
private: false
|
||||
has_issues: true
|
||||
has_wiki: false
|
||||
has_downloads: false
|
||||
|
||||
default_branch: master
|
||||
|
||||
allow_squash_merge: true
|
||||
allow_merge_commit: true
|
||||
allow_rebase_merge: true
|
||||
|
||||
labels:
|
||||
- name: bug
|
||||
color: d73a4a
|
||||
description: Something isn't working
|
||||
- name: duplicate
|
||||
color: cfd3d7
|
||||
description: This issue or pull request already exists
|
||||
- name: enhancement
|
||||
color: a2eeef
|
||||
description: New feature or request
|
||||
- name: good first issue
|
||||
color: 7057ff
|
||||
description: Good for newcomers
|
||||
- name: help wanted
|
||||
color: 008672
|
||||
description: Extra attention is needed
|
||||
- name: invalid
|
||||
color: e4e669
|
||||
description: This doesn't seem right
|
||||
- name: question
|
||||
color: d876e3
|
||||
description: Further information is requested
|
||||
- name: renovate
|
||||
color: e99695
|
||||
description: Automated action from Renovate
|
||||
- name: wontfix
|
||||
color: ffffff
|
||||
description: This will not be worked on
|
||||
|
||||
teams:
|
||||
- name: Admins
|
||||
permission: admin
|
||||
- name: Captain
|
||||
permission: admin
|
||||
- name: Maintainers
|
||||
permission: push
|
||||
|
||||
branches:
|
||||
- name: master
|
||||
protection:
|
||||
required_pull_request_reviews:
|
||||
required_approving_review_count: 1
|
||||
dismiss_stale_reviews: false
|
||||
require_code_owner_reviews: false
|
||||
dismissal_restrictions:
|
||||
teams:
|
||||
- Admins
|
||||
- Captain
|
||||
required_status_checks:
|
||||
strict: true
|
||||
contexts:
|
||||
- continuous-integration/drone/pr
|
||||
enforce_admins: false
|
||||
restrictions:
|
||||
apps:
|
||||
- renovate
|
||||
users: []
|
||||
teams:
|
||||
- Admins
|
||||
- Maintainers
|
||||
+3
-28
@@ -1,30 +1,5 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
|
||||
release/
|
||||
vendor/
|
||||
/release/
|
||||
/drone-gitea-release*
|
||||
|
||||
coverage.out
|
||||
drone-gitea-release
|
||||
.drone.yml
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
FROM plugins/base:multiarch
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
|
||||
org.label-schema.name="Drone Gitea Release" \
|
||||
org.label-schema.vendor="Drone.IO Community" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/linux/i386/drone-gitea-release /bin/
|
||||
ENTRYPOINT ["/bin/drone-gitea-release"]
|
||||
@@ -1,12 +0,0 @@
|
||||
# escape=`
|
||||
FROM microsoft/nanoserver:10.0.14393.1593
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Gitea Release" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
ADD release\drone-gitea-release.exe c:\drone-gitea-release.exe
|
||||
ENTRYPOINT [ "c:\\drone-gitea-release.exe" ]
|
||||
Generated
-48
@@ -1,48 +0,0 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "code.gitea.io/sdk"
|
||||
packages = ["gitea"]
|
||||
revision = "fa91af7569e6ba34bfa382109847cbc79c3fdad8"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/Sirupsen/logrus"
|
||||
packages = ["."]
|
||||
revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc"
|
||||
version = "v1.0.5"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/joho/godotenv"
|
||||
packages = ["."]
|
||||
revision = "a79fa1e548e2c689c241d10173efd51e5d689d5b"
|
||||
version = "v1.2.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/urfave/cli"
|
||||
packages = ["."]
|
||||
revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1"
|
||||
version = "v1.20.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/crypto"
|
||||
packages = ["ssh/terminal"]
|
||||
revision = "21652f85b0fdddb6c2b6b77a5beca5c5a908174a"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/sys"
|
||||
packages = [
|
||||
"unix",
|
||||
"windows"
|
||||
]
|
||||
revision = "cc7307a45468e49eaf2997c890f14aa03a26917b"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "7cb00c5086c5910b3f5a952158b3c99e8a3c41acb235f0591f74545909a00d34"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "code.gitea.io/sdk"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/Sirupsen/logrus"
|
||||
version = "1.0.5"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/joho/godotenv"
|
||||
version = "1.2.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/urfave/cli"
|
||||
version = "1.20.0"
|
||||
|
||||
[prune]
|
||||
go-tests = true
|
||||
unused-packages = true
|
||||
@@ -1,16 +1,50 @@
|
||||
# drone-gitea-release
|
||||
|
||||
[](https://beta.drone.io/drone-plugins/drone-gitea-release)
|
||||
[](http://cloud.drone.io/drone-plugins/drone-gitea-release)
|
||||
[](https://gitter.im/drone/drone)
|
||||
[](https://discourse.drone.io)
|
||||
[](https://stackoverflow.com/questions/tagged/drone.io)
|
||||
[](https://microbadger.com/images/plugins/gitea-release "Get your own image badge on microbadger.com")
|
||||
[](http://godoc.org/github.com/drone-plugins/drone-gitea-release)
|
||||
[](https://goreportcard.com/report/github.com/drone-plugins/drone-gitea-release)
|
||||
|
||||
Drone plugin to publish files and artifacts to Gitea Release.
|
||||
Drone plugin to publish files and artifacts to Gitea release. For the usage information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/drone-plugins/drone-gitea-release/).
|
||||
|
||||
## Build
|
||||
|
||||
Build the binary with the following commands:
|
||||
Build the binary with the following command:
|
||||
|
||||
```console
|
||||
export GOOS=linux
|
||||
export GOARCH=amd64
|
||||
export CGO_ENABLED=0
|
||||
export GO111MODULE=on
|
||||
|
||||
go build -v -a -tags netgo -o release/linux/amd64/drone-gitea-release
|
||||
```
|
||||
|
||||
## Docker
|
||||
|
||||
Build the Docker image with the following command:
|
||||
|
||||
```console
|
||||
docker build \
|
||||
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
|
||||
--file docker/Dockerfile.linux.amd64 --tag plugins/gitea-release .
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```console
|
||||
docker run --rm \
|
||||
-e PLUGIN_BASE_URL=https://try.gitea.io \
|
||||
-e PLUGIN_API_KEY=your-api-key \
|
||||
-e PLUGIN_FILES=build/* \
|
||||
-e DRONE_REPO_OWNER=gitea \
|
||||
-e DRONE_REPO_NAME=test \
|
||||
-e DRONE_BUILD_EVENT=tag \
|
||||
-v $(pwd):$(pwd) \
|
||||
-w $(pwd) \
|
||||
plugins/gitea-release
|
||||
```
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-gitea-release
|
||||
docker build --rm -t plugins/gitea-release .
|
||||
```
|
||||
@@ -0,0 +1,69 @@
|
||||
// Copyright (c) 2021, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/drone-plugins/drone-gitea-release/plugin"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// settingsFlags has the cli.Flags for the plugin.Settings.
|
||||
func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
|
||||
&cli.StringFlag{
|
||||
Name: "api-key",
|
||||
Usage: "api key to access gitea api",
|
||||
EnvVars: []string{"PLUGIN_API_KEY", "GITEA_RELEASE_API_KEY", "GITEA_TOKEN"},
|
||||
Destination: &settings.APIKey,
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "files",
|
||||
Usage: "list of files to upload",
|
||||
EnvVars: []string{"PLUGIN_FILES", "GITEA_RELEASE_FILES"},
|
||||
Destination: &settings.Files,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "file-exists",
|
||||
Value: "overwrite",
|
||||
Usage: "what to do if file already exist",
|
||||
EnvVars: []string{"PLUGIN_FILE_EXISTS", "GITEA_RELEASE_FILE_EXISTS"},
|
||||
Destination: &settings.FileExists,
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "checksum",
|
||||
Usage: "generate specific checksums",
|
||||
EnvVars: []string{"PLUGIN_CHECKSUM", "GITEA_RELEASE_CHECKSUM"},
|
||||
Destination: &settings.Checksum},
|
||||
&cli.BoolFlag{
|
||||
Name: "draft",
|
||||
Usage: "create a draft release",
|
||||
EnvVars: []string{"PLUGIN_DRAFT", "GITEA_RELEASE_DRAFT"},
|
||||
Destination: &settings.Draft},
|
||||
&cli.BoolFlag{
|
||||
Name: "prerelease",
|
||||
Usage: "set the release as prerelease",
|
||||
EnvVars: []string{"PLUGIN_PRERELEASE", "GITEA_RELEASE_PRERELEASE"},
|
||||
Destination: &settings.PreRelease},
|
||||
&cli.StringFlag{
|
||||
Name: "base-url",
|
||||
Usage: "url of the gitea instance",
|
||||
EnvVars: []string{"PLUGIN_BASE_URL", "GITEA_RELEASE_BASE_URL"},
|
||||
Destination: &settings.BaseURL},
|
||||
&cli.StringFlag{
|
||||
Name: "title",
|
||||
Value: "",
|
||||
Usage: "file or string for the title shown in the gitea release",
|
||||
EnvVars: []string{"PLUGIN_TITLE", "GITEA_RELEASE_TITLE"},
|
||||
Destination: &settings.Title},
|
||||
&cli.StringFlag{
|
||||
Name: "note",
|
||||
Value: "",
|
||||
Usage: "file or string with notes for the release (example: changelog)",
|
||||
EnvVars: []string{"PLUGIN_NOTE", "GITEA_RELEASE_NOTE"},
|
||||
Destination: &settings.Note},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// Copyright (c) 2021, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// DO NOT MODIFY THIS FILE DIRECTLY
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/drone-plugins/drone-gitea-release/plugin"
|
||||
"github.com/drone-plugins/drone-plugin-lib/errors"
|
||||
"github.com/drone-plugins/drone-plugin-lib/urfave"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var version = "unknown"
|
||||
|
||||
func main() {
|
||||
settings := &plugin.Settings{}
|
||||
|
||||
if _, err := os.Stat("/run/drone/env"); err == nil {
|
||||
godotenv.Overload("/run/drone/env")
|
||||
}
|
||||
|
||||
app := &cli.App{
|
||||
Name: "drone-gitea-release",
|
||||
Usage: "creates a gitea release",
|
||||
Version: version,
|
||||
Flags: append(settingsFlags(settings), urfave.Flags()...),
|
||||
Action: run(settings),
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
errors.HandleExit(err)
|
||||
}
|
||||
}
|
||||
|
||||
func run(settings *plugin.Settings) cli.ActionFunc {
|
||||
return func(ctx *cli.Context) error {
|
||||
urfave.LoggingFromContext(ctx)
|
||||
|
||||
plugin := plugin.New(
|
||||
*settings,
|
||||
urfave.PipelineFromContext(ctx),
|
||||
urfave.NetworkFromContext(ctx),
|
||||
)
|
||||
|
||||
if err := plugin.Validate(); err != nil {
|
||||
if e, ok := err.(errors.ExitCoder); ok {
|
||||
return e
|
||||
}
|
||||
|
||||
return errors.ExitMessagef("validation failed: %w", err)
|
||||
}
|
||||
|
||||
if err := plugin.Execute(); err != nil {
|
||||
if e, ok := err.(errors.ExitCoder); ok {
|
||||
return e
|
||||
}
|
||||
|
||||
return errors.ExitMessagef("execution failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,4 @@ LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/linux/amd64/drone-gitea-release /bin/
|
||||
ENTRYPOINT ["/bin/drone-gitea-release"]
|
||||
ENTRYPOINT [ "/bin/drone-gitea-release" ]
|
||||
@@ -0,0 +1,10 @@
|
||||
# escape=`
|
||||
FROM plugins/base:windows-1803
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Gitea Release" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/windows/amd64/drone-gitea-release.exe C:/bin/drone-gitea-release.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-gitea-release.exe" ]
|
||||
@@ -0,0 +1,10 @@
|
||||
# escape=`
|
||||
FROM plugins/base:windows-1809-amd64
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Gitea Release" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/windows/amd64/drone-gitea-release.exe C:/bin/drone-gitea-release.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-gitea-release.exe" ]
|
||||
@@ -0,0 +1,10 @@
|
||||
# escape=`
|
||||
FROM plugins/base:windows-1903-amd64
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Gitea Release" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/windows/amd64/drone-gitea-release.exe C:/bin/drone-gitea-release.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-gitea-release.exe" ]
|
||||
@@ -0,0 +1,10 @@
|
||||
# escape=`
|
||||
FROM plugins/base:windows-1909-amd64
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Gitea Release" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/windows/amd64/drone-gitea-release.exe C:/bin/drone-gitea-release.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-gitea-release.exe" ]
|
||||
@@ -0,0 +1,10 @@
|
||||
# escape=`
|
||||
FROM plugins/base:windows-2004-amd64
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Gitea Release" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/windows/amd64/drone-gitea-release.exe C:/bin/drone-gitea-release.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-gitea-release.exe" ]
|
||||
@@ -0,0 +1,44 @@
|
||||
image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
|
||||
manifests:
|
||||
- image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
- image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
variant: v8
|
||||
- image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
variant: v7
|
||||
- image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-2004-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 2004
|
||||
- image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1909
|
||||
- image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1903
|
||||
- image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1809
|
||||
@@ -0,0 +1,10 @@
|
||||
module github.com/drone-plugins/drone-gitea-release
|
||||
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
code.gitea.io/sdk/gitea v0.14.0
|
||||
github.com/drone-plugins/drone-plugin-lib v0.4.0
|
||||
github.com/joho/godotenv v1.3.0
|
||||
github.com/urfave/cli/v2 v2.3.0
|
||||
)
|
||||
@@ -0,0 +1,48 @@
|
||||
code.gitea.io/sdk/gitea v0.14.0 h1:m4J352I3p9+bmJUfS+g0odeQzBY/5OXP91Gv6D4fnJ0=
|
||||
code.gitea.io/sdk/gitea v0.14.0/go.mod h1:89WiyOX1KEcvjP66sRHdu0RafojGo60bT9UqW17VbWs=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/drone-plugins/drone-plugin-lib v0.4.0 h1:qywEYGhquUuid6zNLmKia8CWY1TUa8jPQQ/G9ozfAmc=
|
||||
github.com/drone-plugins/drone-plugin-lib v0.4.0/go.mod h1:EgqogX38GoJFtckeSQyhBJYX8P+KWBPhdprAVvyRxF8=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI=
|
||||
github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
|
||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
|
||||
@@ -1,141 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var (
|
||||
version = "0.0.0"
|
||||
build = "0"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "gitea-release plugin"
|
||||
app.Usage = "gitea-release plugin"
|
||||
app.Version = fmt.Sprintf("%s+%s", version, build)
|
||||
app.Action = run
|
||||
app.Flags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "api-key",
|
||||
Usage: "api key to access gitea api",
|
||||
EnvVar: "PLUGIN_API_KEY,GITEA_RELEASE_API_KEY,GITEA_TOKEN",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "files",
|
||||
Usage: "list of files to upload",
|
||||
EnvVar: "PLUGIN_FILES,GITEA_RELEASE_FILES",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "file-exists",
|
||||
Value: "overwrite",
|
||||
Usage: "what to do if file already exist",
|
||||
EnvVar: "PLUGIN_FILE_EXISTS,GITEA_RELEASE_FILE_EXISTS",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "checksum",
|
||||
Usage: "generate specific checksums",
|
||||
EnvVar: "PLUGIN_CHECKSUM,GITEA_RELEASE_CHECKSUM",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "draft",
|
||||
Usage: "create a draft release",
|
||||
EnvVar: "PLUGIN_DRAFT,GITEA_RELEASE_DRAFT",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "insecure",
|
||||
Usage: "visit base-url via insecure https protocol",
|
||||
EnvVar: "PLUGIN_INSECURE,GITEA_RELEASE_INSECURE",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "prerelease",
|
||||
Usage: "set the release as prerelease",
|
||||
EnvVar: "PLUGIN_PRERELEASE,GITEA_RELEASE_PRERELEASE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "base-url",
|
||||
Usage: "url of the gitea instance",
|
||||
EnvVar: "PLUGIN_BASE_URL,GITEA_RELEASE_BASE_URL",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "note",
|
||||
Value: "",
|
||||
Usage: "file or string with notes for the release (example: changelog)",
|
||||
EnvVar: "PLUGIN_NOTE,GITEA_RELEASE_NOTE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "title",
|
||||
Value: "",
|
||||
Usage: "file or string for the title shown in the gitea release",
|
||||
EnvVar: "PLUGIN_TITLE,GITEA_RELEASE_TITLE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "repo.owner",
|
||||
Usage: "repository owner",
|
||||
EnvVar: "DRONE_REPO_OWNER",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "repo.name",
|
||||
Usage: "repository name",
|
||||
EnvVar: "DRONE_REPO_NAME",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "build.event",
|
||||
Value: "push",
|
||||
Usage: "build event",
|
||||
EnvVar: "DRONE_BUILD_EVENT",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "commit.ref",
|
||||
Value: "refs/heads/master",
|
||||
Usage: "git commit ref",
|
||||
EnvVar: "DRONE_COMMIT_REF",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "env-file",
|
||||
Usage: "source env file",
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func run(c *cli.Context) error {
|
||||
if c.String("env-file") != "" {
|
||||
_ = godotenv.Load(c.String("env-file"))
|
||||
}
|
||||
|
||||
plugin := Plugin{
|
||||
Repo: Repo{
|
||||
Owner: c.String("repo.owner"),
|
||||
Name: c.String("repo.name"),
|
||||
},
|
||||
Build: Build{
|
||||
Event: c.String("build.event"),
|
||||
},
|
||||
Commit: Commit{
|
||||
Ref: c.String("commit.ref"),
|
||||
},
|
||||
Config: Config{
|
||||
APIKey: c.String("api-key"),
|
||||
Files: c.StringSlice("files"),
|
||||
FileExists: c.String("file-exists"),
|
||||
Checksum: c.StringSlice("checksum"),
|
||||
Draft: c.Bool("draft"),
|
||||
PreRelease: c.Bool("prerelease"),
|
||||
BaseURL: c.String("base-url"),
|
||||
Insecure: c.Bool("insecure"),
|
||||
Title: c.String("title"),
|
||||
Note: c.String("note"),
|
||||
},
|
||||
}
|
||||
|
||||
return plugin.Exec()
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}{{else}}latest{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-i386
|
||||
platform:
|
||||
architecture: 386
|
||||
os: linux
|
||||
-
|
||||
image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
-
|
||||
image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}windows-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
@@ -1,165 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
)
|
||||
|
||||
type (
|
||||
Repo struct {
|
||||
Owner string
|
||||
Name string
|
||||
}
|
||||
|
||||
Build struct {
|
||||
Event string
|
||||
}
|
||||
|
||||
Commit struct {
|
||||
Ref string
|
||||
}
|
||||
|
||||
Config struct {
|
||||
APIKey string
|
||||
Files []string
|
||||
FileExists string
|
||||
Checksum []string
|
||||
Draft bool
|
||||
PreRelease bool
|
||||
Insecure bool
|
||||
BaseURL string
|
||||
Title string
|
||||
Note string
|
||||
}
|
||||
|
||||
Plugin struct {
|
||||
Repo Repo
|
||||
Build Build
|
||||
Commit Commit
|
||||
Config Config
|
||||
}
|
||||
)
|
||||
|
||||
func (p Plugin) Exec() error {
|
||||
var (
|
||||
files []string
|
||||
)
|
||||
|
||||
if p.Build.Event != "tag" {
|
||||
return fmt.Errorf("The Gitea Release plugin is only available for tags")
|
||||
}
|
||||
|
||||
if p.Config.APIKey == "" {
|
||||
return fmt.Errorf("You must provide an API key")
|
||||
}
|
||||
|
||||
if !fileExistsValues[p.Config.FileExists] {
|
||||
return fmt.Errorf("Invalid value for file_exists")
|
||||
}
|
||||
|
||||
if p.Config.BaseURL == "" {
|
||||
return fmt.Errorf("You must provide a base url.")
|
||||
}
|
||||
|
||||
if !strings.HasSuffix(p.Config.BaseURL, "/") {
|
||||
p.Config.BaseURL = p.Config.BaseURL + "/"
|
||||
}
|
||||
|
||||
var err error
|
||||
if p.Config.Note != "" {
|
||||
if p.Config.Note, err = readStringOrFile(p.Config.Note); err != nil {
|
||||
return fmt.Errorf("error while reading %s: %v", p.Config.Note, err)
|
||||
}
|
||||
}
|
||||
|
||||
if p.Config.Title != "" {
|
||||
if p.Config.Title, err = readStringOrFile(p.Config.Title); err != nil {
|
||||
return fmt.Errorf("error while reading %s: %v", p.Config.Note, err)
|
||||
}
|
||||
}
|
||||
|
||||
for _, glob := range p.Config.Files {
|
||||
globed, err := filepath.Glob(glob)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to glob %s. %s", glob, err)
|
||||
}
|
||||
|
||||
if globed != nil {
|
||||
files = append(files, globed...)
|
||||
}
|
||||
}
|
||||
|
||||
if len(p.Config.Checksum) > 0 {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
|
||||
files, err = writeChecksums(files, p.Config.Checksum)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to write checksums. %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
client := gitea.NewClient(p.Config.BaseURL, p.Config.APIKey)
|
||||
|
||||
if p.Config.Insecure {
|
||||
cookieJar, _ := cookiejar.New(nil)
|
||||
|
||||
var insecureClient = &http.Client{
|
||||
Jar: cookieJar,
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
},
|
||||
}
|
||||
client.SetHTTPClient(insecureClient)
|
||||
}
|
||||
|
||||
rc := releaseClient{
|
||||
Client: client,
|
||||
Owner: p.Repo.Owner,
|
||||
Repo: p.Repo.Name,
|
||||
Tag: strings.TrimPrefix(p.Commit.Ref, "refs/tags/"),
|
||||
Draft: p.Config.Draft,
|
||||
Prerelease: p.Config.PreRelease,
|
||||
FileExists: p.Config.FileExists,
|
||||
Title: p.Config.Title,
|
||||
Note: p.Config.Note,
|
||||
}
|
||||
|
||||
release, err := rc.buildRelease()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to create the release. %s", err)
|
||||
}
|
||||
|
||||
if err := rc.uploadFiles(release.ID, files); err != nil {
|
||||
return fmt.Errorf("Failed to upload the files. %s", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func readStringOrFile(input string) (string, error) {
|
||||
// Check if input is a file path
|
||||
if _, err := os.Stat(input); err != nil && os.IsNotExist(err) {
|
||||
// No file found => use input as result
|
||||
return input, nil
|
||||
} else if err != nil {
|
||||
return "", err
|
||||
}
|
||||
result, err := ioutil.ReadFile(input)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(result), nil
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
// Copyright (c) 2021, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// Settings for the plugin.
|
||||
type Settings struct {
|
||||
APIKey string
|
||||
Files cli.StringSlice
|
||||
FileExists string
|
||||
Checksum cli.StringSlice
|
||||
Draft bool
|
||||
PreRelease bool
|
||||
BaseURL string
|
||||
Title string
|
||||
Note string
|
||||
|
||||
uploads []string
|
||||
}
|
||||
|
||||
// Validate handles the settings validation of the plugin.
|
||||
func (p *Plugin) Validate() error {
|
||||
var err error
|
||||
|
||||
if p.pipeline.Build.Event != "tag" {
|
||||
return fmt.Errorf("gitea release plugin is only available for tags")
|
||||
}
|
||||
|
||||
if p.settings.APIKey == "" {
|
||||
return fmt.Errorf("no api key provided")
|
||||
}
|
||||
|
||||
if !fileExistsValues[p.settings.FileExists] {
|
||||
return fmt.Errorf("invalid value for file_exists")
|
||||
}
|
||||
|
||||
if p.settings.BaseURL == "" {
|
||||
return fmt.Errorf("no base url provided")
|
||||
}
|
||||
|
||||
if !strings.HasSuffix(p.settings.BaseURL, "/") {
|
||||
p.settings.BaseURL = p.settings.BaseURL + "/"
|
||||
}
|
||||
|
||||
if p.settings.Note != "" {
|
||||
if p.settings.Note, err = readStringOrFile(p.settings.Note); err != nil {
|
||||
return fmt.Errorf("error while reading %s: %w", p.settings.Note, err)
|
||||
}
|
||||
}
|
||||
|
||||
if p.settings.Title != "" {
|
||||
if p.settings.Title, err = readStringOrFile(p.settings.Title); err != nil {
|
||||
return fmt.Errorf("error while reading %s: %w", p.settings.Note, err)
|
||||
}
|
||||
}
|
||||
|
||||
files := p.settings.Files.Value()
|
||||
for _, glob := range files {
|
||||
globed, err := filepath.Glob(glob)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to glob %s: %w", glob, err)
|
||||
}
|
||||
|
||||
if globed != nil {
|
||||
p.settings.uploads = append(p.settings.uploads, globed...)
|
||||
}
|
||||
}
|
||||
|
||||
if len(files) > 0 && len(p.settings.uploads) < 1 {
|
||||
return fmt.Errorf("failed to find any file to release")
|
||||
}
|
||||
|
||||
checksum := p.settings.Checksum.Value()
|
||||
if len(checksum) > 0 {
|
||||
p.settings.uploads, err = writeChecksums(files, checksum)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write checksums: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Execute provides the implementation of the plugin.
|
||||
func (p *Plugin) Execute() error {
|
||||
client, err := gitea.NewClient(p.settings.BaseURL, gitea.SetToken(p.settings.APIKey), gitea.SetHTTPClient(p.network.Client))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rc := releaseClient{
|
||||
Client: client,
|
||||
Owner: p.pipeline.Repo.Owner,
|
||||
Repo: p.pipeline.Repo.Name,
|
||||
Tag: strings.TrimPrefix(p.pipeline.Commit.Ref, "refs/tags/"),
|
||||
Draft: p.settings.Draft,
|
||||
Prerelease: p.settings.PreRelease,
|
||||
FileExists: p.settings.FileExists,
|
||||
Title: p.settings.Title,
|
||||
Note: p.settings.Note,
|
||||
}
|
||||
|
||||
// When the title was not provided in the config use the tag instead
|
||||
if rc.Title == "" {
|
||||
rc.Title = rc.Tag
|
||||
}
|
||||
|
||||
release, err := rc.buildRelease()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create the release. %s", err)
|
||||
}
|
||||
|
||||
if err := rc.uploadFiles(release.ID, p.settings.uploads); err != nil {
|
||||
return fmt.Errorf("failed to upload the files. %s", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2021, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestValidate(t *testing.T) {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
func TestExecute(t *testing.T) {
|
||||
t.Skip()
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2021, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"github.com/drone-plugins/drone-plugin-lib/drone"
|
||||
)
|
||||
|
||||
// Plugin implements drone.Plugin to provide the plugin implementation.
|
||||
type Plugin struct {
|
||||
settings Settings
|
||||
pipeline drone.Pipeline
|
||||
network drone.Network
|
||||
}
|
||||
|
||||
// New initializes a plugin from the given Settings, Pipeline, and Network.
|
||||
func New(settings Settings, pipeline drone.Pipeline, network drone.Network) drone.Plugin {
|
||||
return &Plugin{
|
||||
settings: settings,
|
||||
pipeline: pipeline,
|
||||
network: network,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2021, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPlugin(t *testing.T) {
|
||||
t.Skip()
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
package main
|
||||
// Copyright (c) 2021, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -35,25 +40,25 @@ func (rc *releaseClient) buildRelease() (*gitea.Release, error) {
|
||||
release, err = rc.newRelease()
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to retrieve or create a release: %s", err)
|
||||
return nil, fmt.Errorf("failed to retrieve or create a release: %s", err)
|
||||
}
|
||||
|
||||
return release, nil
|
||||
}
|
||||
|
||||
func (rc *releaseClient) getRelease() (*gitea.Release, error) {
|
||||
releases, err := rc.Client.ListReleases(rc.Owner, rc.Repo)
|
||||
releases, _, err := rc.Client.ListReleases(rc.Owner, rc.Repo, gitea.ListReleasesOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, release := range releases {
|
||||
if release.TagName == rc.Tag {
|
||||
fmt.Printf("Successfully retrieved %s release\n", rc.Tag)
|
||||
fmt.Printf("successfully retrieved %s release\n", rc.Tag)
|
||||
return release, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("Release %s not found", rc.Tag)
|
||||
return nil, fmt.Errorf("release %s not found", rc.Tag)
|
||||
}
|
||||
|
||||
func (rc *releaseClient) newRelease() (*gitea.Release, error) {
|
||||
@@ -65,20 +70,20 @@ func (rc *releaseClient) newRelease() (*gitea.Release, error) {
|
||||
Note: rc.Note,
|
||||
}
|
||||
|
||||
release, err := rc.Client.CreateRelease(rc.Owner, rc.Repo, r)
|
||||
release, _, err := rc.Client.CreateRelease(rc.Owner, rc.Repo, r)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to create release: %s", err)
|
||||
return nil, fmt.Errorf("failed to create release: %s", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Successfully created %s release\n", rc.Tag)
|
||||
fmt.Printf("successfully created %s release\n", rc.Tag)
|
||||
return release, nil
|
||||
}
|
||||
|
||||
func (rc *releaseClient) uploadFiles(releaseID int64, files []string) error {
|
||||
attachments, err := rc.Client.ListReleaseAttachments(rc.Owner, rc.Repo, releaseID)
|
||||
attachments, _, err := rc.Client.ListReleaseAttachments(rc.Owner, rc.Repo, releaseID, gitea.ListReleaseAttachmentsOptions{})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to fetch existing assets: %s", err)
|
||||
return fmt.Errorf("failed to fetch existing assets: %s", err)
|
||||
}
|
||||
|
||||
var uploadFiles []string
|
||||
@@ -91,12 +96,12 @@ files:
|
||||
case "overwrite":
|
||||
// do nothing
|
||||
case "fail":
|
||||
return fmt.Errorf("Asset file %s already exists", path.Base(file))
|
||||
return fmt.Errorf("asset file %s already exists", path.Base(file))
|
||||
case "skip":
|
||||
fmt.Printf("Skipping pre-existing %s artifact\n", attachment.Name)
|
||||
fmt.Printf("skipping pre-existing %s artifact\n", attachment.Name)
|
||||
continue files
|
||||
default:
|
||||
return fmt.Errorf("Internal error, unkown file_exist value %s", rc.FileExists)
|
||||
return fmt.Errorf("internal error, unkown file_exist value %s", rc.FileExists)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,24 +113,24 @@ files:
|
||||
handle, err := os.Open(file)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to read %s artifact: %s", file, err)
|
||||
return fmt.Errorf("failed to read %s artifact: %s", file, err)
|
||||
}
|
||||
|
||||
for _, attachment := range attachments {
|
||||
if attachment.Name == path.Base(file) {
|
||||
if err := rc.Client.DeleteReleaseAttachment(rc.Owner, rc.Repo, releaseID, attachment.ID); err != nil {
|
||||
return fmt.Errorf("Failed to delete %s artifact: %s", file, err)
|
||||
if _, err := rc.Client.DeleteReleaseAttachment(rc.Owner, rc.Repo, releaseID, attachment.ID); err != nil {
|
||||
return fmt.Errorf("failed to delete %s artifact: %s", file, err)
|
||||
}
|
||||
|
||||
fmt.Printf("Successfully deleted old %s artifact\n", attachment.Name)
|
||||
fmt.Printf("successfully deleted old %s artifact\n", attachment.Name)
|
||||
}
|
||||
}
|
||||
|
||||
if _, err = rc.Client.CreateReleaseAttachment(rc.Owner, rc.Repo, releaseID, handle, path.Base(file)); err != nil {
|
||||
return fmt.Errorf("Failed to upload %s artifact: %s", file, err)
|
||||
if _, _, err = rc.Client.CreateReleaseAttachment(rc.Owner, rc.Repo, releaseID, handle, path.Base(file)); err != nil {
|
||||
return fmt.Errorf("failed to upload %s artifact: %s", file, err)
|
||||
}
|
||||
|
||||
fmt.Printf("Successfully uploaded %s artifact\n", file)
|
||||
fmt.Printf("successfully uploaded %s artifact\n", file)
|
||||
}
|
||||
|
||||
return nil
|
||||
+21
-12
@@ -1,4 +1,9 @@
|
||||
package main
|
||||
// Copyright (c) 2021, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
@@ -11,9 +16,7 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -24,13 +27,19 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func execute(cmd *exec.Cmd) error {
|
||||
fmt.Println("+", strings.Join(cmd.Args, " "))
|
||||
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdin = os.Stdin
|
||||
|
||||
return cmd.Run()
|
||||
func readStringOrFile(input string) (string, error) {
|
||||
// Check if input is a file path
|
||||
if _, err := os.Stat(input); err != nil && os.IsNotExist(err) {
|
||||
// No file found => use input as result
|
||||
return input, nil
|
||||
} else if err != nil {
|
||||
return "", err
|
||||
}
|
||||
result, err := ioutil.ReadFile(input)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(result), nil
|
||||
}
|
||||
|
||||
func checksum(r io.Reader, method string) (string, error) {
|
||||
@@ -55,7 +64,7 @@ func checksum(r io.Reader, method string) (string, error) {
|
||||
return strconv.FormatUint(uint64(crc32.ChecksumIEEE(b)), 10), nil
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("Hashing method %s is not supported", method)
|
||||
return "", fmt.Errorf("hashing method %s is not supported", method)
|
||||
}
|
||||
|
||||
func writeChecksums(files, methods []string) ([]string, error) {
|
||||
@@ -66,7 +75,7 @@ func writeChecksums(files, methods []string) ([]string, error) {
|
||||
handle, err := os.Open(file)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to read %s artifact: %s", file, err)
|
||||
return nil, fmt.Errorf("failed to read %s artifact: %s", file, err)
|
||||
}
|
||||
|
||||
hash, err := checksum(handle, method)
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"extends": [
|
||||
"config:base",
|
||||
":automergeMinor",
|
||||
":automergeDigest"
|
||||
],
|
||||
"enabledManagers": [
|
||||
"dockerfile",
|
||||
"gomod"
|
||||
],
|
||||
"dockerfile": {
|
||||
"fileMatch": [
|
||||
"docker/Dockerfile\\.linux\\.(arm|arm64|amd64|multiarch)",
|
||||
"docker/Dockerfile\\.windows\\.(1809|1903|1909|2004)"
|
||||
],
|
||||
"pinDigests": true
|
||||
},
|
||||
"gomod": {
|
||||
"postUpdateOptions": [
|
||||
"gomodTidy"
|
||||
]
|
||||
},
|
||||
"labels": [
|
||||
"renovate"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user