forked from newrelic/newrelic-lambda-layers
-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (178 loc) · 8.11 KB
/
Copy pathpublish-python.yml
File metadata and controls
185 lines (178 loc) · 8.11 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
name: Publish Python Layers
on:
push:
tags:
- v**_python
workflow_dispatch:
inputs:
regions:
description: 'Comma-separated regions to (re)publish. Leave empty to publish all regions.'
required: false
default: ''
jobs:
# ── Job 1: Publish staging (python3.14 only) ──────────────────────────────
stage-python:
runs-on: ubuntu-latest
outputs:
tag-match: ${{ steps.setup.outputs.tag-match }}
arn_x86: ${{ steps.staging.outputs.arn_x86 }}
arn_arm64: ${{ steps.staging.outputs.arn_arm64 }}
steps:
- uses: actions/checkout@v4
- name: Setup
id: setup
uses: ./.github/actions/python-layer-setup
- name: Publish staging layers (python3.14)
if: steps.setup.outputs.tag-match == 'true'
id: staging
env:
AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }}
STAGING_REGION: us-east-1
run: |
cd python
./publish-layers.sh publish-staging-python3.14
# ── Job 2: Validate (calls reusable workflow) ─────────────────────────────
validate-python:
needs: stage-python
if: needs.stage-python.outputs.tag-match == 'true'
uses: ./.github/workflows/validate-layer.yml
with:
runtime: python314
arn_x86: ${{ needs.stage-python.outputs.arn_x86 }}
arn_arm64: ${{ needs.stage-python.outputs.arn_arm64 }}
secrets: inherit
# ── Job 3: Cleanup staging (always) ──────────────────────────────────────
cleanup-python:
needs: [stage-python, validate-python]
if: always() && needs.stage-python.outputs.arn_x86 != ''
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cleanup staging layers
env:
AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }}
STAGING_REGION: us-east-1
ARN_X86: ${{ needs.stage-python.outputs.arn_x86 }}
ARN_ARM64: ${{ needs.stage-python.outputs.arn_arm64 }}
run: |
cd python
./publish-layers.sh cleanup-staging-python3.14
# ── Job 4: Release all Python versions — gated on validate passing ────────
publish-python:
needs: [stage-python, validate-python]
if: needs.stage-python.outputs.tag-match == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
outputs:
failure_summary: ${{ steps.publish.outputs.failure_summary }}
ecr_failure_summary: ${{ steps.publish.outputs.ecr_failure_summary }}
steps:
- uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/python-layer-setup
- name: Load failed regions for re-run
id: region-retry-load
uses: ./.github/actions/region-retry
with:
mode: load
job_key: python-${{ matrix.python-version }}
run_id: ${{ github.run_id }}
run_attempt: ${{ github.run_attempt }}
- name: Publish Python ${{ matrix.python-version }} layer
id: publish
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
PUBLISH_REGIONS: ${{ steps.region-retry-load.outputs.publish_regions || inputs.regions }}
LAYER_REGIONS: ${{ vars.LAYER_REGIONS }}
S3_BUCKET_PREFIX: ${{ vars.S3_BUCKET_PREFIX }}
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}
run: |
cd python
./publish-layers.sh python${{ matrix.python-version }}
- name: Save failed regions for re-run
if: always()
uses: ./.github/actions/region-retry
with:
mode: save
job_key: python-${{ matrix.python-version }}
failure_summary: ${{ steps.publish.outputs.failure_summary }}
run_id: ${{ github.run_id }}
run_attempt: ${{ github.run_attempt }}
# ── Job 5: Release universal — gated on validate passing ─────────────────
publish-python-universal:
needs: [stage-python, validate-python]
if: needs.stage-python.outputs.tag-match == 'true'
runs-on: ubuntu-latest
outputs:
failure_summary: ${{ steps.publish-universal.outputs.failure_summary }}
ecr_failure_summary: ${{ steps.publish-universal.outputs.ecr_failure_summary }}
steps:
- uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/python-layer-setup
- name: Load failed regions for re-run
id: region-retry-load
uses: ./.github/actions/region-retry
with:
mode: load
job_key: python-universal
run_id: ${{ github.run_id }}
run_attempt: ${{ github.run_attempt }}
- name: Publish universal Python layer
id: publish-universal
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
PUBLISH_REGIONS: ${{ steps.region-retry-load.outputs.publish_regions || inputs.regions }}
LAYER_REGIONS: ${{ vars.LAYER_REGIONS }}
S3_BUCKET_PREFIX: ${{ vars.S3_BUCKET_PREFIX }}
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}
run: |
cd python
./publish-layers.sh python
- name: Save failed regions for re-run
if: always()
uses: ./.github/actions/region-retry
with:
mode: save
job_key: python-universal
failure_summary: ${{ steps.publish-universal.outputs.failure_summary }}
run_id: ${{ github.run_id }}
run_attempt: ${{ github.run_attempt }}
# ── Job 6: Slack release summary — only after validate passed ─────────────
notify-slack:
needs: [stage-python, validate-python, publish-python, publish-python-universal]
if: always() && needs.validate-python.result == 'success' && needs.stage-python.outputs.tag-match == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/notify-slack-layer
with:
language_name: Python
versions_json: |-
[
{"key":"3.9","label":"Python 3.9","job":"publish-python (3.9)","fallback":"${{ needs.publish-python.result }}","failure_key":"python-3.9"},
{"key":"3.10","label":"Python 3.10","job":"publish-python (3.10)","fallback":"${{ needs.publish-python.result }}","failure_key":"python-3.10"},
{"key":"3.11","label":"Python 3.11","job":"publish-python (3.11)","fallback":"${{ needs.publish-python.result }}","failure_key":"python-3.11"},
{"key":"3.12","label":"Python 3.12","job":"publish-python (3.12)","fallback":"${{ needs.publish-python.result }}","failure_key":"python-3.12"},
{"key":"3.13","label":"Python 3.13","job":"publish-python (3.13)","fallback":"${{ needs.publish-python.result }}","failure_key":"python-3.13"},
{"key":"3.14","label":"Python 3.14","job":"publish-python (3.14)","fallback":"${{ needs.publish-python.result }}","failure_key":"python-3.14"},
{"key":"universal","label":"Python Universal","job":"publish-python-universal","fallback":"${{ needs.publish-python-universal.result }}","failure_key":"python-universal"}
]
failure_summaries: |
${{ needs.publish-python.outputs.ecr_failure_summary }}
${{ needs.publish-python-universal.outputs.ecr_failure_summary }}
slack_webhook: ${{ secrets.SLACK_VALIDATION_WEBHOOK }}
gh_token: ${{ github.token }}
repo: ${{ github.repository }}
run_id: ${{ github.run_id }}
run_attempt: ${{ github.run_attempt }}
ref_name: ${{ github.ref_name }}
actor: ${{ github.actor }}
server_url: ${{ github.server_url }}