drone ci and git release
This commit is contained in:
parent
4193b3e1d4
commit
0046bc3ed6
2 changed files with 103 additions and 36 deletions
92
.drone.yml
92
.drone.yml
|
@ -2,52 +2,72 @@ kind: pipeline
|
||||||
type: exec
|
type: exec
|
||||||
name: default
|
name: default
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: restore-cache-with-filesystem
|
- name: restore-cache-with-filesystem
|
||||||
image: drillster/drone-volume-cache
|
commands:
|
||||||
settings:
|
- ls -a /tmp/drone/Elixium/Raxen
|
||||||
restore: true
|
- ls -a
|
||||||
mount:
|
- cp -r /tmp/drone/Elixium/Raxen $(pwd)/
|
||||||
- ./build
|
- ls -a
|
||||||
- ./.gradle
|
# settings:
|
||||||
# Mount the cache volume, needs "Trusted"
|
# restore: true
|
||||||
volumes:
|
# mount:
|
||||||
- name: cache
|
# - ./build
|
||||||
path: /cache
|
# - ./.gradle
|
||||||
|
# ## Mount the cache volume, needs "Trusted"
|
||||||
|
# volumes:
|
||||||
|
# - name: cache
|
||||||
|
# path: /cache
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
image: gradle:jdk17
|
|
||||||
commands:
|
commands:
|
||||||
- ls -a
|
- ls -a
|
||||||
- gradle assemble --stacktrace
|
- gradle assemble --stacktrace
|
||||||
- ls -a
|
- ls -a
|
||||||
|
|
||||||
- name: gitea_release
|
- name: gitea_release
|
||||||
image: plugins/gitea-release
|
|
||||||
settings:
|
|
||||||
base_url: https://git.unurled.me
|
|
||||||
files: build/libs/*
|
|
||||||
api_key:
|
|
||||||
from_secret: api_key
|
|
||||||
prerelease: true
|
|
||||||
when:
|
when:
|
||||||
event: tag
|
event:
|
||||||
|
- tag
|
||||||
|
commands:
|
||||||
|
- export PRERELEASE=true
|
||||||
|
- chmod +x git_release.sh
|
||||||
|
- python git_release.py --token "$API_KEY" --message "${DRONE_COMMIT_MESSAGE}" --prerelease $PRERELEASE --tag "${DRONE_TAG}"
|
||||||
|
environment:
|
||||||
|
API_KEY:
|
||||||
|
from_secret: api_key
|
||||||
|
# settings:
|
||||||
|
# base_url: https://git.unurled.me
|
||||||
|
# files: build/libs/*
|
||||||
|
# api_key:
|
||||||
|
# from_secret: api_key
|
||||||
|
# prerelease: true
|
||||||
|
# when:
|
||||||
|
# event: tag
|
||||||
|
|
||||||
- name: rebuild-cache-with-filesystem
|
- name: rebuild-cache-with-filesystem
|
||||||
image: drillster/drone-volume-cache
|
commands:
|
||||||
settings:
|
- ls -a
|
||||||
rebuild: true
|
- mkdir -p /tmp/drone/Elixium/Raxen
|
||||||
mount:
|
- ls -a /tmp/drone/Elixium/Raxen
|
||||||
- ./build
|
- mv -f -t $(pwd)/build/classes /tmp/drone/Elixium/Raxen
|
||||||
- ./.gradle
|
- mv -f -t $(pwd)/build/generated /tmp/drone/Elixium/Raxen
|
||||||
# Mount the cache volume, needs "Trusted"
|
- mv -f -t $(pwd)/build/resources /tmp/drone/Elixium/Raxen
|
||||||
volumes:
|
- mv -f -t $(pwd)/build/tmp /tmp/drone/Elixium/Raxen
|
||||||
- name: cache
|
- mv -f -t $(pwd)/.gradle /tmp/drone/Elixium/Raxen
|
||||||
path: /cache
|
- ls -a
|
||||||
|
- ls -a /tmp/drone/Elixium/Raxen
|
||||||
|
# image: drillster/drone-volume-cache
|
||||||
volumes:
|
# settings:
|
||||||
- name: cache
|
# rebuild: true
|
||||||
host:
|
# mount:
|
||||||
path: /tmp/cache
|
# - ./build
|
||||||
# temp: {}
|
# - ./.gradle
|
||||||
|
# # Mount the cache volume, needs "Trusted"
|
||||||
|
# volumes:
|
||||||
|
# - name: cache
|
||||||
|
# path: /cache
|
||||||
|
|
47
git_release.py
Normal file
47
git_release.py
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
import os
|
||||||
|
import argparse
|
||||||
|
import giteapy
|
||||||
|
from giteapy.rest import ApiException
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description="publish to git.unurled.me the release.")
|
||||||
|
parser.add_argument('--token', type=str, help="a token which have sufficient permission")
|
||||||
|
parser.add_argument('--message', type=str)
|
||||||
|
parser.add_argument('--prerelease', type=bool)
|
||||||
|
parser.add_argument('--tag', type=str)
|
||||||
|
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
doc = vars(args)
|
||||||
|
|
||||||
|
print(doc)
|
||||||
|
|
||||||
|
configuration = giteapy.Configuration()
|
||||||
|
configuration.api_key['access_token'] = doc['token']
|
||||||
|
configuration.host = 'https://git.unurled.me/api/v1'
|
||||||
|
api_instance = giteapy.RepositoryApi(giteapy.ApiClient(configuration))
|
||||||
|
owner = "Elixium"
|
||||||
|
repo = "Raxen"
|
||||||
|
body = giteapy.CreateReleaseOption(body=doc['message'], draft=False, name=doc['tag'], prerelease=doc['prerelease'], tag_name=doc['tag'], target_commitish="string")
|
||||||
|
attachments = []
|
||||||
|
for file in os.listdir(os.getcwd() +"/build/libs"):
|
||||||
|
if file.endswith('.jar'):
|
||||||
|
if file.startswith('raxen'):
|
||||||
|
attachments.append(os.getcwd() + '/build/libs/' + file)
|
||||||
|
print(attachments)
|
||||||
|
attachment1 = attachments[0]
|
||||||
|
attachment2 = attachments[1]
|
||||||
|
attachment3 = attachments[2]
|
||||||
|
name1 = attachments[0].split("libs/")[1]
|
||||||
|
name2 = attachments[1].split("libs/")[1]
|
||||||
|
name3 = attachments[2].split("libs/")[1]
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Create a release
|
||||||
|
api_response = api_instance.repo_create_release(owner, repo, body=body)
|
||||||
|
print(api_response.id)
|
||||||
|
attachement_response = api_instance.repo_create_release_attachment(owner, repo, api_response.id, attachment=attachment1, name=name1)
|
||||||
|
attachement_response = api_instance.repo_create_release_attachment(owner, repo, api_response.id, attachment=attachment2, name=name2)
|
||||||
|
attachement_response = api_instance.repo_create_release_attachment(owner, repo, api_response.id, attachment=attachment3, name=name3)
|
||||||
|
print(attachement_response)
|
||||||
|
except ApiException as e:
|
||||||
|
print("Exception when calling RepositoryApi->repo_create_release: %s\n" % e)
|
Loading…
Add table
Reference in a new issue