-
Notifications
You must be signed in to change notification settings - Fork 75
107 lines (93 loc) · 3.94 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Main - post-commit
on:
workflow_dispatch: # Allows running from actions tab
push:
branches:
- main
concurrency:
group: main-${{ github.ref_name }}
cancel-in-progress: false
jobs:
detect-version-changed:
runs-on: ubuntu-20.04
outputs:
version_changed: ${{ steps.versions.outputs.version_changed }}
new_version: ${{ steps.versions.outputs.new_version }}
new_base_image_version: ${{ steps.versions.outputs.new_base_image_version }}
build_base_images: ${{ steps.versions.outputs.build_base_images }}
release_version: ${{ steps.versions.outputs.release_version }}
is_prerelease_version: ${{ steps.versions.outputs.is_prerelease_version }}
steps:
- uses: actions/checkout@v4
with:
# We need to use a different github token because GITHUB_TOKEN cannot trigger a workflow from another
token: ${{secrets.BASETENBOT_GITHUB_TOKEN}}
fetch-depth: 2
- uses: ./.github/actions/detect-versions/
id: versions
build-and-push-truss-base-images-if-needed:
needs: [detect-version-changed]
if: needs.detect-version-changed.outputs.build_base_images == 'true'
runs-on: ubuntu-20.04
strategy:
matrix:
python_version: ["3.8", "3.9", "3.10", "3.11"]
use_gpu: ["y", "n"]
job_type: ["server"]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python/
- run: poetry install --with=dev,dev-server --extras=all
- shell: bash
run: |
poetry run bin/generate_base_images.py \
--use-gpu ${{ matrix.use_gpu }} \
--python-version ${{ matrix.python_version }} \
--job-type ${{ matrix.job_type }} \
--version-tag ${{ needs.detect-version-changed.outputs.new_base_image_version }} \
--skip-login --push
integration-tests:
needs: [detect-version-changed, build-and-push-truss-base-images-if-needed]
if: ${{ !failure() && !cancelled() && (needs.build-and-push-truss-base-images-if-needed.result == 'success' || needs.build-and-push-truss-base-images-if-needed.result == 'skipped') }}
uses: ./.github/workflows/_integration_test_shared.yml
publish-rc-to-pypi:
needs: [detect-version-changed]
if: ${{ !failure() && !cancelled() && needs.detect-version-changed.outputs.release_version == 'true' && needs.detect-version-changed.outputs.is_prerelease_version == 'true' }}
runs-on: ubuntu-20.04
steps:
- name: "Git tag release"
uses: actions/checkout@v4
with:
token: ${{secrets.BASETENBOT_GITHUB_TOKEN}}
- run: |
NEW_VERSION=v${{ needs.detect-version-changed.outputs.new_version }}
git config --global user.name "Github action"
git config --global user.email "github.action@baseten.co"
git tag -a $NEW_VERSION -m "Release $NEW_VERSION"
git push origin $NEW_VERSION
- uses: ./.github/actions/setup-python/
- name: Install poetry packages
run: poetry install --extras=all
- name: Build
run: poetry build
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
token: ${{ secrets.BASETENBOT_GITHUB_TOKEN }}
draft: false
prerelease: ${{ needs.detect-version-changed.outputs.is_prerelease_version }}
generateReleaseNotes: true
makeLatest: true
skipIfReleaseExists: true
tag: "v${{ needs.detect-version-changed.outputs.new_version }}"
- name: Publish to PyPI
if: ${{ github.event_name != 'pull_request' }}
run: poetry publish -u "${{ secrets.PYPI_USERNAME }}" -p "${{ secrets.PYPI_PASSWORD }}"