96 lines
3.2 KiB
YAML
96 lines
3.2 KiB
YAML
name: Create Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
release_tag:
|
|
description: 'Release tag (e.g., v0.3.0)'
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Get Version
|
|
id: get_version
|
|
run: |
|
|
python - <<'PY'
|
|
import os
|
|
import tomllib
|
|
from pathlib import Path
|
|
|
|
data = tomllib.loads(Path("blender_manifest.toml").read_text(encoding="utf-8"))
|
|
version = data["version"]
|
|
|
|
# Gitea Actions uses GITHUB_OUTPUT (compatible with GitHub Actions)
|
|
output_file = os.environ.get("GITHUB_OUTPUT", os.environ.get("GITEA_OUTPUT", "/dev/stdout"))
|
|
with open(output_file, "a", encoding="utf-8") as fh:
|
|
fh.write(f"version={version}\n")
|
|
fh.write(f"zip_name=dynamiclinkmanager_{version}.zip\n")
|
|
PY
|
|
|
|
- name: Create ZIP
|
|
run: |
|
|
ADDON_DIR=dynamiclinkmanager
|
|
mkdir -p "$ADDON_DIR"
|
|
|
|
# Copy top-level files
|
|
for file in __init__.py blender_manifest.toml; do
|
|
if [ -f "$file" ]; then
|
|
cp "$file" "$ADDON_DIR"/
|
|
else
|
|
echo "Skipping missing file: $file"
|
|
fi
|
|
done
|
|
|
|
# Copy directories
|
|
cp -r ops "$ADDON_DIR"/
|
|
cp -r ui "$ADDON_DIR"/
|
|
if [ -d "utils" ] && [ "$(ls -A utils)" ]; then
|
|
cp -r utils "$ADDON_DIR"/
|
|
fi
|
|
|
|
# Create the zip from the temporary directory
|
|
zip -r "${{ steps.get_version.outputs.zip_name }}" "$ADDON_DIR"/*
|
|
|
|
- name: Create Release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
# Gitea Actions uses github.repository context (compatible with GitHub Actions)
|
|
API_BASE="${GITHUB_SERVER_URL}/api/v1"
|
|
curl -X POST \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"tag_name\": \"${{ inputs.release_tag }}\",
|
|
\"name\": \"${{ inputs.release_tag }}\",
|
|
\"body\": \"Release ${{ steps.get_version.outputs.version }}\",
|
|
\"draft\": true
|
|
}" \
|
|
"${API_BASE}/repos/${{ github.repository }}/releases" || true
|
|
|
|
- name: Upload Release Asset
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
API_BASE="${GITHUB_SERVER_URL}/api/v1"
|
|
# Get the release ID
|
|
RELEASE_ID=$(curl -s \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
"${API_BASE}/repos/${{ github.repository }}/releases/tags/${{ inputs.release_tag }}" \
|
|
| grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
|
|
|
if [ -n "$RELEASE_ID" ]; then
|
|
curl -X POST \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/zip" \
|
|
--data-binary "@${{ steps.get_version.outputs.zip_name }}" \
|
|
"${API_BASE}/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=${{ steps.get_version.outputs.zip_name }}"
|
|
fi
|