Repository navigation
230 lines (210 loc) · 7.41 KB
/
Copy pathrelease.yml
File metadata and controls
230 lines (210 loc) · 7.41 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
# Builds prebuilt SDK bundles (headers + static libs + CMake metadata) for
# common platforms incl. arm64 and attaches them to a GitHub Release.
# Trigger: push a v* tag, or run manually from the Actions tab.
name: Release
concurrency:
group: release-${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
cancel-in-progress: false
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: Tag to attach artifacts to, e.g. v0.4.0 (must exist)
required: true
type: string
permissions:
contents: read # write is granted only to the release job below
jobs:
# Resolve the release tag once (name + commit) so every build job and the
# release job operate on the same commit, even if the tag moves later.
resolve:
name: Resolve release tag
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
sha: ${{ steps.tag.outputs.sha }}
steps:
- name: Resolve release tag and commit
id: tag
env:
RELEASE_TAG: ${{ inputs.tag }}
run: |
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
case "$RELEASE_TAG" in
v[0-9]*)
;;
*)
echo "::error::input tag must be an existing version tag, e.g. v0.4.0"
exit 1
;;
esac
case "$RELEASE_TAG" in
*/*)
echo "::error::tag '${RELEASE_TAG}' must not contain '/'"
exit 1
;;
esac
SHA="$(git ls-remote "https://github.com/${GITHUB_REPOSITORY}.git" \
"refs/tags/${RELEASE_TAG}^{}" | awk '{print $1}')"
if [ -z "$SHA" ]; then
SHA="$(git ls-remote "https://github.com/${GITHUB_REPOSITORY}.git" \
"refs/tags/${RELEASE_TAG}" | awk '{print $1}')"
fi
if [ -z "$SHA" ]; then
echo "::error::tag '${RELEASE_TAG}' does not exist on ${GITHUB_REPOSITORY}"
exit 1
fi
TAG="$RELEASE_TAG"
else
TAG="${GITHUB_REF#refs/tags/}"
SHA="$GITHUB_SHA"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
build:
name: Build ${{ matrix.name }}
needs: resolve
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-amd64
os: ubuntu-24.04
triplet: x64-linux
- name: linux-arm64
os: ubuntu-24.04-arm
triplet: arm64-linux
- name: macos-amd64
os: macos-15-intel
triplet: x64-osx
- name: macos-arm64
os: macos-15
triplet: arm64-osx
- name: windows-amd64
os: windows-latest
triplet: x64-windows-static
steps:
- name: Checkout minio-cpp
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
path: minio-cpp
ref: ${{ needs.resolve.outputs.sha }}
persist-credentials: false
- name: Checkout vcpkg
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: microsoft/vcpkg
ref: 9e593bb18ea69cc5095e012465dcd675a822ed0d # 2026.07.29
path: vcpkg
persist-credentials: false
- name: Install recent CMake and Ninja
uses: lukka/get-cmake@fffaaafeea488556c2c12dad60690008bc1caacb # v4.4.2
- name: Bootstrap vcpkg
shell: bash
run: |
if [ "$RUNNER_OS" = "Windows" ]; then
./vcpkg/bootstrap-vcpkg.bat -disableMetrics
else
./vcpkg/bootstrap-vcpkg.sh -disableMetrics
fi
- name: Resolve archive name
id: tag
shell: bash
env:
RELEASE_TAG: ${{ needs.resolve.outputs.tag }}
run: |
echo "archive=minio-cpp-${RELEASE_TAG#v}-${{ matrix.name }}" >> "$GITHUB_OUTPUT"
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: brew install pkg-config
- name: Configure and build
shell: bash
run: |
cd minio-cpp
../vcpkg/vcpkg install --triplet "${{ matrix.triplet }}"
cmake . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DVCPKG_TARGET_TRIPLET="${{ matrix.triplet }}" \
-DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build --config Release -j 4
# Install miniocpp into vcpkg's dep prefix so the bundle is one flat,
# relocatable directory: headers + all static libs + CMake configs.
- name: Install into SDK bundle
shell: bash
run: |
cd minio-cpp
cmake --install build --config Release \
--prefix "build/vcpkg_installed/${{ matrix.triplet }}"
- name: Package bundle
shell: bash
env:
RELEASE_ARCHIVE: ${{ steps.tag.outputs.archive }}
run: |
set -euo pipefail
ARCHIVE="$RELEASE_ARCHIVE"
mv "minio-cpp/build/vcpkg_installed/${{ matrix.triplet }}" "$ARCHIVE"
if [ "$RUNNER_OS" = "Windows" ]; then
tar -a -cf "$ARCHIVE.zip" "$ARCHIVE"
else
tar -czf "$ARCHIVE.tar.gz" "$ARCHIVE"
fi
- name: Upload bundle (tar.gz)
if: runner.os != 'Windows'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: ${{ steps.tag.outputs.archive }}.tar.gz
path: ${{ steps.tag.outputs.archive }}.tar.gz
if-no-files-found: error
- name: Upload bundle (zip)
if: runner.os == 'Windows'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: ${{ steps.tag.outputs.archive }}.zip
path: ${{ steps.tag.outputs.archive }}.zip
if-no-files-found: error
release:
name: Publish release assets
needs: [build, resolve]
if: needs.build.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: write # only this job may create/update the release
steps:
- name: Download all bundles
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
path: artifacts
merge-multiple: true
# Abort the release if the tag was moved while the build was running.
- name: Verify tag still points to the resolved commit
env:
RELEASE_TAG: ${{ needs.resolve.outputs.tag }}
RESOLVED_SHA: ${{ needs.resolve.outputs.sha }}
run: |
SHA="$(git ls-remote "https://github.com/${GITHUB_REPOSITORY}.git" \
"refs/tags/${RELEASE_TAG}^{}" | awk '{print $1}')"
if [ -z "$SHA" ]; then
SHA="$(git ls-remote "https://github.com/${GITHUB_REPOSITORY}.git" \
"refs/tags/${RELEASE_TAG}" | awk '{print $1}')"
fi
if [ -z "$SHA" ] || [ "$SHA" != "$RESOLVED_SHA" ]; then
echo "::error::tag '${RELEASE_TAG}' moved since the build started"
exit 1
fi
- name: Create or update GitHub release with assets
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ needs.resolve.outputs.tag }}
run: |
set -euo pipefail
TAG="$RELEASE_TAG"
if gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release upload "$TAG" artifacts/* -R "$GITHUB_REPOSITORY" --clobber
else
gh release create "$TAG" artifacts/* -R "$GITHUB_REPOSITORY" \
--title "minio-cpp $TAG" --generate-notes --verify-tag
fi