-
Notifications
You must be signed in to change notification settings - Fork 6
194 lines (166 loc) · 5.68 KB
/
Copy pathbuild.yaml
File metadata and controls
194 lines (166 loc) · 5.68 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
name: Build TAP Schema and Datalink and publish to PyPI
on:
push:
branches:
- main
tags:
- "*"
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Python and install dependencies
uses: ./.github/actions/setup-test-environment
- name: Run Python tests
run: pytest
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Run the build
id: build-tap-schema
run: ./build-all
working-directory: ./tap-schema
- name: Build datalink release
id: build-datalink
run: sdm-tools build-datalink-metadata ../yml/*.yaml
working-directory: ./datalink
- name: Upload datalink artifacts
uses: actions/upload-artifact@v7
with:
name: datalink-artifacts
path: |
datalink/datalink-columns.zip
datalink/datalink-snippets.zip
- name: Upload schema YAML files
uses: actions/upload-artifact@v7
with:
name: schema-artifacts
path: yml/*.yaml
- name: Release Datalink
uses: softprops/action-gh-release@v3
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
datalink/datalink-columns.zip
datalink/datalink-snippets.zip
check-changes:
outputs:
skip: ${{ steps.check.outputs.skip }}
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Check if weekly changed
id: check
run: |
# Get SHA hashes for all weekly tags
weekly_sha=$(git tag -l 'w.*' | while read tag; do
git rev-list -n 1 "${tag}"
done)
echo "Weekly tag SHA ${weekly_sha}"
# Extract the current tag and its SHA
current_tag=${GITHUB_REF#refs/tags/}
echo "Current tag: ${current_tag}"
current_sha=$(git rev-list -1 "${current_tag}") || echo "no_value"
echo "Current sha: ${current_sha}"
# Count occurrences of the current SHA in the weekly SHA list
n=$(echo "${weekly_sha}" | grep -c "${current_sha}") || echo "0"
echo "Current tag ${current_tag} (${current_sha}) SHA found ${n} time(s)"
# Determine whether to skip the upload based on the count
if [ "${n}" -gt 1 ]; then
echo "Skip upload"
echo "skip=true" >> "${GITHUB_OUTPUT}"
else
echo "Enable upload"
echo "skip=false" >> "${GITHUB_OUTPUT}"
fi
upload-gcs:
name: Upload release artifacts to GCS
runs-on: ubuntu-latest
needs: build
permissions:
contents: read
if: >
github.event_name != 'merge_group'
&& (github.event_name != 'pull_request'
|| startsWith(github.head_ref, 'tickets/'))
steps:
- name: Download datalink artifacts
uses: actions/download-artifact@v8
with:
name: datalink-artifacts
path: datalink
- name: Download schema YAML files
uses: actions/download-artifact@v8
with:
name: schema-artifacts
path: yml
- name: Determine GCS destination path
id: gcs-path
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "destination=${{ github.head_ref }}" >> "$GITHUB_OUTPUT"
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
echo "destination=releases/${TAG}" >> "$GITHUB_OUTPUT"
else
echo "destination=main" >> "$GITHUB_OUTPUT"
fi
- name: Create schema archive
run: |
mkdir -p sdm_schemas/python/lsst/sdm/schemas
cp -r yml/. sdm_schemas/python/lsst/sdm/schemas/
tar -czf schemas.tar.gz sdm_schemas/
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v3
with:
credentials_json: ${{ secrets.GCP_SDM_SCHEMAS_CREDENTIALS }}
- name: Upload datalink artifacts to GCS
uses: google-github-actions/upload-cloud-storage@v3
with:
path: datalink
destination: ${{ secrets.GCS_BUCKET_NAME }}/${{ steps.gcs-path.outputs.destination }}
glob: "*.zip"
parent: false
process_gcloudignore: false
- name: Upload schema archive to GCS
uses: google-github-actions/upload-cloud-storage@v3
with:
path: schemas.tar.gz
destination: ${{ secrets.GCS_BUCKET_NAME }}/${{ steps.gcs-path.outputs.destination }}
process_gcloudignore: false
gzip: false
pypi:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: [build, check-changes]
permissions:
id-token: write
if: "${{ ! startsWith(github.ref, 'refs/tags/w.') || needs.check-changes.outputs.skip == 'false' }}"
steps:
- uses: actions/checkout@v7
with:
# Need to clone everything to embed the version.
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel build
- name: Build and create distribution
run: |
python -m build --skip-dependency-check
- name: Upload
uses: pypa/gh-action-pypi-publish@release/v1