85 lines
2.7 KiB
YAML
85 lines
2.7 KiB
YAML
name: Publish
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Install build tools
|
|
run: pip install build twine
|
|
|
|
- name: Build core package
|
|
run: python -m build packages/foreignthon
|
|
|
|
- name: Build Spanish pack
|
|
run: python -m build packages/langs/es
|
|
|
|
- name: Build Tamil pack
|
|
run: python -m build packages/langs/ta
|
|
|
|
- name: Publish to PyPI
|
|
env:
|
|
TWINE_USERNAME: __token__
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
|
run: |
|
|
twine upload --skip-existing packages/foreignthon/dist/*
|
|
twine upload --skip-existing packages/langs/es/dist/*
|
|
twine upload --skip-existing packages/langs/ta/dist/*
|
|
|
|
|
|
- name: Create Gitea release with assets
|
|
env:
|
|
GIT_RELEASE_TOKEN: ${{ secrets.GIT_RELEASE_TOKEN }}
|
|
run: |
|
|
TAG=${GITHUB_REF#refs/tags/}
|
|
echo "Tag: $TAG"
|
|
|
|
# Delete existing release if any
|
|
EXISTING=$(curl -s \
|
|
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/$TAG")
|
|
EXISTING_ID=$(echo $EXISTING | python -c "import sys,json; d=json.load(sys.stdin); print(d.get('id',''))" 2>/dev/null || echo "")
|
|
|
|
if [ -n "$EXISTING_ID" ]; then
|
|
echo "Deleting existing release $EXISTING_ID"
|
|
curl -s -X DELETE \
|
|
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$EXISTING_ID"
|
|
fi
|
|
|
|
# Create fresh release
|
|
RELEASE=$(curl -s -X POST \
|
|
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"tag_name\": \"$TAG\",
|
|
\"name\": \"$TAG\",
|
|
\"body\": \"Release $TAG\",
|
|
\"draft\": false,
|
|
\"prerelease\": false
|
|
}" \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases")
|
|
|
|
echo "Release response: $RELEASE"
|
|
RELEASE_ID=$(echo $RELEASE | python -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
|
|
|
for FILE in packages/foreignthon/dist/* packages/langs/es/dist/*; do
|
|
echo "Uploading $FILE"
|
|
curl -s -X POST \
|
|
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
|
-F "attachment=@$FILE" \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$RELEASE_ID/assets"
|
|
done
|