-
Notifications
You must be signed in to change notification settings - Fork 0
172 lines (151 loc) · 5.12 KB
/
Copy pathrelease.yml
File metadata and controls
172 lines (151 loc) · 5.12 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
name: release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
version:
description: "SemVer version to publish, without leading v (example: 0.2.0)"
required: true
permissions:
contents: write
id-token: write
attestations: write
jobs:
build:
name: build ${{ matrix.platform }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
platform: linux-x86_64
# macOS targets are temporarily disabled. Restore the macos-13 /
# macos-14 entries when Apple-flavored tarballs are needed again.
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Validate VERSION against release tag
shell: bash
run: |
version="$(tr -d '[:space:]' < VERSION)"
if [ -n "${{ github.event.inputs.version }}" ] && [ "$version" != "${{ github.event.inputs.version }}" ]; then
echo "VERSION ($version) must match workflow input (${{ github.event.inputs.version }})" >&2
exit 1
fi
if [[ "${GITHUB_REF:-}" == refs/tags/v* ]]; then
tag="${GITHUB_REF#refs/tags/v}"
if [ "$version" != "$tag" ]; then
echo "VERSION ($version) must match tag v$tag" >&2
exit 1
fi
fi
- name: Install Linux dependencies
if: matrix.platform == 'linux-x86_64'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake pkg-config libsqlite3-dev libyaml-dev curl
- name: Install macOS dependencies
if: startsWith(matrix.platform, 'macos-')
shell: bash
run: brew install cmake pkg-config sqlite libyaml
- name: Build graft
run: |
set -euo pipefail
rpath='$ORIGIN'
if [[ "${{ matrix.platform }}" == macos-* ]]; then rpath='@loader_path'; fi
cmake -S third_party/llama.cpp -B third_party/llama.cpp/build \
-DBUILD_SHARED_LIBS=ON -DGGML_NATIVE=OFF \
-DLLAMA_CURL=OFF -DLLAMA_BUILD_SERVER=OFF \
-DLLAMA_BUILD_TOOLS=OFF -DLLAMA_BUILD_EXAMPLES=OFF \
-DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_COMMON=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_RPATH="$rpath"
cmake --build third_party/llama.cpp/build --parallel 2
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_RPATH="$rpath" \
-DGRAFT_BUILD_TESTS=OFF
cmake --build build --parallel
- name: Package release asset
run: bash scripts/package-release.sh "${{ matrix.platform }}"
- uses: actions/upload-artifact@v4
with:
name: graft-${{ matrix.platform }}
path: dist/release/graft-${{ matrix.platform }}.*
if-no-files-found: error
publish:
name: publish GitHub release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
path: dist/release
merge-multiple: true
- name: Generate checksums and changelog
shell: bash
run: |
cd dist/release
sha256sum graft-* > SHA256SUMS
cd ../..
tag="${GITHUB_REF#refs/tags/}"
if [ "$tag" = "$GITHUB_REF" ]; then tag="v${{ github.event.inputs.version }}"; fi
prev="$(git describe --tags --abbrev=0 "${tag}^" 2>/dev/null || true)"
{
echo "# ${tag}"
echo
if [ -n "$prev" ]; then
git log --pretty='- %s (%h)' "$prev..HEAD"
else
git log --pretty='- %s (%h)'
fi
} > dist/release/CHANGELOG.md
- name: Generate SBOM
uses: anchore/sbom-action@v0
with:
path: .
format: spdx-json
output-file: dist/release/graft-sbom.spdx.json
upload-artifact: false
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Sign release assets
shell: bash
run: |
cd dist/release
for f in graft-* SHA256SUMS; do
cosign sign-blob --yes "$f" \
--output-signature "$f.sig" \
--output-certificate "$f.pem"
done
- name: Attest build provenance
uses: actions/attest-build-provenance@v2
with:
subject-path: "dist/release/graft-*"
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
tag="${GITHUB_REF#refs/tags/}"
if [ "$tag" = "$GITHUB_REF" ]; then tag="v${{ github.event.inputs.version }}"; fi
if ! git rev-parse "$tag" >/dev/null 2>&1; then
git tag "$tag"
git push origin "$tag"
fi
gh release create "$tag" dist/release/* \
--title "$tag" \
--notes-file dist/release/CHANGELOG.md \
--verify-tag