-
-
Notifications
You must be signed in to change notification settings - Fork 10
Add publish.yml #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
glenn-jocher
wants to merge
16
commits into
main
Choose a base branch
from
add-publish
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add publish.yml #75
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
07681aa
Add publish.yml
glenn-jocher f4b64b0
Add publish.yml
glenn-jocher fcbd833
Add publish.yml
glenn-jocher 35211c3
Add publish.yml
glenn-jocher 107b986
Add publish.yml
glenn-jocher c44df84
Add publish.yml
glenn-jocher 8a50c1b
Add publish.yml
glenn-jocher 783e82a
Add publish.yml
glenn-jocher 58f73ea
Add publish.yml
glenn-jocher ecedc1e
Add publish.yml
glenn-jocher fbdecc6
Add publish.yml
glenn-jocher f7dbf07
Add publish.yml
glenn-jocher 0fa622e
Add publish.yml
glenn-jocher 8f17497
Add publish.yml
glenn-jocher 28cfd5b
Add publish.yml
glenn-jocher cb08f3e
Add publish.yml
glenn-jocher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| # Ultralytics π AGPL-3.0 License - https://ultralytics.com/license | ||
|
|
||
| # Publish pip package to PyPI https://pypi.org/project/ultralytics-template/ | ||
|
|
||
| name: Publish to PyPI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
| inputs: | ||
| pypi: | ||
| type: boolean | ||
| description: Publish to PyPI | ||
|
|
||
| jobs: | ||
| check: | ||
| if: github.repository == 'ultralytics/template' && github.actor == 'glenn-jocher' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| outputs: | ||
| increment: ${{ steps.check_pypi.outputs.increment }} | ||
| current_tag: ${{ steps.check_pypi.outputs.current_tag }} | ||
| previous_tag: ${{ steps.check_pypi.outputs.previous_tag }} | ||
| pypi_url: https://pypi.org/p/ultralytics-template | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.x" | ||
| - uses: astral-sh/setup-uv@v7 | ||
| - run: uv pip install --system --no-cache ultralytics-actions | ||
| - id: check_pypi | ||
| shell: python | ||
| run: | | ||
| import os | ||
| from actions.utils import check_pypi_version | ||
| local_version, online_version, publish = check_pypi_version() | ||
| 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 publish: | ||
| print('Ready to publish new version to PyPI β .') | ||
| - name: Tag and Release | ||
| if: steps.check_pypi.outputs.increment == 'True' | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| CURRENT_TAG: ${{ steps.check_pypi.outputs.current_tag }} | ||
| 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 "[email protected]" | ||
| git tag -a "$CURRENT_TAG" -m "$(git log -1 --pretty=%B)" | ||
| git push origin "$CURRENT_TAG" | ||
| ultralytics-actions-summarize-release | ||
| uv cache prune --ci | ||
|
|
||
| build: | ||
| needs: check | ||
| if: needs.check.outputs.increment == 'True' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.x" | ||
| - uses: astral-sh/setup-uv@v7 | ||
| - run: uv pip install --system --no-cache build | ||
| - run: python -m build | ||
| - uses: actions/upload-artifact@v5 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
| - run: uv cache prune --ci | ||
|
|
||
| publish: | ||
| needs: [check, build] | ||
| if: needs.check.outputs.increment == 'True' | ||
| runs-on: ubuntu-latest | ||
| environment: # for GitHub Deployments tab | ||
| name: Release - PyPI | ||
| url: ${{ needs.check.outputs.pypi_url }} | ||
| permissions: | ||
| id-token: write # for PyPI trusted publishing | ||
| steps: | ||
| - uses: actions/download-artifact@v6 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
| - uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
|
||
| sbom: | ||
| needs: [check, build, publish] | ||
| if: needs.check.outputs.increment == 'True' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.x" | ||
| - uses: astral-sh/setup-uv@v7 | ||
| - run: | | ||
| uv venv sbom-env | ||
| uv pip install -e . | ||
| env: | ||
| VIRTUAL_ENV: sbom-env | ||
| - uses: anchore/sbom-action@v0 | ||
| with: | ||
| format: spdx-json | ||
| output-file: sbom.spdx.json | ||
| path: sbom-env | ||
| - run: gh release upload ${{ needs.check.outputs.current_tag }} sbom.spdx.json | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| notify: | ||
| needs: [check, publish] | ||
| if: always() && needs.check.outputs.increment == 'True' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Get short SHA | ||
| id: sha | ||
| run: echo "short=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT | ||
| - name: Notify Slack | ||
| uses: slackapi/[email protected] | ||
| env: | ||
| TITLE: ${{ needs.publish.result == 'success' && format('<!channel> <https://github.com/{0}/actions/runs/{1}|GitHub Actions> {2} {3} for {4} β \nNEW `{0} {5}` <{6}|package> published π', github.repository, github.run_id, github.event_name, needs.publish.result, github.workflow, needs.check.outputs.current_tag, needs.check.outputs.pypi_url) || format('<!channel> <https://github.com/{0}/actions/runs/{1}|GitHub Actions> {2} {3} for {4} β', github.repository, github.run_id, github.event_name, needs.publish.result, github.workflow) }} | ||
| with: | ||
| webhook-type: incoming-webhook | ||
| webhook: ${{ secrets.SLACK_WEBHOOK_URL_YOLO }} | ||
| payload: | | ||
| text: "${{ env.TITLE }}\n\n\n*Repository:* https://github.com/${{ github.repository }}\n*Author:* ${{ github.actor }}\n*Commit:* <https://github.com/${{ github.repository }}/commit/${{ github.sha }}|${{ steps.sha.outputs.short }}> ${{ github.event.head_commit.message }}\n" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Ultralytics π AGPL-3.0 License - https://ultralytics.com/license | ||
|
|
||
| # Test Slack notification logic | ||
|
|
||
| name: Test Notify | ||
|
|
||
| on: | ||
| push: | ||
| workflow_dispatch: | ||
| inputs: | ||
| simulate_success: | ||
| type: boolean | ||
| description: Simulate success (true) or failure (false) | ||
| default: true | ||
|
|
||
| jobs: | ||
| mock_check: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| increment: "True" | ||
| current_tag: v1.0.0 | ||
| previous_tag: v0.9.9 | ||
| pypi_url: https://pypi.org/p/ultralytics-template | ||
| steps: | ||
| - run: echo "Mock check job" | ||
|
|
||
| mock_publish: | ||
| needs: mock_check | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: | | ||
| if [ "${{ github.event.inputs.simulate_success || 'true' }}" = "false" ]; then | ||
| echo "Simulating failure" | ||
| exit 1 | ||
| else | ||
| echo "Simulating success" | ||
| exit 0 | ||
| fi | ||
|
|
||
| notify: | ||
| needs: [mock_check, mock_publish] | ||
| if: always() && needs.mock_check.outputs.increment == 'True' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Get short SHA | ||
| id: sha | ||
| run: echo "short=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT | ||
| - name: Notify Slack | ||
| uses: slackapi/[email protected] | ||
| env: | ||
| TITLE: ${{ needs.mock_publish.result == 'success' && format('<!channel> <https://github.com/{0}/actions/runs/{1}|GitHub Actions> {2} {3} for {4} β \nNEW `{0} {5}` <{6}|package> published π', github.repository, github.run_id, github.event_name, needs.mock_publish.result, github.workflow, needs.mock_check.outputs.current_tag, needs.mock_check.outputs.pypi_url) || format('<!channel> <https://github.com/{0}/actions/runs/{1}|GitHub Actions> {2} {3} for {4} β', github.repository, github.run_id, github.event_name, needs.mock_publish.result, github.workflow) }} | ||
| with: | ||
| webhook-type: incoming-webhook | ||
| webhook: ${{ secrets.SLACK_WEBHOOK_URL_LLM }} | ||
| payload: | | ||
| text: "${{ env.TITLE }}\n\n\n*Repository:* https://github.com/${{ github.repository }}\n*Author:* ${{ github.actor }}\n*Commit:* <https://github.com/${{ github.repository }}/commit/${{ github.sha }}|${{ steps.sha.outputs.short }}> ${{ github.event.head_commit.message }}\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| # Ultralytics π AGPL-3.0 License - https://ultralytics.com/license | ||
|
|
||
| __version__ = "0.0.0" | ||
| __version__ = "0.0.1" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.