-
Notifications
You must be signed in to change notification settings - Fork 179
180 lines (159 loc) · 6.02 KB
/
release-build.yaml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Release Build and Push
on:
workflow_dispatch: # Allows manual trigger
push:
tags:
- 'v*' # This triggers the workflow on any new tag
jobs:
image-release:
runs-on: ubuntu-latest
needs: [cut-github-release]
permissions:
packages: write
contents: read
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Set up Docker Buildx (optional but allows advanced Docker building)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# Log in to Github Registry
# - name: Login to the Container registry
# uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# Build container images with docker registry namespace
- name: Build Container Images
run: |
IS_MAIN_BRANCH=false GIT_COMMIT_HASH=${{ github.ref_name }} make docker-build-all
# Push container image to DockerHub
- name: Push container image to container registry
run: |
IS_MAIN_BRANCH=false GIT_COMMIT_HASH=${{ github.ref_name }} make docker-push-all
# Build container images with Github registry namespace
# - name: Build Container Images with Github Container Registry prefix
# run: |
# IS_MAIN_BRANCH=false GIT_COMMIT_HASH=${{ github.ref_name }} AIBRIX_CONTAINER_REGISTRY_NAMESPACE=ghcr.io/aibrix make docker-build-all
# Push container image to Github container registry
# - name: Push Container Images to Github Container Registry
# run: |
# IS_MAIN_BRANCH=false GIT_COMMIT_HASH=${{ github.ref_name }} AIBRIX_CONTAINER_REGISTRY_NAMESPACE=ghcr.io/aibrix make docker-push-all
python-wheel-release:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
name: publish
steps:
- name: Check out source repository
uses: actions/checkout@v4
- name: Set up Python environment ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
cd python/aibrix
python -m pip install --upgrade pip
pip install -U pip poetry
- name: Build and publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: |
cd python/aibrix
poetry publish --build
- name: Add package to release artifact
run: |
cd python/aibrix
poetry build
ls -al dist/*
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: aibrix-python-packages
path: python/aibrix/dist/*.whl
artifact-release:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Install Kustomize
- name: Install Kustomize
run: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
mv kustomize /usr/local/bin/
# Build Kustomize package
- name: Build Kustomize
run: |
kustomize build config/dependency > aibrix-dependency-${{ github.ref_name }}.yaml
kustomize build config/overlays/release > aibrix-core-${{ github.ref_name }}.yaml
# Upload the Kustomize YAML as a release artifact
- name: Upload Kustomize YAML
uses: actions/upload-artifact@v4
with:
name: aibrix-dependency-${{ github.ref_name }}.yaml
path: aibrix-dependency-${{ github.ref_name }}.yaml
- name: Upload Kustomize YAML
uses: actions/upload-artifact@v4
with:
name: aibrix-core-${{ github.ref_name }}.yaml
path: aibrix-core-${{ github.ref_name }}.yaml
cut-github-release:
runs-on: ubuntu-latest
needs: [python-wheel-release, artifact-release]
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v3
# Download the Kustomize artifact from the previous job
- name: Download Kustomize YAML
uses: actions/download-artifact@v4
with:
name: aibrix-dependency-${{ github.ref_name }}.yaml
- name: Download Kustomize YAML
uses: actions/download-artifact@v4
with:
name: aibrix-core-${{ github.ref_name }}.yaml
- name: Download PYTHON wheels
uses: actions/download-artifact@v4
with:
name: aibrix-python-packages
# Determine if this is a prerelease based on the tag name
# if it contains
- name: Set prerelease flag
id: prerelease_check
run: |
if [[ "${{ github.ref_name }}" == *"rc"* ]]; then
echo "This is a prerelease"
echo "prerelease=true" >> $GITHUB_ENV
else
echo "This is not a prerelease"
echo "prerelease=false" >> $GITHUB_ENV
fi
- name: Create Draft Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }} # Use the tag that triggered the workflow
name: ${{ github.ref_name }} # The name of the release
body: |
Automatically generated release for tag ${{ github.ref_name }}.
draft: true # let's always check the release before officially published.
prerelease: ${{ env.prerelease }}
files: |
aibrix-dependency-${{ github.ref_name }}.yaml
aibrix-core-${{ github.ref_name }}.yaml
aibrix-*.whl
aibrix-python-packages/aibrix-*.whl