-
Notifications
You must be signed in to change notification settings - Fork 442
210 lines (188 loc) · 8.06 KB
/
prepare_release.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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
---
name: prepare-release
on:
# TODO: Change this back into pull_request
push:
branches: [misc/prepare-release-*]
env:
ZENML_ANALYTICS_OPT_IN: false
jobs:
prepare-release:
if: contains(github.event.head_commit.message, '[prepare]') && github.repository == 'zenml-io/zenml' # TODO: Remove
runs-on: ubuntu-latest
steps:
# 0. Check out the repository
- name: Checkout code
uses: actions/[email protected]
# 0. Extract the version name
- name: Extract version from branch name
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
VERSION=${BRANCH_NAME#misc/prepare-release-}
echo "VERSION=$VERSION" >> $GITHUB_ENV
# 0. Set up python
- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.12'
# 0. Configure Git
- name: Configure git
shell: bash
run: |
git config --global user.email "[email protected]"
git config --global user.name "ZenML GmbH"
# 0. Install ZenML
- name: Install ZenML and dependencies
shell: bash
run: |
scripts/install-zenml-dev.sh --system --integrations "no"
uv pip list
uv pip check || true
# # 1. Send a message to Discord to alert everyone for the release
# - name: Send message to Discord
# run: |
# curl -H "Content-Type: application/json" \
# -d "{\"content\": \"New changes pushed to the main branch!\"}" \
# ${{ secrets.DISCORD_WEBHOOK_URL }}
# 4. Alembic merge
- name: Run Alembic merge
shell: bash
run: |
alembic merge -m "Release" heads --rev-id ${{ env.VERSION }}
scripts/format.sh
git add src/zenml/zen_stores/migrations/versions
# 5. Update the main files
- name: Update main files
run: |
OLD_VERSION=$(cat src/zenml/VERSION)
echo "OLD_VERSION=$OLD_VERSION" >> $GITHUB_ENV
sed -i "s/$OLD_VERSION/${{ env.VERSION }}/g" README.md pyproject.toml src/zenml/VERSION src/zenml/zen_server/deploy/helm/Chart.yaml src/zenml/zen_server/deploy/helm/README.md
git add README.md pyproject.toml src/zenml/VERSION src/zenml/zen_server/deploy/helm/Chart.yaml src/zenml/zen_server/deploy/helm/README.md
# 5.5. Update the quickstart references
- name: Replace the references in the quickstart example
run: |
find examples/quickstart -type f \( -name "*.txt" -o -name "*.yaml" -o -name "*.ipynb" \) -print0 |
while IFS= read -r -d '' file; do
if [[ "$file" == *.ipynb ]]; then
# For .ipynb files, we need to parse JSON
jq --arg OLD "$OLD_VERSION" --arg NEW ${{ env.VERSION }} \
'(.cells[] | select(.cell_type == "code") | .source) |= map(gsub($OLD; $NEW))' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
else
# For .txt and .yaml files, we can use sed
sed -i "s/$OLD_VERSION/${{ env.VERSION }}/g" "$file"
fi
done
git add examples/quickstart
# 6. Generate and append release notes
- name: Generate release notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RELEASE_NOTES=$(gh api repos/${{ github.repository }}/releases/generate-notes -F tag_name=${{ env.VERSION }} -F target_commitish=${{ github.sha }} -F previous_tag_name=${{ env.OLD_VERSION }} | jq -r '.body')
echo "$RELEASE_NOTES" >> RELEASE_NOTES.md
git add RELEASE_NOTES.md
# 7. Push the changes
# TODO: Change the reference to ${{ github.event.pull_request.head.ref }}
- name: Push the changes
run: |
git commit -m "Adding the new version to the necessary files."
git push origin HEAD:${{ github.ref }}
build-release:
if: contains(github.event.head_commit.message, '[build]') && github.repository == 'zenml-io/zenml' # TODO: Remove
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
# Check out the prepare-release branch
- name: Checkout code
uses: actions/[email protected]
# Sign in to Google
- uses: google-github-actions/setup-gcloud@v0
with:
service_account_email: ${{ secrets.GCP_CLOUDBUILD_EMAIL }}
service_account_key: ${{ secrets.GCP_CLOUDBUILD_KEY }}
project_id: ${{ secrets.GCP_CLOUDBUILD_PROJECT }}
# Submit the Cloudbuild job
- name: Build docker images
run: |
gcloud builds submit \
--quiet \
--config=release-cloudbuild-preparation.yaml \
--substitutions=_ZENML_BRANCH=${{ github.ref }}
# Sign in to AWS
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::715803424590:role/gh-action-role-zenml-quickstart-ecr
aws-region: eu-central-1
- name: Login to Amazon ECR
id: login-ecr
run: |
aws ecr get-login-password --region eu-central-1 | docker login 715803424590.dkr.ecr.eu-central-1.amazonaws.com --username AWS --password-stdin
# Publish the AWS image
- name: Pull quickstart image from Dockerhub
run: |
docker pull zenmldocker/prepare-release:quickstart-aws
- name: Push quickstart image to ECR
run: |
docker tag zenmldocker/prepare-release:quickstart-aws 715803424590.dkr.ecr.eu-central-1.amazonaws.com/prepare-release:quickstart-aws
docker push 715803424590.dkr.ecr.eu-central-1.amazonaws.com/prepare-release:quickstart-aws
test-release:
if: contains(github.event.head_commit.message, '[test]') && github.repository == 'zenml-io/zenml' # TODO: Remove
env:
ZENML_STORE_URL: ${{ secrets.RELEASE_TENANT_URL }}
ZENML_STORE_API_KEY: ${{ secrets.RELEASE_TENANT_SERVICE_ACCOUNT_KEY }}
runs-on: ubuntu-latest
steps:
# Check out the code
- name: Checkout code
uses: actions/[email protected]
# Setting up the Python
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
# Install requests
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: Test
run: |
scripts/install-zenml-dev.sh --system --integrations "no"
zenml stack list
# # Deactivate and rerun the tenant
# - name: Run tenant management script
# env:
# CLOUD_STAGING_CLIENT_ID: ${{ secrets.CLOUD_STAGING_CLIENT_ID }}
# CLOUD_STAGING_CLIENT_SECRET: ${{ secrets.CLOUD_STAGING_CLIENT_SECRET }}
# RELEASE_TENANT_ID: ${{ secrets.RELEASE_TENANT_ID }}
# run: python scripts/redeploy-release-prep-tenant.py
# Quickstart example
- name: Quickstart example
run: cd examples/quickstart
# Run the Quickstart on the AWS stack
- name: Run on AWS
run: |
zenml integration install aws -y
zenml stack set aws
sed -i '' "s|parent_image:.*|parent_image: \"715803424590.dkr.ecr.eu-central-1.amazonaws.com/prepare-release:quickstart-aws\"|" configs/training_aws.yaml
cat configs/training_aws.yaml
# python run.py --model_type=t5-small
# Run the Quickstart on the Azure stack
- name: Run on Azure
run: |-
zenml integration install azure -y
zenml stack set azure
sed -i '' "s|parent_image:.*|parent_image: \"zenmldocker/prepare-release:quickstart-azure\"|" configs/training_azure.yaml
cat configs/training_azure.yaml
# python run.py --model_type=t5-small
# Run the Quickstart on the GCP stack
- name: Run on GCP
run: |
zenml integration install gcp -y
zenml stack set gcp
sed -i '' "s|parent_image:.*|parent_image: \"zenmldocker/prepare-release:quickstart-gcp\"|" configs/training_gcp.yaml
cat configs/training_gcp.yaml
# python run.py --model_type=t5-small