From b47d4e20d154f939e9cd27fae5971585d95463e9 Mon Sep 17 00:00:00 2001 From: cuiyaning Date: Mon, 26 May 2025 07:35:03 +0000 Subject: [PATCH 1/3] [chore] create github release if not exists --- .github/workflows/docker.yml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bd910a9..8bc234e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,7 +4,7 @@ on: push: branches: - main - - pypi_test + - actions jobs: publish_package: @@ -45,3 +45,27 @@ jobs: TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | python -m twine upload dist/* + + + - name: Check if GitHub Release exists + id: check-release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + TAG="v${{ steps.version.outputs.version }}" + EXISTS=$(gh release view "$TAG" > /dev/null 2>&1 && echo "yes" || echo "no") + echo "exists=$EXISTS" >> "$GITHUB_OUTPUT" + + + - name: Debug Release Check + run: | + echo "Release exists: ${{ steps.check-release.outputs.exists }}" + + - name: Create GitHub Release + if: steps.check-release.outputs.exists == 'no' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create v${{ steps.version.outputs.version }} dist/* \ + --title "Release v${{ steps.version.outputs.version }}" \ + --notes "Automated release from GitHub Actions" \ No newline at end of file From 3606702d39cc5752066753d494f5081363990695 Mon Sep 17 00:00:00 2001 From: cuiyaning Date: Mon, 26 May 2025 07:37:30 +0000 Subject: [PATCH 2/3] [chore] add release info in docker.yml --- .github/workflows/docker.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8bc234e..30d59fb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -54,6 +54,8 @@ jobs: run: | TAG="v${{ steps.version.outputs.version }}" EXISTS=$(gh release view "$TAG" > /dev/null 2>&1 && echo "yes" || echo "no") + echo "Release tag: $TAG" + echo "Release exists: $EXISTS" echo "exists=$EXISTS" >> "$GITHUB_OUTPUT" From c1d8631519d99e13035ab3ee340763558dea0f4f Mon Sep 17 00:00:00 2001 From: cuiyaning Date: Mon, 26 May 2025 07:46:44 +0000 Subject: [PATCH 3/3] [chore] unified the release and pypi in CI --- .github/workflows/docker.yml | 51 ++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 30d59fb..edb75bf 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -8,9 +8,9 @@ on: jobs: publish_package: - name: Publish package - + name: Build and Publish runs-on: ubuntu-latest + steps: - uses: actions/checkout@v3 @@ -22,30 +22,35 @@ jobs: run: | pip install setuptools wheel twine - - name: Build core package + - name: Extract version info + id: version + run: | + VERSION=$(python setup.py --version) + PACKAGE_NAME=$(python setup.py --name) + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "package_name=$PACKAGE_NAME" >> $GITHUB_OUTPUT + + - name: Build package env: FLASH_ATTENTION_SKIP_CUDA_BUILD: "TRUE" run: | - python setup.py sdist --dist-dir=dist + python setup.py sdist bdist_wheel --dist-dir=dist - name: Check if version exists on PyPI - id: check-version + id: check-pypi run: | - VERSION=$(python setup.py --version) - PACKAGE_NAME=$(python setup.py --name) - echo "Detected version: $VERSION" - echo "Detected package: $PACKAGE_NAME" - EXISTS=$(curl --silent -f https://pypi.org/pypi/${PACKAGE_NAME}/${VERSION}/json > /dev/null && echo "yes" || echo "no") + VERSION="${{ steps.version.outputs.version }}" + PACKAGE="${{ steps.version.outputs.package_name }}" + EXISTS=$(curl --silent -f https://pypi.org/pypi/${PACKAGE}/${VERSION}/json > /dev/null && echo "yes" || echo "no") echo "exists=$EXISTS" >> "$GITHUB_OUTPUT" - - name: Deploy to PyPI - if: steps.check-version.outputs.exists == 'no' + - name: Upload to PyPI + if: steps.check-pypi.outputs.exists == 'no' env: TWINE_USERNAME: "__token__" TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | - python -m twine upload dist/* - + twine upload dist/* - name: Check if GitHub Release exists id: check-release @@ -54,14 +59,7 @@ jobs: run: | TAG="v${{ steps.version.outputs.version }}" EXISTS=$(gh release view "$TAG" > /dev/null 2>&1 && echo "yes" || echo "no") - echo "Release tag: $TAG" - echo "Release exists: $EXISTS" - echo "exists=$EXISTS" >> "$GITHUB_OUTPUT" - - - - name: Debug Release Check - run: | - echo "Release exists: ${{ steps.check-release.outputs.exists }}" + echo "exists=$EXISTS" >> $GITHUB_OUTPUT - name: Create GitHub Release if: steps.check-release.outputs.exists == 'no' @@ -70,4 +68,11 @@ jobs: run: | gh release create v${{ steps.version.outputs.version }} dist/* \ --title "Release v${{ steps.version.outputs.version }}" \ - --notes "Automated release from GitHub Actions" \ No newline at end of file + --notes "Automated release from GitHub Actions" + + - name: Debug Info (optional) + run: | + echo "Package: ${{ steps.version.outputs.package_name }}" + echo "Version: ${{ steps.version.outputs.version }}" + echo "PyPI Exists: ${{ steps.check-pypi.outputs.exists }}" + echo "GitHub Release Exists: ${{ steps.check-release.outputs.exists }}"