Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b73d858ca7 | |||
| aa4bfa33c0 | |||
| 0b9cd99fb0 | |||
| eba8df9962 | |||
| f2a39e4660 | |||
| 2f0a44706b | |||
| 10a46f8668 | |||
| db981ba4a6 | |||
|
|
aa757710c9 | ||
| 1d587ce2d1 | |||
| 0aaa7087a9 | |||
|
|
68bce5006d | ||
| 4383982fb2 | |||
|
|
5f1dcaf352 | ||
| 62c688dba4 | |||
|
|
42332635ba | ||
| 9ae516b77c | |||
| 4ff96d98e0 |
148
.github/workflows/release.yml
vendored
148
.github/workflows/release.yml
vendored
@@ -26,6 +26,7 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
- name: Determine plugin version
|
- name: Determine plugin version
|
||||||
id: meta
|
id: meta
|
||||||
@@ -38,11 +39,54 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Genereer manifest.json uit plugin header
|
||||||
|
run: |
|
||||||
|
python3 - <<'PY'
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
|
||||||
|
with open('groq-ai-product-text.php', 'r', encoding='utf-8') as handle:
|
||||||
|
content = handle.read()
|
||||||
|
|
||||||
|
header_match = re.search(r'/\*\*(.*?)\*/', content, re.S)
|
||||||
|
header = header_match.group(1) if header_match else ''
|
||||||
|
|
||||||
|
def read_field(label: str) -> str:
|
||||||
|
match = re.search(r'^\s*\*\s*' + re.escape(label) + r'\s*:\s*(.+)$', header, re.M)
|
||||||
|
return match.group(1).strip() if match else ''
|
||||||
|
|
||||||
|
manifest = {
|
||||||
|
'plugin_name': read_field('Plugin Name'),
|
||||||
|
'description': read_field('Description'),
|
||||||
|
'version': read_field('Version'),
|
||||||
|
'author': read_field('Author'),
|
||||||
|
'author_url': read_field('Author URI'),
|
||||||
|
}
|
||||||
|
|
||||||
|
with open('manifest.json', 'w', encoding='utf-8') as handle:
|
||||||
|
json.dump(manifest, handle, ensure_ascii=False, indent=2)
|
||||||
|
|
||||||
|
print('manifest.json aangemaakt/bijgewerkt')
|
||||||
|
PY
|
||||||
|
|
||||||
|
- name: Commit & push manifest.json
|
||||||
|
run: |
|
||||||
|
if git diff --quiet -- manifest.json; then
|
||||||
|
echo "manifest.json ongewijzigd; geen commit nodig."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add manifest.json
|
||||||
|
git commit -m "chore: update manifest.json"
|
||||||
|
git push
|
||||||
|
|
||||||
- name: Check if tag exists
|
- name: Check if tag exists
|
||||||
id: tagcheck
|
id: tagcheck
|
||||||
run: |
|
run: |
|
||||||
TAG="v${{ steps.meta.outputs.version }}"
|
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 "refs/tags/$TAG$"; then
|
||||||
echo "exists=true" >> "$GITHUB_OUTPUT"
|
echo "exists=true" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
echo "exists=false" >> "$GITHUB_OUTPUT"
|
echo "exists=false" >> "$GITHUB_OUTPUT"
|
||||||
@@ -57,20 +101,26 @@ jobs:
|
|||||||
if: steps.tagcheck.outputs.exists == 'false'
|
if: steps.tagcheck.outputs.exists == 'false'
|
||||||
id: package
|
id: package
|
||||||
run: |
|
run: |
|
||||||
|
if ! command -v zip >/dev/null 2>&1; then
|
||||||
|
apt-get update -y
|
||||||
|
apt-get install -y zip
|
||||||
|
fi
|
||||||
|
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
SLUG="siti-ai-product-content-generator"
|
SLUG="siti-ai-product-content-generator"
|
||||||
BUILD_ROOT="$RUNNER_TEMP/build"
|
BUILD_ROOT="$RUNNER_TEMP/build"
|
||||||
DEST_DIR="$BUILD_ROOT/$SLUG"
|
DEST_DIR="$BUILD_ROOT/$SLUG"
|
||||||
mkdir -p "$DEST_DIR"
|
mkdir -p "$DEST_DIR"
|
||||||
|
|
||||||
rsync -a ./ "$DEST_DIR" \
|
tar -cf - \
|
||||||
--exclude '.git/' \
|
--exclude='.git' \
|
||||||
--exclude '.github/' \
|
--exclude='.github' \
|
||||||
--exclude 'docker/' \
|
--exclude='docker' \
|
||||||
--exclude 'docs/' \
|
--exclude='docs' \
|
||||||
--exclude 'dist/' \
|
--exclude='dist' \
|
||||||
--exclude 'docker-compose.yml' \
|
--exclude='docker-compose.yml' \
|
||||||
--exclude 'PLAN.md'
|
--exclude='PLAN.md' \
|
||||||
|
. | tar -xf - -C "$DEST_DIR"
|
||||||
|
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
ZIP_PATH="dist/${SLUG}-${VERSION}.zip"
|
ZIP_PATH="dist/${SLUG}-${VERSION}.zip"
|
||||||
@@ -79,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 }}
|
|
||||||
|
|||||||
@@ -16,11 +16,20 @@ class SitiWebUpdater {
|
|||||||
|
|
||||||
private $authorize_token;
|
private $authorize_token;
|
||||||
|
|
||||||
|
private $api_base_url;
|
||||||
|
|
||||||
|
private $auth_header_scheme;
|
||||||
|
|
||||||
|
private $download_auth_header_scheme;
|
||||||
|
|
||||||
private $github_response;
|
private $github_response;
|
||||||
|
|
||||||
public function __construct( $file ) {
|
public function __construct( $file ) {
|
||||||
|
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
|
$this->api_base_url = 'https://api.github.com';
|
||||||
|
$this->auth_header_scheme = 'bearer';
|
||||||
|
$this->download_auth_header_scheme = 'token';
|
||||||
|
|
||||||
$this->set_plugin_properties();
|
$this->set_plugin_properties();
|
||||||
add_action( 'admin_init', array( $this, 'set_plugin_properties' ) );
|
add_action( 'admin_init', array( $this, 'set_plugin_properties' ) );
|
||||||
@@ -50,15 +59,29 @@ class SitiWebUpdater {
|
|||||||
$this->authorize_token = $token;
|
$this->authorize_token = $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function set_api_base_url( $api_base_url ) {
|
||||||
|
$this->api_base_url = rtrim( (string) $api_base_url, '/' );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_auth_header_scheme( $scheme ) {
|
||||||
|
$this->auth_header_scheme = (string) $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_download_auth_header_scheme( $scheme ) {
|
||||||
|
$this->download_auth_header_scheme = (string) $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
private function get_repository_info() {
|
private function get_repository_info() {
|
||||||
if ( is_null( $this->github_response ) ) { // Do we have a response?
|
if ( is_null( $this->github_response ) ) { // Do we have a response?
|
||||||
$args = array();
|
$args = array();
|
||||||
$request_uri = sprintf( 'https://api.github.com/repos/%s/%s/releases', $this->username, $this->repository ); // Build URI
|
$request_uri = sprintf( '%s/repos/%s/%s/releases', $this->api_base_url, $this->username, $this->repository ); // Build URI
|
||||||
|
|
||||||
$args = array();
|
$args = array();
|
||||||
|
|
||||||
if( $this->authorize_token ) { // Is there an access token?
|
if( $this->authorize_token ) { // Is there an access token?
|
||||||
$args['headers']['Authorization'] = "bearer {$this->authorize_token}"; // Set the headers
|
$scheme = trim( $this->auth_header_scheme );
|
||||||
|
$scheme = '' === $scheme ? 'bearer' : $scheme;
|
||||||
|
$args['headers']['Authorization'] = $scheme . ' ' . $this->authorize_token; // Set the headers
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = json_decode( wp_remote_retrieve_body( wp_remote_get( $request_uri, $args ) ), true ); // Get JSON and parse it
|
$response = json_decode( wp_remote_retrieve_body( wp_remote_get( $request_uri, $args ) ), true ); // Get JSON and parse it
|
||||||
@@ -179,7 +202,9 @@ class SitiWebUpdater {
|
|||||||
|
|
||||||
if ( null !== $args['filename'] ) {
|
if ( null !== $args['filename'] ) {
|
||||||
if( $this->authorize_token ) {
|
if( $this->authorize_token ) {
|
||||||
$args = array_merge( $args, array( "headers" => array( "Authorization" => "token {$this->authorize_token}" ) ) );
|
$scheme = trim( $this->download_auth_header_scheme );
|
||||||
|
$scheme = '' === $scheme ? 'token' : $scheme;
|
||||||
|
$args = array_merge( $args, array( "headers" => array( "Authorization" => $scheme . ' ' . $this->authorize_token ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* Plugin Name: SitiAI Product Teksten
|
* Plugin Name: SitiAI Product Teksten
|
||||||
* Description: Genereer productteksten met diverse AI-aanbieders rechtstreeks vanuit WooCommerce.
|
* Description: Genereer productteksten met diverse AI-aanbieders rechtstreeks vanuit WooCommerce.
|
||||||
* Version: 1.9.0
|
* Version: 1.9.1
|
||||||
* Author: Roberto Guagliardo | SitiWeb
|
* Author: Roberto Guagliardo | SitiWeb
|
||||||
* Author URI: https://sitiweb.nl/
|
* Author URI: https://sitiweb.nl/
|
||||||
* Text Domain: siti-ai-product-content-generator
|
* Text Domain: siti-ai-product-content-generator
|
||||||
@@ -79,6 +79,7 @@ if( ! class_exists( 'SitiWebUpdater' ) ){
|
|||||||
$updater = new SitiWebUpdater( __FILE__ );
|
$updater = new SitiWebUpdater( __FILE__ );
|
||||||
$updater->set_username( 'SitiWeb' );
|
$updater->set_username( 'SitiWeb' );
|
||||||
$updater->set_repository( 'siti-ai-product-content-generator' );
|
$updater->set_repository( 'siti-ai-product-content-generator' );
|
||||||
|
$updater->set_api_base_url( 'https://git.robert.ooo/api/v1' );
|
||||||
$updater->initialize();
|
$updater->initialize();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
7
manifest.json
Normal file
7
manifest.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"plugin_name": "SitiAI Product Teksten",
|
||||||
|
"description": "Genereer productteksten met diverse AI-aanbieders rechtstreeks vanuit WooCommerce.",
|
||||||
|
"version": "1.9.1",
|
||||||
|
"author": "Roberto Guagliardo | SitiWeb",
|
||||||
|
"author_url": "https://sitiweb.nl/"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user