-
Notifications
You must be signed in to change notification settings - Fork 1
170 lines (140 loc) · 5.8 KB
/
macos-release.yml
File metadata and controls
170 lines (140 loc) · 5.8 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
name: macOS Release Build
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write # Needed for release upload
id-token: write # Needed for build provenance attestation
attestations: write # Needed for build provenance attestation
jobs:
cmake:
name: cmake + ${{ matrix.os }} + ${{ matrix.shard }}
runs-on: ${{ matrix.os }}
permissions:
contents: 'write'
id-token: 'write'
attestations: 'write'
strategy:
fail-fast: false
matrix:
os: [ macos-14]
shard: [ BqDriver ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: google-github-actions/auth@v2
with:
create_credentials_file: true
credentials_json: ${{ secrets.BUILD_CACHE_KEY }}
- uses: actions/setup-python@v5
id: py311
with:
python-version: '3.11'
- uses: google-github-actions/setup-gcloud@v2
with:
version: '500.0.0'
env:
CLOUDSDK_PYTHON: ${{ steps.py311.outputs.python-path }}
- name: Dynamic Configuration
id: dynamic
shell: bash
run: |
echo "vcpkg-version=$(cat ci/etc/vcpkg-version.txt)" >> "${GITHUB_OUTPUT}"
- name: Install bash >= 5.x and Ninja
run: brew install bash ninja
- name: Download cmake formula (3.29.0) and install
run: |
brew unlink cmake
curl -L https://github.com/Kitware/CMake/releases/download/v3.29.0/cmake-3.29.0-macos-universal.tar.gz -o cmake.tar.gz
tar -xzf cmake.tar.gz
sudo cp -r cmake-3.29.0-macos-universal/CMake.app/Contents/bin/* /usr/local/bin/
sudo cp -r cmake-3.29.0-macos-universal/CMake.app/Contents/share/cmake-3.29 /usr/local/share/
cmake --version
- name: cmake version
run: cmake --version
- name: Download and Install sccache
working-directory: "${{runner.temp}}"
run: |
curl -fsSL https://github.com/mozilla/sccache/releases/download/v0.9.1/sccache-v0.9.1-x86_64-apple-darwin.tar.gz | \
tar -zxf - --strip-components=1 && \
chmod +x sccache && \
mv sccache /Users/runner/.cargo/bin/sccache
- name: Install bison flex for 'arrow'
run: brew install bison flex
- name: Download and Install vcpkg
working-directory: "${{runner.temp}}"
run: |
git clone --branch ${{ steps.dynamic.outputs.vcpkg-version }} https://github.com/microsoft/vcpkg.git
vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Install iODBC
run: |
brew install libiodbc
- name: Setup and Build cpp-bigquery-odbc driver
run: |
export VCPKG_ROOT="${{ runner.temp }}/vcpkg"
export PATH="$VCPKG_ROOT:/opt/homebrew/bin:$PATH"
export LDFLAGS="-L$(brew --prefix libiodbc)/lib -liconv"
export PATH="$(dirname ${{ steps.py311.outputs.python-path }}):$PATH"
export CLOUDSDK_PYTHON="${{ steps.py311.outputs.python-path }}"
bash ci/gha/builds/macos-release-setup.sh
export ODBC_INCLUDE_PATH="/opt/homebrew/opt/libiodbc/include"
bash ci/gha/builds/macos-cmake.sh
- name: Validate DRIVER_VERSION with github tag.
id: version
run: |
TAG=${GITHUB_REF#refs/tags/}
VERSION=${TAG#v}
HEADER_VERSION=$(grep 'DRIVER_VERSION' google/cloud/odbc/internal/version.h | sed -E 's/.*"([^"]+)".*/\1/')
echo "Tag version: $VERSION"
echo "Header DRIVER_VERSION: $HEADER_VERSION"
if [ "$VERSION" != "$HEADER_VERSION" ]; then
echo "DRIVER_VERSION doesn't match the version in github tag."
exit 1
else
echo "DRIVER_VERSION matches tag version"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Create TAR Package
run: |
set -euo pipefail
# Detect CMake build output directory
if [ -d "cmake-out" ]; then
BUILD_DIR="cmake-out"
else
echo "No build directory found. Did CMake run?"
exit 1
fi
echo "Using build directory: $BUILD_DIR"
# Prepare package folder
mkdir -p release_package/lib
# Copy driver files (fail if missing)
cp -rv "$BUILD_DIR/google/cloud/odbc/libgoogle_cloud_odbc_bq_driver.dylib" release_package/lib/
# Copy ODBC config files from repo
cp -rv ci/gha/builds/release/odbc.ini release_package/odbc.ini
cp -rv ci/gha/builds/release/odbcinst.ini release_package/odbcinst.ini
# Copy root certificates file form repo
cp -rv ci/etc/roots.pem release_package/roots.pem
# Create TAR.GZ file
TAR_NAME="ODBCDriverforBigQuery_macos_${{ steps.version.outputs.version }}.tar.gz"
tar -czvf "$TAR_NAME" -C release_package .
echo "TAR package created: $TAR_NAME"
- name: Attest build provenance
uses: actions/attest-build-provenance@v2
with:
subject-path: ODBCDriverforBigQuery_macos_${{ steps.version.outputs.version }}.tar.gz
- name: Upload TAR to GitHub Release
uses: softprops/action-gh-release@v2
with:
files: ODBCDriverforBigQuery_macos_${{ steps.version.outputs.version }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USE_BAZEL_VERSION: 7.0.0
MATRIX_OS: ${{ matrix.os }}
BAZEL_REMOTE_CACHE: https://storage.googleapis.com/gha-cache-cpp-bigquery-odbc/bazel-cache/${{ matrix.os }}
SCCACHE_GCS_BUCKET: gha-cache-cpp-bigquery-odbc
SCCACHE_GCS_KEY_PREFIX: sccache/${{ matrix.os }}
SCCACHE_GCS_RW_MODE: READ_WRITE
SCCACHE_IGNORE_SERVER_IO_ERROR: 1
VCPKG_BINARY_SOURCES: x-gcs,gs://gha-cache-cpp-bigquery-odbc/vcpkg-cache/${{ matrix.os }},readwrite