Просмотр исходного кода

Set the deploy scripts to use the commit/changelog scripts; add the changelog script

master
Fen Dweller 5 лет назад
Родитель
Сommit
9d2e2b4810
3 измененных файлов: 50 добавлений и 1 удалений
  1. +47
    -0
      commits.py
  2. +2
    -0
      deploy-branch.sh
  3. +1
    -1
      deploy-release.sh

+ 47
- 0
commits.py Просмотреть файл

@@ -0,0 +1,47 @@
#! /usr/bin/python3

import sys
import os
import requests
import json
import os

from datetime import datetime

TOKEN = os.environ["GITEA_API_KEY"]

def grab(url):
r = requests.get(url, headers = {
"authorization": "token " + TOKEN
})

if r.status_code != 200:
print(url)
print("oops...")
print(r.text)
sys.exit(1)

return json.loads(r.text)

url = "https://git.crux.best/api/v1/repos/chemicalcrux/{0}/releases".format(sys.argv[1])

tag = grab(url)[0]["tag_name"]

url = "https://git.crux.best/api/v1/repos/chemicalcrux/{0}/commits?sha={1}".format(sys.argv[1], tag)

data = grab(url)[1:]

results = []
for commit in data:
result = {}
lines = commit["commit"]["message"].split("\n")
subject = lines[0]
body = "\n".join(lines[2:])

result["date"] = datetime.fromisoformat(commit["commit"]["author"]["date"]).strftime("%B %d")
result["subject"] = subject
result["body"] = body
results.append(result)

with open(os.path.join(sys.argv[2], "commits.json"), "w", encoding="utf-8") as file:
json.dump(results[::-1], file)

+ 2
- 0
deploy-branch.sh Просмотреть файл

@@ -20,3 +20,5 @@ then
cd /home/web/crux.sexy/macrovision
git pull
fi

$WEBHOOK_SCRIPT_DIR/commits.py $1 $COMMITS_DIR/$1.json

+ 1
- 1
deploy-release.sh Просмотреть файл

@@ -8,4 +8,4 @@ git fetch --tags
latest=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout ${latest}

$WEBHOOK_SCRIPT_DIR/changelog.py $1 .
$WEBHOOK_SCRIPT_DIR/changelog.py $1 $CHANGELOG_DIR/$1.json

Загрузка…
Отмена
Сохранить