feat: implement Gitea release creation with asset upload
Some checks failed
Build & Release Plugin / release (push) Failing after 8s
Some checks failed
Build & Release Plugin / release (push) Failing after 8s
This commit is contained in:
80
.github/workflows/release.yml
vendored
80
.github/workflows/release.yml
vendored
@@ -129,24 +129,68 @@ jobs:
|
|||||||
echo "asset_path=$ZIP_PATH" >> "$GITHUB_OUTPUT"
|
echo "asset_path=$ZIP_PATH" >> "$GITHUB_OUTPUT"
|
||||||
echo "asset_name=${SLUG}-${VERSION}.zip" >> "$GITHUB_OUTPUT"
|
echo "asset_name=${SLUG}-${VERSION}.zip" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Stel release-body samen
|
- name: Maak Gitea release
|
||||||
if: steps.tagcheck.outputs.exists == 'false'
|
if: steps.tagcheck.outputs.exists == 'false'
|
||||||
id: releasebody
|
|
||||||
run: |
|
|
||||||
if [ -n "$RELEASE_NOTES" ]; then
|
|
||||||
echo "text=$RELEASE_NOTES" >> "$GITHUB_OUTPUT"
|
|
||||||
else
|
|
||||||
echo "text=Automatische release op basis van versie ${{ steps.meta.outputs.version }}." >> "$GITHUB_OUTPUT"
|
|
||||||
fi
|
|
||||||
env:
|
env:
|
||||||
RELEASE_NOTES: ${{ github.event.inputs.release_notes }}
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
RELEASE_SERVER_URL: ${{ vars.RELEASE_SERVER_URL }}
|
||||||
|
RELEASE_REPOSITORY: ${{ vars.RELEASE_REPOSITORY }}
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
|
TAG="v$VERSION"
|
||||||
|
ASSET_PATH="${{ steps.package.outputs.asset_path }}"
|
||||||
|
ASSET_NAME="${{ steps.package.outputs.asset_name }}"
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_TOKEN" ]; then
|
||||||
|
echo "::error::RELEASE_TOKEN ontbreekt. Voeg deze secret toe om releases te kunnen maken."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SERVER_URL="${RELEASE_SERVER_URL:-${GITHUB_SERVER_URL}}"
|
||||||
|
REPO="${RELEASE_REPOSITORY:-${GITHUB_REPOSITORY}}"
|
||||||
|
if [ -z "$SERVER_URL" ] || [ -z "$REPO" ]; then
|
||||||
|
echo "::error::Kan server of repository niet bepalen. Stel RELEASE_SERVER_URL en RELEASE_REPOSITORY in."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
API_URL="${SERVER_URL%/}/api/v1"
|
||||||
|
|
||||||
|
export TAG
|
||||||
|
python3 - <<'PY'
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
"tag_name": os.environ["TAG"],
|
||||||
|
"name": f"Siti AI Product Teksten {os.environ['TAG']}",
|
||||||
|
"body": f"Automatische release op basis van versie {os.environ['TAG'][1:]}",
|
||||||
|
"target_commitish": os.environ.get("GITHUB_SHA") or os.environ.get("GITEA_SHA", ""),
|
||||||
|
}
|
||||||
|
|
||||||
|
with open("release.json", "w", encoding="utf-8") as handle:
|
||||||
|
json.dump(payload, handle, ensure_ascii=False)
|
||||||
|
PY
|
||||||
|
|
||||||
|
RESPONSE=$(curl -sS -X POST "$API_URL/repos/$REPO/releases" \
|
||||||
|
-H "Authorization: token $RELEASE_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d @release.json)
|
||||||
|
|
||||||
|
RELEASE_ID=$(python3 - <<'PY'
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
data = json.loads(sys.stdin.read())
|
||||||
|
print(data.get('id', ''))
|
||||||
|
PY
|
||||||
|
<<< "$RESPONSE")
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
|
echo "::error::Kon release-ID niet bepalen. Response: $RESPONSE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -sS -X POST "$API_URL/repos/$REPO/releases/$RELEASE_ID/assets?name=$ASSET_NAME" \
|
||||||
|
-H "Authorization: token $RELEASE_TOKEN" \
|
||||||
|
-H "Content-Type: application/zip" \
|
||||||
|
--data-binary "@$ASSET_PATH"
|
||||||
|
|
||||||
- name: Maak GitHub release
|
|
||||||
if: steps.tagcheck.outputs.exists == 'false'
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
with:
|
|
||||||
tag_name: v${{ steps.meta.outputs.version }}
|
|
||||||
name: Siti AI Product Teksten v${{ steps.meta.outputs.version }}
|
|
||||||
body: ${{ steps.releasebody.outputs.text }}
|
|
||||||
generate_release_notes: true
|
|
||||||
files: ${{ steps.package.outputs.asset_path }}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user