Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

jobs:
check:
if: github.repository == 'ultralytics/mkdocs' && github.actor == 'glenn-jocher'
if: github.repository == 'ultralytics/mkdocs' && github.actor == 'glenn-jocher' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -32,13 +32,17 @@ jobs:
- run: uv pip install --system --no-cache ultralytics-actions
- id: check_pypi
shell: python
env:
PYPI_DISPATCH: ${{ github.event.inputs.pypi }}
run: |
import os
from actions.utils import check_pypi_version
local_version, online_version, publish = check_pypi_version()
publish = publish or os.environ.get("PYPI_DISPATCH") == "true" # manual recovery re-run
os.system(f'echo "increment={publish}" >> $GITHUB_OUTPUT')
os.system(f'echo "current_tag=v{local_version}" >> $GITHUB_OUTPUT')
os.system(f'echo "previous_tag=v{online_version}" >> $GITHUB_OUTPUT')
if online_version != local_version: # empty on recovery re-runs so summarize falls back to the true previous tag
os.system(f'echo "previous_tag=v{online_version}" >> $GITHUB_OUTPUT')
if publish:
print('Ready to publish new version to PyPI βœ….')
- name: Tag and Release
Expand All @@ -49,11 +53,16 @@ jobs:
PREVIOUS_TAG: ${{ steps.check_pypi.outputs.previous_tag }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
git config --global user.name "UltralyticsAssistant"
git config --global user.email "web@ultralytics.com"
git tag -a "$CURRENT_TAG" -m "$(git log -1 --pretty=%B)"
git push origin "$CURRENT_TAG"
ultralytics-actions-summarize-release
if [ -z "$(git ls-remote --tags origin "refs/tags/$CURRENT_TAG")" ]; then
git config --global user.name "UltralyticsAssistant"
git config --global user.email "web@ultralytics.com"
git tag -a "$CURRENT_TAG" -m "$(git log -1 --pretty=%B)"
git push origin "$CURRENT_TAG"
fi
if ! gh release view "$CURRENT_TAG" >/dev/null 2>&1; then
[ -n "$PREVIOUS_TAG" ] || git fetch --unshallow --tags # summarize resolves the previous tag from git history
ultralytics-actions-summarize-release
fi
uv cache prune --ci

build:
Expand Down Expand Up @@ -91,6 +100,8 @@ jobs:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true # tolerate recovery re-runs after partial failures

sbom:
needs: [check, build, publish]
Expand All @@ -114,12 +125,12 @@ jobs:
format: spdx-json
output-file: sbom.spdx.json
path: sbom-env
- run: gh release upload ${{ needs.check.outputs.current_tag }} sbom.spdx.json
- run: gh release upload ${{ needs.check.outputs.current_tag }} sbom.spdx.json --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

notify:
needs: [check, publish]
needs: [check, publish, sbom]
if: always() && needs.check.outputs.increment == 'True'
runs-on: ubuntu-latest
permissions:
Expand All @@ -136,15 +147,15 @@ jobs:
TITLE=$(printf '%s' "$TITLE" | sed -E "s@#([0-9]+)@<https://github.com/$GH_REPO/pull/\1|#\1>@g")
echo "title=$TITLE" >> "$GITHUB_OUTPUT"
- name: Notify Success
if: needs.publish.result == 'success' && github.event_name == 'push'
if: needs.publish.result == 'success' && needs.sbom.result == 'success' && github.event_name == 'push'
uses: slackapi/slack-github-action@v3.0.3
with:
webhook-type: incoming-webhook
webhook: ${{ secrets.SLACK_WEBHOOK_URL_YOLO }}
payload: |
text: "<!subteam^S082BPCRAJ3> *${{ github.workflow }}* βœ… `${{ github.repository }}` ${{ steps.release.outputs.title || needs.check.outputs.current_tag }} <https://github.com/${{ github.repository }}/releases/tag/${{ needs.check.outputs.current_tag }}|*Release*> Β· <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|*Run*>"
- name: Notify Failure
if: needs.publish.result != 'success'
if: needs.publish.result != 'success' || needs.sbom.result != 'success'
uses: slackapi/slack-github-action@v3.0.3
with:
webhook-type: incoming-webhook
Expand Down
Loading