-
Notifications
You must be signed in to change notification settings - Fork 0
456 lines (381 loc) · 16.7 KB
/
Copy pathconda-publish.yml
File metadata and controls
456 lines (381 loc) · 16.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# .github/workflows/conda-build-publish.yml
name: Conda-Build, Test, and Publish Package
on:
workflow_dispatch:
inputs:
version:
description: 'Package version (leave empty for latest from PyPI)'
required: false
type: string
release:
types: [published]
jobs:
build-publish:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.14"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# ================================================================
# ADIM 1: PyPI'den Son Sürüm Bilgilerini Çek
# ================================================================
- name: Fetch latest version info from PyPI
id: pypi_info
run: |
if [ -n "${{ inputs.version }}" ]; then
PKG_VERSION="${{ inputs.version }}"
echo "📌 Manuel sürüm kullanılıyor: $PKG_VERSION"
else
echo "🔍 PyPI'den son sürüm bilgisi çekiliyor..."
PYPI_JSON=$(curl -s https://pypi.org/pypi/kha256/json)
PKG_VERSION=$(echo "$PYPI_JSON" | python3 -c "
import sys, json
data = json.load(sys.stdin)
print(data['info']['version'])
")
echo "✅ PyPI'den çekilen sürüm: $PKG_VERSION"
fi
echo "PKG_VERSION=$PKG_VERSION" >> $GITHUB_ENV
echo "version=$PKG_VERSION" >> $GITHUB_OUTPUT
# ================================================================
# ADIM 2: PyPI'den Source URL ve BLAKE2b-256 Hash Çek
# ================================================================
- name: Fetch PyPI source URL and BLAKE2b-256 hash
id: pypi_source
run: |
echo "📦 PyPI source bilgileri çekiliyor (sürüm: $PKG_VERSION)..."
PYPI_JSON=$(curl -s "https://pypi.org/pypi/kha256/$PKG_VERSION/json")
SOURCE_INFO=$(echo "$PYPI_JSON" | python3 -c "
import sys, json
data = json.load(sys.stdin)
for url_info in data['urls']:
if url_info['packagetype'] == 'sdist':
print(f\"URL={url_info['url']}\")
print(f\"HASH={url_info['digests']['blake2b_256']}\")
break
else:
for url_info in data['urls']:
if url_info['packagetype'] == 'bdist_wheel':
print(f\"URL={url_info['url']}\")
print(f\"HASH={url_info['digests']['blake2b_256']}\")
break
")
PYPI_URL=$(echo "$SOURCE_INFO" | grep "^URL=" | cut -d'=' -f2-)
PYPI_HASH=$(echo "$SOURCE_INFO" | grep "^HASH=" | cut -d'=' -f2-)
if [ -z "$PYPI_URL" ] || [ -z "$PYPI_HASH" ]; then
echo "❌ HATA: PyPI'den source bilgileri çekilemedi!"
exit 1
fi
echo "✅ Source URL: $PYPI_URL"
echo "✅ BLAKE2b-256: $PYPI_HASH"
echo "PYPI_URL=$PYPI_URL" >> $GITHUB_ENV
echo "PYPI_HASH=$PYPI_HASH" >> $GITHUB_ENV
# ================================================================
# ADIM 3: meta.yaml Dosyasını Dinamik Olarak Güncelle
# ================================================================
- name: Update meta.yaml with PyPI source info
run: |
echo "📝 meta.yaml dosyası güncelleniyor..."
python3 << 'EOF'
import os
import re
pypi_url = os.environ['PYPI_URL']
pypi_hash = os.environ['PYPI_HASH']
pkg_version = os.environ['PKG_VERSION']
meta_file = 'meta.yaml'
with open(meta_file, 'r', encoding='utf-8') as f:
content = f.read()
content = re.sub(
r'(url:\s*)(["\']?)(.*?)\2',
f'url: "{pypi_url}"',
content,
count=1
)
content = re.sub(
r'(blake2b-256:\s*)(["\']?)(.*?)\2',
f'blake2b-256: "{pypi_hash}"',
content,
count=1
)
content = re.sub(
r'(version:\s*)(["\']?)(.*?)\2',
f'version: "{pkg_version}"',
content,
count=1
)
with open(meta_file, 'w', encoding='utf-8') as f:
f.write(content)
print(f"✅ meta.yaml güncellendi:")
print(f" version: {pkg_version}")
print(f" url: {pypi_url}")
print(f" blake2b-256: {pypi_hash}")
EOF
echo ""
echo "📄 Güncellenmiş meta.yaml (source bölümü):"
grep -A 3 "^source:" meta.yaml
# ================================================================
# ADIM 4: Miniconda Kurulumu
# ================================================================
- name: Setup Miniconda for Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: true
python-version: "${{ matrix.python-version }}"
channels: conda-forge,bilgi,defaults
channel-priority: strict
miniforge-version: latest
- name: Install Conda-Build
run: |
echo "📦 Conda-build kuruluyor..."
conda config --add channels bilgi
conda config --set channel_priority strict
conda install -n base -y \
conda-build \
anaconda-client
conda info
# ================================================================
# ADIM 5: Conda Paketi Oluştur (TEMİZLİK DAHİL)
# ================================================================
- name: Clean environment before build
run: |
echo "🧹 Derleme öncesi temizlik yapılıyor..."
rm -rf build/ dist/ *.egg-info kha256.egg-info
find . -type d -name "__pycache__" -exec rm -rf {} + || true
find . -name "*.pyc" -delete || true
conda clean --all --yes
- name: Build the package (skip tests)
run: |
echo "=========================================="
echo "🔨 Conda Paketi Oluşturuluyor"
echo "=========================================="
echo "Sürüm: $PKG_VERSION"
echo "Python: ${{ matrix.python-version }}"
echo "Source URL: $PYPI_URL"
echo "BLAKE2b-256: $PYPI_HASH"
echo "=========================================="
conda build . \
--python ${{ matrix.python-version }} \
--no-test \
--output-folder ./dist
if [ -z "$(ls -A dist 2>/dev/null)" ]; then
echo "❌ HATA: Hiçbir conda paketi oluşturulamadı!"
exit 1
fi
echo ""
echo "✅ Oluşturulan paketler ve boyutları:"
ls -lh dist/noarch/
# ================================================================
# ADIM 6: Test Ortamı Oluştur (Temel Paketler)
# ================================================================
- name: Create test environment
run: |
echo "🧪 Test ortamı oluşturuluyor (temel paketler)..."
# Sadece temel bilimsel paketleri kur
conda create -n test-env -y \
python=${{ matrix.python-version }} \
numpy \
pandas \
scipy \
ipython \
ipywidgets \
pytest \
pytest-cov \
-c conda-forge -c bilgi
# kececinumbers ekle
conda install -n test-env -y kececinumbers -c bilgi
echo ""
echo "✅ Temel paketler kuruldu"
# ================================================================
# ADIM 7: Kriptografik Paketleri Conda ile Kur
# ================================================================
- name: Install cryptographic packages with conda
run: |
echo "🔐 Kriptografik paketler conda ile kuruluyor..."
# Her paketi ayrı ayrı kur (solver hatası önlemek için)
echo "📦 cryptography kuruluyor..."
conda install -n test-env -y cryptography -c conda-forge
echo "📦 pycryptodome kuruluyor..."
conda install -n test-env -y pycryptodome -c conda-forge
echo "📦 bcrypt kuruluyor..."
conda install -n test-env -y bcrypt -c conda-forge
echo "📦 argon2-cffi kuruluyor..."
conda install -n test-env -y argon2-cffi -c conda-forge
echo "📦 blake3 kuruluyor..."
conda install -n test-env -y blake3 -c conda-forge
echo "📦 python-xxhash kuruluyor..."
conda install -n test-env -y python-xxhash -c conda-forge
echo "📦 aiohttp kuruluyor..."
conda install -n test-env -y aiohttp -c conda-forge
echo "📦 python-dotenv kuruluyor..."
conda install -n test-env -y python-dotenv -c conda-forge
echo "📦 nest-asyncio2 kuruluyor..."
conda install -n test-env -y nest-asyncio2 -c conda-forge
echo ""
echo "✅ Kriptografik paketler kuruldu:"
conda list -n test-env | grep -E "(aiohttp|dotenv|nest-asyncio2|cryptography|pycryptodome|bcrypt|argon2|blake3|python-xxhash)" || true
# ================================================================
# ADIM 8: Oluşturulan Paketi Kur
# ================================================================
- name: Install the built package
run: |
echo "📦 Oluşturulan paket kuruluyor..."
PACKAGE_FILE=$(find dist -name "*.conda" -o -name "*.tar.bz2" | head -n 1)
if [ -z "$PACKAGE_FILE" ]; then
echo "❌ HATA: Kurulacak paket dosyası bulunamadı!"
exit 1
fi
echo "✅ Kurulan paket: $PACKAGE_FILE"
# Paketi kur (--no-deps: bağımlılıkları tekrar kurma, zaten kurulu)
conda install -n test-env -y --no-deps "$PACKAGE_FILE"
echo ""
echo "✅ Tüm paketler:"
conda list -n test-env | grep -E "(kha256|aiohttp|dotenv|nest-asyncio2|cryptography|pycryptodome|bcrypt|argon2|blake3|python-xxhash)" || true
# ================================================================
# ADIM 9: Paket Import Testi
# ================================================================
- name: Verify package import
run: |
echo "🔍 Paket import testi yapılıyor..."
conda run -n test-env python -c "
import kha256
import kececinumbers
import bcrypt
import argon2
import blake3
import xxhash
import aiohttp
import dotenv
import nest_asyncio2
from Crypto.Cipher import ChaCha20
print('✅ Tüm bağımlılıklar başarıyla yüklendi!')
print(f'📦 KHA-256 version: {kha256.__version__}')
print(f'📦 bcrypt version: {bcrypt.__version__}')
print(f'📦 argon2 version: {argon2.__version__}')
print(f'📦 blake3 version: {blake3.__version__}')
print(f'📦 xxhash version: {xxhash.VERSION}')
print(f'📦 aiohttp version: {aiohttp.__version__}')
print(f'📦 PyCryptodome: Crypto modülü çalışıyor')
try:
result = kha256.quick_hash('test')
print(f'✅ quick_hash testi başarılı: {result[:16]}...')
except Exception as e:
print(f'⚠️ quick_hash testi başarısız: {e}')
"
# ================================================================
# ADIM 10: Debug (Başarısızlık Durumu)
# ================================================================
- name: Debug - Environment info
if: failure()
run: |
echo "=========================================="
echo "🔍 Hata Ayıklama Bilgileri"
echo "=========================================="
conda info
echo ""
echo "Test ortamı paketleri:"
conda list -n test-env || echo "test-env yok"
echo ""
echo "Ortam detayları:"
conda env export -n test-env || echo "test-env export başarısız"
# ================================================================
# ADIM 11: Anaconda Cloud'a Yükle (DÜZELTİLDİ)
# ================================================================
- name: Upload to Anaconda Cloud
if: success()
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
echo "📤 Anaconda Cloud'a yükleniyor..."
# 1. Token kontrolü
if [ -z "$ANACONDA_TOKEN" ]; then
echo "❌ HATA: ANACONDA_TOKEN GitHub Secrets'ta tanımlı değil!"
exit 1
fi
echo "✅ Token bulundu."
# 2. Conda bin yolunu tanımla
CONDA_BIN="$CONDA/bin"
echo "🔧 Conda executable yolu: $CONDA_BIN"
# anaconda-client yüklü mü kontrol et
if ! command -v $CONDA_BIN/anaconda &> /dev/null; then
echo "⚠️ anaconda-client bulunamadı, kuruluyor..."
conda install -n base -y anaconda-client
else
echo "✅ anaconda-client zaten kurulu."
fi
# 3. Token doğrulama
echo "🔍 Token doğrulanıyor..."
$CONDA_BIN/anaconda -t $ANACONDA_TOKEN whoami
if [ $? -ne 0 ]; then
echo "❌ HATA: Token geçersiz veya Anaconda'ya bağlanılamadı!"
exit 1
fi
echo "✅ Token geçerli!"
# 4. Paket dosyalarını bul
PACKAGE_FILES=$(find dist -name "*.conda" -o -name "*.tar.bz2")
if [ -z "$PACKAGE_FILES" ]; then
echo "❌ HATA: Yüklenecek paket dosyası bulunamadı!"
exit 1
fi
echo "✅ Yüklenecek paketler:"
echo "$PACKAGE_FILES"
# 5. Yükleme işlemini yap (DÜZELTİLDİ: --verbose kaldırıldı)
UPLOAD_SUCCESS=false
for pkg in $PACKAGE_FILES; do
echo ""
echo "📦 Yükleniyor: $pkg"
# --verbose KALDIRILDI, sadece --force kullanılıyor
$CONDA_BIN/anaconda -t $ANACONDA_TOKEN upload \
"$pkg" \
--user bilgi \
--label main \
--force
if [ $? -eq 0 ]; then
echo "✅ Başarıyla yüklendi: $pkg"
UPLOAD_SUCCESS=true
else
echo "❌ Yükleme başarısız: $pkg"
exit 1 # Hata durumunda workflow'u durdur
fi
done
# 6. Gerçek başarı kontrolü
if [ "$UPLOAD_SUCCESS" = true ]; then
echo ""
echo "=========================================="
echo "🎉 TÜM PAKETLER ANACONDA CLOUD'A YÜKLENDİ"
echo "🔗 Kontrol: https://anaconda.org/bilgi/kha256"
echo "=========================================="
else
echo ""
echo "❌ HATA: Hiçbir paket yüklenemedi!"
exit 1
fi
# ================================================================
# ADIM 12: Temizlik
# ================================================================
- name: Cleanup
if: always()
run: |
echo "🧹 Temizlik yapılıyor..."
conda env remove -n test-env || true
rm -rf dist/ build/ || true
echo "✅ Temizlik tamamlandı"
# ================================================================
# ADIM 13: Özet
# ================================================================
- name: Summary
if: success()
run: |
echo "=========================================="
echo "✅ CONDA BUILD VE YAYINLAMA BAŞARILI"
echo "=========================================="
echo "📦 Paket: kha256"
echo "🏷️ Sürüm: $PKG_VERSION"
echo "🐍 Python: ${{ matrix.python-version }}"
echo "🔗 PyPI URL: $PYPI_URL"
echo "🔒 BLAKE2b-256: $PYPI_HASH"
echo "📤 Anaconda: https://anaconda.org/bilgi/kha256"
echo "=========================================="