per-package independent releases via prefixed tags
This commit is contained in:
@@ -3,7 +3,8 @@ name: Publish
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
- "foreignthon-v*"
|
||||
- "foreignthon-*-v*"
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
@@ -20,62 +21,67 @@ jobs:
|
||||
- name: Install build tools
|
||||
run: pip install build twine
|
||||
|
||||
- name: Build core package
|
||||
run: python -m build packages/foreignthon
|
||||
- name: Determine what to build
|
||||
id: target
|
||||
run: |
|
||||
TAG=${GITHUB_REF#refs/tags/}
|
||||
echo "Full tag: $TAG"
|
||||
|
||||
- name: Build Spanish pack
|
||||
run: python -m build packages/langs/es
|
||||
if [[ "$TAG" == "foreignthon-v"* ]]; then
|
||||
# Core package: foreignthon-v0.2.0
|
||||
echo "type=core" >> $GITHUB_OUTPUT
|
||||
echo "path=packages/foreignthon" >> $GITHUB_OUTPUT
|
||||
echo "name=foreignthon" >> $GITHUB_OUTPUT
|
||||
elif [[ "$TAG" == "foreignthon-"*"-v"* ]]; then
|
||||
# Lang pack: foreignthon-es-v0.1.0 → lang code is "es"
|
||||
LANG=$(echo $TAG | sed 's/foreignthon-\(.*\)-v.*/\1/')
|
||||
echo "type=lang" >> $GITHUB_OUTPUT
|
||||
echo "path=packages/langs/$LANG" >> $GITHUB_OUTPUT
|
||||
echo "name=foreignthon-$LANG" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Build Tamil pack
|
||||
run: python -m build packages/langs/ta
|
||||
- name: Build package
|
||||
run: python -m build ${{ steps.target.outputs.path }}
|
||||
|
||||
- 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/*
|
||||
|
||||
run: twine upload --skip-existing ${{ steps.target.outputs.path }}/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 "")
|
||||
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\",
|
||||
\"name\": \"${{ steps.target.outputs.name }} ${TAG##*-v}\",
|
||||
\"body\": \"Release of ${{ steps.target.outputs.name }} ${TAG##*-v}\",
|
||||
\"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
|
||||
for FILE in ${{ steps.target.outputs.path }}/dist/*; do
|
||||
echo "Uploading $FILE"
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
||||
|
||||
Reference in New Issue
Block a user