.gitea/workflows/release-from-tag.yml aktualisiert
All checks were successful
Tag from TOC Version / tag (push) Successful in 5s
All checks were successful
Tag from TOC Version / tag (push) Successful in 5s
This commit is contained in:
@@ -12,13 +12,25 @@ jobs:
|
||||
steps:
|
||||
- name: Tools installieren
|
||||
run: |
|
||||
set -e
|
||||
apt-get update
|
||||
apt-get install -y git zip curl jq rsync
|
||||
|
||||
- name: Variablen setzen
|
||||
run: |
|
||||
set -e
|
||||
echo "REPO=${{ gitea.repository }}" >> $GITHUB_ENV
|
||||
echo "TAG=${{ gitea.ref_name }}" >> $GITHUB_ENV
|
||||
echo "SERVER_URL=${{ gitea.server_url }}" >> $GITHUB_ENV
|
||||
echo "API_BASE=${{ gitea.server_url }}/api/v1" >> $GITHUB_ENV
|
||||
|
||||
- name: Repo klonen
|
||||
run: |
|
||||
rm -rf /tmp/repo /tmp/build
|
||||
git clone http://oauth2:${{ secrets.PAT_TOKEN }}@10.10.2.140:3000/Torsten/HailMaryGuildTools.git /tmp/repo
|
||||
set -e
|
||||
rm -rf /tmp/repo /tmp/build /tmp/release.json /tmp/assets.json
|
||||
|
||||
CLONE_URL="${SERVER_URL#https://}"
|
||||
git clone "https://oauth2:${{ secrets.PAT_TOKEN }}@${CLONE_URL}/${REPO}.git" /tmp/repo
|
||||
|
||||
- name: ZIP mit Addon-Ordner bauen
|
||||
run: |
|
||||
@@ -31,44 +43,89 @@ jobs:
|
||||
/tmp/repo/ /tmp/build/HailMaryGuildTools/
|
||||
|
||||
cd /tmp/build
|
||||
zip -r "/tmp/HailMaryGuildTools-${{ gitea.ref_name }}.zip" HailMaryGuildTools
|
||||
ls -lh "/tmp/HailMaryGuildTools-${{ gitea.ref_name }}.zip"
|
||||
zip -r "/tmp/HailMaryGuildTools-${TAG}.zip" HailMaryGuildTools
|
||||
ls -lh "/tmp/HailMaryGuildTools-${TAG}.zip"
|
||||
|
||||
- name: Release anlegen oder laden
|
||||
run: |
|
||||
set -e
|
||||
TAG="${{ gitea.ref_name }}"
|
||||
API="http://10.10.2.140:3000/api/v1/repos/Torsten/HailMaryGuildTools"
|
||||
|
||||
API="${API_BASE}/repos/${REPO}"
|
||||
|
||||
echo "Server: ${SERVER_URL}"
|
||||
echo "Repo: ${REPO}"
|
||||
echo "Tag: ${TAG}"
|
||||
|
||||
HTTP_CODE=$(curl -s -o /tmp/release.json -w "%{http_code}" \
|
||||
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
|
||||
"$API/releases/tags/$TAG")
|
||||
-H "Accept: application/json" \
|
||||
"${API}/releases/tags/${TAG}")
|
||||
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
echo "Release existiert bereits."
|
||||
else
|
||||
elif [ "$HTTP_CODE" = "404" ]; then
|
||||
echo "Release wird erstellt."
|
||||
curl --fail -s \
|
||||
-X POST \
|
||||
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
|
||||
-H "Accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"tag_name\": \"$TAG\",
|
||||
\"name\": \"HailMaryGuildTools $TAG\",
|
||||
\"tag_name\": \"${TAG}\",
|
||||
\"name\": \"${REPO##*/} ${TAG}\",
|
||||
\"draft\": false,
|
||||
\"prerelease\": false
|
||||
}" \
|
||||
"$API/releases" > /tmp/release.json
|
||||
"${API}/releases" > /tmp/release.json
|
||||
else
|
||||
echo "Unerwarteter HTTP-Code beim Laden des Releases: ${HTTP_CODE}"
|
||||
cat /tmp/release.json || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Release-Daten:"
|
||||
jq '.id, .tag_name, .html_url' /tmp/release.json
|
||||
|
||||
- name: Vorhandenes Asset mit gleichem Namen löschen
|
||||
run: |
|
||||
set -e
|
||||
|
||||
RELEASE_ID=$(jq -r '.id' /tmp/release.json)
|
||||
FILE_NAME="HailMaryGuildTools-${TAG}.zip"
|
||||
ASSET_API="${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets"
|
||||
|
||||
curl --fail -s \
|
||||
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
|
||||
-H "Accept: application/json" \
|
||||
"${ASSET_API}" > /tmp/assets.json
|
||||
|
||||
ASSET_ID=$(jq -r ".[] | select(.name == \"${FILE_NAME}\") | .id" /tmp/assets.json | head -n1)
|
||||
|
||||
if [ -n "$ASSET_ID" ] && [ "$ASSET_ID" != "null" ]; then
|
||||
echo "Vorhandenes Asset gefunden: ${ASSET_ID} -> wird gelöscht"
|
||||
curl --fail -s \
|
||||
-X DELETE \
|
||||
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
|
||||
-H "Accept: application/json" \
|
||||
"${ASSET_API}/${ASSET_ID}"
|
||||
else
|
||||
echo "Kein vorhandenes Asset mit gleichem Namen gefunden."
|
||||
fi
|
||||
|
||||
- name: ZIP an Release anhängen
|
||||
run: |
|
||||
set -e
|
||||
RELEASE_ID=$(jq -r '.id' /tmp/release.json)
|
||||
FILE="/tmp/HailMaryGuildTools-${{ gitea.ref_name }}.zip"
|
||||
|
||||
curl --fail \
|
||||
RELEASE_ID=$(jq -r '.id' /tmp/release.json)
|
||||
FILE="/tmp/HailMaryGuildTools-${TAG}.zip"
|
||||
FILE_NAME="$(basename "$FILE")"
|
||||
UPLOAD_URL="${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILE_NAME}"
|
||||
|
||||
echo "Upload URL: ${UPLOAD_URL}"
|
||||
|
||||
curl --fail -v \
|
||||
-X POST \
|
||||
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
|
||||
-H "Accept: application/json" \
|
||||
-F "attachment=@${FILE}" \
|
||||
"http://10.10.2.140:3000/api/v1/repos/Torsten/HailMaryGuildTools/releases/${RELEASE_ID}/assets?name=$(basename "$FILE")"
|
||||
"${UPLOAD_URL}"
|
||||
Reference in New Issue
Block a user