diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1af9817..cd229c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,6 +26,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + fetch-tags: true - name: Determine plugin version id: meta @@ -68,6 +69,11 @@ jobs: print('manifest.json aangemaakt/bijgewerkt') PY + - name: Toon manifest.json + run: | + echo "manifest.json inhoud:" + cat manifest.json + - name: Commit & push manifest.json run: | if git diff --quiet -- manifest.json; then @@ -85,7 +91,7 @@ jobs: id: tagcheck run: | TAG="v${{ steps.meta.outputs.version }}" - if git rev-parse "$TAG" >/dev/null 2>&1; then + if git ls-remote --tags origin "refs/tags/$TAG" | grep -q "$TAG"; then echo "exists=true" >> "$GITHUB_OUTPUT" else echo "exists=false" >> "$GITHUB_OUTPUT" @@ -134,12 +140,99 @@ jobs: env: RELEASE_NOTES: ${{ github.event.inputs.release_notes }} - - name: Maak GitHub release + - name: Maak Gitea tag 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 }} + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + GITEA_SERVER_URL: ${{ vars.GITEA_SERVER_URL }} + GITEA_REPOSITORY: ${{ vars.GITEA_REPOSITORY }} + run: | + VERSION="${{ steps.meta.outputs.version }}" + TAG="v$VERSION" + + if [ -z "$GITEA_TOKEN" ]; then + echo "::error::GITEA_TOKEN ontbreekt. Voeg deze secret toe om tags te kunnen pushen." + exit 1 + fi + + SERVER_URL="${GITEA_SERVER_URL:-${GITHUB_SERVER_URL}}" + REPO="${GITEA_REPOSITORY:-${GITHUB_REPOSITORY}}" + if [ -z "$SERVER_URL" ] || [ -z "$REPO" ]; then + echo "::error::Kan Gitea server of repository niet bepalen. Stel GITEA_SERVER_URL en GITEA_REPOSITORY in." + exit 1 + fi + + HOST="${SERVER_URL#https://}" + HOST="${HOST#http://}" + AUTH_URL="https://oauth2:${GITEA_TOKEN}@${HOST}/${REPO}.git" + + git tag -a "$TAG" -m "$TAG" + git push "$AUTH_URL" "$TAG" + + - name: Maak Gitea release + if: steps.tagcheck.outputs.exists == 'false' + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + GITEA_SERVER_URL: ${{ vars.GITEA_SERVER_URL }} + GITEA_REPOSITORY: ${{ vars.GITEA_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 "$GITEA_TOKEN" ]; then + echo "::error::GITEA_TOKEN ontbreekt. Voeg deze secret toe om releases te kunnen maken." + exit 1 + fi + + SERVER_URL="${GITEA_SERVER_URL:-${GITHUB_SERVER_URL}}" + REPO="${GITEA_REPOSITORY:-${GITHUB_REPOSITORY}}" + if [ -z "$SERVER_URL" ] || [ -z "$REPO" ]; then + echo "::error::Kan Gitea server of repository niet bepalen. Stel GITEA_SERVER_URL en GITEA_REPOSITORY in." + exit 1 + fi + + API_URL="${SERVER_URL%/}/api/v1" + BODY="${{ steps.releasebody.outputs.text }}" + + export TAG + export BODY + + python3 - <<'PY' + import json + import os + + payload = { + "tag_name": os.environ["TAG"], + "name": f"Siti AI Product Teksten {os.environ['TAG']}", + "body": os.environ.get("BODY", ""), + "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 $GITEA_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 $GITEA_TOKEN" \ + -H "Content-Type: application/zip" \ + --data-binary "@$ASSET_PATH" diff --git a/groq-ai-product-text.php b/groq-ai-product-text.php index 57aa00f..2a42b60 100644 --- a/groq-ai-product-text.php +++ b/groq-ai-product-text.php @@ -2,7 +2,7 @@ /** * Plugin Name: SitiAI Product Teksten * Description: Genereer productteksten met diverse AI-aanbieders rechtstreeks vanuit WooCommerce. - * Version: 1.9.2 + * Version: 1.9.1 * Author: Roberto Guagliardo | SitiWeb * Author URI: https://sitiweb.nl/ * Text Domain: siti-ai-product-content-generator