Repository navigation
242 lines (219 loc) · 10.7 KB
/
Copy pathrelease.yml
File metadata and controls
242 lines (219 loc) · 10.7 KB
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., v2.99.0-rc1 or v2.99.0)'
required: true
type: string
# Only one release workflow runs at a time; additional runs are queued.
concurrency:
group: release
cancel-in-progress: false
permissions:
contents: read
jobs:
authorize:
# Releasing acts as HaystackBot (a ruleset-bypass actor), so the ruleset
# cannot enforce *who* started the release. Gate on the triggering user's
# role instead: only maintainers/admins may run this workflow, even though
# workflow_dispatch itself is available to anyone with write access.
runs-on: ubuntu-slim
steps:
- name: Verify the triggering user may release
env:
GH_TOKEN: ${{ secrets.HAYSTACK_BOT_TOKEN }}
ACTOR: ${{ github.triggering_actor }}
run: |
ROLE=$(gh api "repos/${{ github.repository }}/collaborators/${ACTOR}/permission" --jq '.role_name')
echo "::notice::${ACTOR} has repository role '${ROLE}'"
case "$ROLE" in
admin|maintain)
echo "✅ ${ACTOR} is authorized to trigger a release." ;;
*)
echo "::error::${ACTOR} has role '${ROLE}'. A release can only be triggered by a user with the 'maintain' or 'admin' role."
exit 1 ;;
esac
parse-validate-version:
needs: ["authorize"]
runs-on: ubuntu-slim
outputs:
version: ${{ steps.parse-validate.outputs.version }}
major_minor: ${{ steps.parse-validate.outputs.major_minor }}
release_branch: ${{ steps.parse-validate.outputs.release_branch }}
is_rc: ${{ steps.parse-validate.outputs.is_rc }}
is_first_rc: ${{ steps.parse-validate.outputs.is_first_rc }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # needed to fetch tags and branches
- name: Parse and validate version
id: parse-validate
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}
run: .github/utils/parse_validate_version.sh "$VERSION"
branch-off:
needs: ["parse-validate-version"]
if: needs.parse-validate-version.outputs.is_first_rc == 'true'
uses: ./.github/workflows/branch_off.yml
secrets:
HAYSTACK_BOT_TOKEN: ${{ secrets.HAYSTACK_BOT_TOKEN }}
create-release-tag:
needs: ["parse-validate-version", "branch-off"]
if: always() && needs.parse-validate-version.result == 'success' && needs.branch-off.result != 'failure'
runs-on: ubuntu-slim
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # needed to fetch tags and branches
# use this token so the created tag triggers workflows (does not happen with the default github.token)
token: ${{ secrets.HAYSTACK_BOT_TOKEN }}
- name: Update VERSION.txt and create tag
env:
GITHUB_TOKEN: ${{ secrets.HAYSTACK_BOT_TOKEN }}
VERSION: ${{ needs.parse-validate-version.outputs.version }}
RELEASE_BRANCH: ${{ needs.parse-validate-version.outputs.release_branch }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout "$RELEASE_BRANCH"
git pull origin "$RELEASE_BRANCH"
echo "$VERSION" > VERSION.txt
git add VERSION.txt
git commit -m "bump version to $VERSION"
git push origin "$RELEASE_BRANCH"
TAG="v$VERSION"
git tag -m "$TAG" "$TAG"
git push origin "$TAG"
check-artifacts:
needs: ["parse-validate-version", "create-release-tag"]
if: always() && needs.parse-validate-version.result == 'success' && needs.create-release-tag.result == 'success'
runs-on: ubuntu-latest
outputs:
github_url: ${{ steps.set-outputs.outputs.github_url }}
pypi_url: ${{ steps.set-outputs.outputs.pypi_url }}
docker_url: ${{ steps.set-outputs.outputs.docker_url }}
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.parse-validate-version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # needed to fetch tags and branches
- name: Wait for release workflows
run: |
.github/utils/wait_for_workflows.sh "v${{ env.VERSION }}" \
"Project release on PyPi" \
"Project release on Github" \
"Docker image release"
- name: Check artifacts
run: |
check() {
for _ in {1..5}; do curl -sf "$2" > /dev/null && echo "✅ $1" && return 0; sleep 30; done
echo "❌ $1 not found" && return 1
}
check "GitHub Release" "https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ env.VERSION }}"
check "PyPI package" "https://pypi.org/pypi/haystack-ai/${{ env.VERSION }}/json"
check "Docker image" "https://hub.docker.com/v2/repositories/deepset/haystack/tags/base-v${{ env.VERSION }}"
- name: Set artifact URLs
id: set-outputs
run: |
{
echo "github_url=https://github.com/${{ github.repository }}/releases/tag/v${{ env.VERSION }}"
echo "pypi_url=https://pypi.org/project/haystack-ai/${{ env.VERSION }}/"
echo "docker_url=https://hub.docker.com/r/deepset/haystack/tags?name=base-v${{ env.VERSION }}"
} >> "$GITHUB_OUTPUT"
bump-platform-repos:
needs: ["parse-validate-version", "check-artifacts"]
if: always() && needs.check-artifacts.result == 'success' && needs.parse-validate-version.outputs.is_rc == 'true'
runs-on: ubuntu-slim
outputs:
dc_pipeline_templates_pr_url: ${{ steps.dc-pipeline-templates.outputs.pr_url }}
dc_pipeline_templates_result: ${{ steps.dc-pipeline-templates.outcome }}
dc_custom_nodes_pr_url: ${{ steps.deepset-cloud-custom-nodes.outputs.pr_url }}
dc_custom_nodes_result: ${{ steps.deepset-cloud-custom-nodes.outcome }}
haystack_runtime_pr_url: ${{ steps.haystack-runtime.outputs.pr_url }}
haystack_runtime_result: ${{ steps.haystack-runtime.outcome }}
env:
VERSION: ${{ needs.parse-validate-version.outputs.version }}
steps:
- name: Checkout haystack (for utils)
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
sparse-checkout: .github/utils/wait_for_platform_pr.sh
sparse-checkout-cone-mode: false
- name: Trigger platform update workflows
env:
GH_TOKEN: ${{ secrets.HAYSTACK_BOT_TOKEN }}
run: |
gh workflow run update-haystack-version.yaml -R deepset-ai/dc-pipeline-templates -f haystack_version="$VERSION"
gh workflow run update-haystack-version.yaml -R deepset-ai/deepset-cloud-custom-nodes -f haystack_version="$VERSION"
gh workflow run update-package-version.yaml -R deepset-ai/haystack-runtime -f haystack_version="$VERSION"
- name: Wait for dc-pipeline-templates PR
id: dc-pipeline-templates
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.HAYSTACK_BOT_TOKEN }}
run: .github/utils/wait_for_platform_pr.sh deepset-ai/dc-pipeline-templates "$VERSION"
- name: Wait for deepset-cloud-custom-nodes PR
id: deepset-cloud-custom-nodes
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.HAYSTACK_BOT_TOKEN }}
run: .github/utils/wait_for_platform_pr.sh deepset-ai/deepset-cloud-custom-nodes "$VERSION"
- name: Wait for haystack-runtime PR
id: haystack-runtime
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.HAYSTACK_BOT_TOKEN }}
run: .github/utils/wait_for_platform_pr.sh deepset-ai/haystack-runtime "$VERSION"
- name: Fail if any platform PR is missing
if: steps.dc-pipeline-templates.outcome == 'failure' || steps.deepset-cloud-custom-nodes.outcome == 'failure' || steps.haystack-runtime.outcome == 'failure'
run: |
echo "::error::One or more platform PRs were not found. Something might have failed; check the logs above."
exit 1
notify:
needs:
- "parse-validate-version"
- "branch-off"
- "create-release-tag"
- "check-artifacts"
- "bump-platform-repos"
if: always()
runs-on: ubuntu-slim
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Prepare release notification
env:
VERSION: ${{ inputs.version }}
GH_TOKEN: ${{ github.token }}
RUN_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
# HAS_FAILURE = the release failed. Failing PRs on Platform repos are reported on Slack but do not mean the release failed.
HAS_FAILURE: ${{ needs.parse-validate-version.result == 'failure' || needs.branch-off.result == 'failure' || needs.create-release-tag.result == 'failure' || needs.check-artifacts.result == 'failure' }}
IS_RC: ${{ needs.parse-validate-version.outputs.is_rc }}
IS_FIRST_RC: ${{ needs.parse-validate-version.outputs.is_first_rc }}
MAJOR_MINOR: ${{ needs.parse-validate-version.outputs.major_minor }}
GITHUB_URL: ${{ needs.check-artifacts.outputs.github_url }}
PYPI_URL: ${{ needs.check-artifacts.outputs.pypi_url }}
DOCKER_URL: ${{ needs.check-artifacts.outputs.docker_url }}
BUMP_VERSION_PR_URL: ${{ needs.branch-off.outputs.bump_version_pr_url }}
DC_PIPELINE_TEMPLATES_PR_URL: ${{ needs.bump-platform-repos.outputs.dc_pipeline_templates_pr_url }}
DC_CUSTOM_NODES_PR_URL: ${{ needs.bump-platform-repos.outputs.dc_custom_nodes_pr_url }}
HAYSTACK_RUNTIME_PR_URL: ${{ needs.bump-platform-repos.outputs.haystack_runtime_pr_url }}
DC_PIPELINE_TEMPLATES_RESULT: ${{ needs.bump-platform-repos.outputs.dc_pipeline_templates_result }}
DC_CUSTOM_NODES_RESULT: ${{ needs.bump-platform-repos.outputs.dc_custom_nodes_result }}
HAYSTACK_RUNTIME_RESULT: ${{ needs.bump-platform-repos.outputs.haystack_runtime_result }}
run: .github/utils/prepare_release_notification.sh
- name: Send release notification to Slack
uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL_RELEASE }}
webhook-type: incoming-webhook
payload-file-path: slack_payload.json