-
Notifications
You must be signed in to change notification settings - Fork 217
178 lines (149 loc) · 5.27 KB
/
release.yml
File metadata and controls
178 lines (149 loc) · 5.27 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
name: Release package
on:
workflow_dispatch:
inputs:
tag:
description: "Tag to release (e.g. v0.23.0)"
required: true
type: string
push:
tags:
- v[0-9].[0-9]+.[0-9]+
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
validate-packages-yml:
runs-on: ubuntu-latest
steps:
- name: Checkout Elementary
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install PyYAML
run: pip install pyyaml
- name: Validate dbt-data-reliability is not a git hash reference
run: |
python - <<'EOF'
import yaml
import sys
packages_file = "./elementary/monitor/dbt_project/packages.yml"
with open(packages_file) as f:
data = yaml.safe_load(f)
packages = data.get("packages", [])
has_git_ref = any(
"git" in pkg and "dbt-data-reliability" in pkg["git"]
for pkg in packages
)
if has_git_ref:
print("::error::packages.yml contains a git hash reference for dbt-data-reliability. "
"Releases must use a proper package version (e.g. 'package: elementary-data/elementary' "
"with a 'version:' field). Please update packages.yml before releasing.")
sys.exit(1)
has_package_ref = any(
pkg.get("package") == "elementary-data/elementary"
for pkg in packages
)
if not has_package_ref:
print("::error::packages.yml does not contain a proper package reference for "
"elementary-data/elementary. Please update packages.yml before releasing.")
sys.exit(1)
print("packages.yml validation passed - using proper package version reference.")
EOF
- name: Validate package-lock.yml has no 'name' fields unsupported in dbt 1.8
run: |
python - <<'EOF'
import yaml
import sys
lock_file = "./elementary/monitor/dbt_project/package-lock.yml"
with open(lock_file) as f:
data = yaml.safe_load(f)
packages = data.get("packages", [])
bad_packages = [pkg for pkg in packages if "name" in pkg]
if bad_packages:
names = ", ".join(pkg["name"] for pkg in bad_packages)
print(f"::error::package-lock.yml contains 'name' fields ({names}) which are "
"unsupported in dbt 1.8. Remove the 'name' fields from the lock file "
"or delete it and let dbt regenerate it.")
sys.exit(1)
print("package-lock.yml validation passed - no unsupported 'name' fields found.")
EOF
publish-to-pypi:
needs: validate-packages-yml
runs-on: ubuntu-latest
steps:
- name: Checkout Elementary
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install 'build' package
run: pip install build
- name: Build package
run: python -m build --sdist --wheel --outdir dist .
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: build
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PYPI_USER }}
password: ${{ secrets.PYPI_PASS }}
build-and-push-docker-image:
needs: validate-packages-yml
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Elementary
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
- name: Set up QEMU for multi-platform support
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx for multi-platform support
uses: docker/setup-buildx-action@v3
- name: Log in to the container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=${{ inputs.tag || '' }}
type=ref,event=tag
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
merge-to-docs:
needs: validate-packages-yml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
- name: PR master to docs
uses: repo-sync/pull-request@v2
with:
source_branch: master
destination_branch: docs