From cd5424a21a0141c72e340b904d1487c0cc6e3844 Mon Sep 17 00:00:00 2001 From: Lifei Zhou Date: Thu, 29 Aug 2024 21:03:19 +1000 Subject: [PATCH] moved checktag in the pypi_release workflow --- .github/workflows/ci.yaml | 31 ----------------------------- .github/workflows/pypi_release.yaml | 27 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ea0f7f1c..a34ab367 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,34 +25,3 @@ jobs: run: | uv run pytest tests -m 'not integration' - create_tag: - runs-on: ubuntu-latest - needs: build - if: ${{ github.ref == 'refs/heads/main' }} - - steps: - - uses: actions/checkout@v4 - - - name: Install UV - run: curl -LsSf https://astral.sh/uv/install.sh | sh - - - name: Source Cargo Environment - run: source $HOME/.cargo/env - - - name: Build with UV - run: uvx --from build pyproject-build --installer uv - - - name: Check tag exists - run: | - dist_file_name=$(cd dist && ls goose-ai*.tar.gz) - ./scripts/check_tag_exists.sh $dist_file_name - env: - GITHUB_ENV: $GITHUB_ENV - - - name: Create tag if it doesn't exist - if: env.tag_version != '' - run: | - git tag "v$tag_version" - git push origin "v$tag_version" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pypi_release.yaml b/.github/workflows/pypi_release.yaml index 9cec0346..81aaa181 100644 --- a/.github/workflows/pypi_release.yaml +++ b/.github/workflows/pypi_release.yaml @@ -1,18 +1,19 @@ name: PYPI Release on: - push: - tags: - - 'v*' + workflow_run: + workflows: ["CI"] + types: + - completed jobs: pypi_release: runs-on: ubuntu-latest - + if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }} steps: - uses: actions/checkout@v4 with: - ref: ${{ github.ref }} + ref: ${{ github.event.workflow_run.head_sha }} - name: Install UV run: curl -LsSf https://astral.sh/uv/install.sh | sh @@ -23,7 +24,23 @@ jobs: - name: Build with UV run: uvx --from build pyproject-build --installer uv + - name: Check tag exists + run: | + dist_file_name=$(cd dist && ls goose-ai*.tar.gz) + ./scripts/check_tag_exists.sh $dist_file_name + env: + GITHUB_ENV: $GITHUB_ENV + + - name: Create tag if it doesn't exist + if: env.tag_version != '' + run: | + git tag "v$tag_version" + git push origin "v$tag_version" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish + if: ${{ success() }} uses: pypa/gh-action-pypi-publish@v1.4.2 with: user: __token__