per-package independent releases via prefixed tags
This commit is contained in:
@@ -3,7 +3,8 @@ name: Publish
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "foreignthon-v*"
|
||||||
|
- "foreignthon-*-v*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
@@ -20,62 +21,67 @@ jobs:
|
|||||||
- name: Install build tools
|
- name: Install build tools
|
||||||
run: pip install build twine
|
run: pip install build twine
|
||||||
|
|
||||||
- name: Build core package
|
- name: Determine what to build
|
||||||
run: python -m build packages/foreignthon
|
id: target
|
||||||
|
run: |
|
||||||
|
TAG=${GITHUB_REF#refs/tags/}
|
||||||
|
echo "Full tag: $TAG"
|
||||||
|
|
||||||
- name: Build Spanish pack
|
if [[ "$TAG" == "foreignthon-v"* ]]; then
|
||||||
run: python -m build packages/langs/es
|
# 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
|
- name: Build package
|
||||||
run: python -m build packages/langs/ta
|
run: python -m build ${{ steps.target.outputs.path }}
|
||||||
|
|
||||||
- name: Publish to PyPI
|
- name: Publish to PyPI
|
||||||
env:
|
env:
|
||||||
TWINE_USERNAME: __token__
|
TWINE_USERNAME: __token__
|
||||||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
||||||
run: |
|
run: twine upload --skip-existing ${{ steps.target.outputs.path }}/dist/*
|
||||||
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
|
- name: Create Gitea release with assets
|
||||||
env:
|
env:
|
||||||
GIT_RELEASE_TOKEN: ${{ secrets.GIT_RELEASE_TOKEN }}
|
GIT_RELEASE_TOKEN: ${{ secrets.GIT_RELEASE_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
TAG=${GITHUB_REF#refs/tags/}
|
TAG=${GITHUB_REF#refs/tags/}
|
||||||
echo "Tag: $TAG"
|
|
||||||
|
|
||||||
# Delete existing release if any
|
|
||||||
EXISTING=$(curl -s \
|
EXISTING=$(curl -s \
|
||||||
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
||||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/$TAG")
|
"${{ 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
|
if [ -n "$EXISTING_ID" ]; then
|
||||||
echo "Deleting existing release $EXISTING_ID"
|
|
||||||
curl -s -X DELETE \
|
curl -s -X DELETE \
|
||||||
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
||||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$EXISTING_ID"
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$EXISTING_ID"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create fresh release
|
|
||||||
RELEASE=$(curl -s -X POST \
|
RELEASE=$(curl -s -X POST \
|
||||||
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{
|
-d "{
|
||||||
\"tag_name\": \"$TAG\",
|
\"tag_name\": \"$TAG\",
|
||||||
\"name\": \"$TAG\",
|
\"name\": \"${{ steps.target.outputs.name }} ${TAG##*-v}\",
|
||||||
\"body\": \"Release $TAG\",
|
\"body\": \"Release of ${{ steps.target.outputs.name }} ${TAG##*-v}\",
|
||||||
\"draft\": false,
|
\"draft\": false,
|
||||||
\"prerelease\": false
|
\"prerelease\": false
|
||||||
}" \
|
}" \
|
||||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases")
|
"${{ 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'])")
|
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"
|
echo "Uploading $FILE"
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
-H "Authorization: token $GIT_RELEASE_TOKEN" \
|
||||||
|
|||||||
Reference in New Issue
Block a user