handle existing release on retag
This commit is contained in:
@@ -31,16 +31,30 @@ jobs:
|
||||
TWINE_USERNAME: __token__
|
||||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
||||
run: |
|
||||
twine upload packages/foreignthon/dist/*
|
||||
twine upload packages/langs/es/dist/*
|
||||
twine upload --skip-existing packages/foreignthon/dist/*
|
||||
twine upload --skip-existing packages/langs/es/dist/*
|
||||
|
||||
- name: Create Gitea release with assets
|
||||
env:
|
||||
GIT_RELEASE_TOKEN: ${{ secrets.GIT_RELEASE_TOKEN }}
|
||||
run: |
|
||||
TAG=${GITHUB_REF#refs/tags/}
|
||||
echo "Tag is: $TAG"
|
||||
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" \
|
||||
@@ -53,11 +67,11 @@ jobs:
|
||||
}" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases")
|
||||
|
||||
echo "Gitea API response: $RELEASE"
|
||||
|
||||
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" \
|
||||
|
||||
Reference in New Issue
Block a user