-
Notifications
You must be signed in to change notification settings - Fork 7
194 lines (177 loc) · 6.29 KB
/
Copy pathrelease.yml
File metadata and controls
194 lines (177 loc) · 6.29 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
# .github/workflows/release.yml
on:
push:
tags:
- "v*"
jobs:
build-release:
name: deploy
permissions:
contents: write
id-token: write
attestations: write
runs-on: ${{ matrix.os }}
env:
# For some builds, we use cross to test on 32-bit and big-endian
# systems.
CARGO: cargo
# When CARGO is set to CROSS, this is set to `--target matrix.target`.
TARGET_FLAGS: ""
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
TARGET_DIR: ./target
# Emit backtraces on panics.
RUST_BACKTRACE: 1
strategy:
matrix:
build:
- linux
- macos
- windows
include:
- build: linux
os: ubuntu-22.04
rust: stable
target: x86_64-unknown-linux-gnu
- build: linux-musl
os: ubuntu-22.04
rust: stable
target: x86_64-unknown-linux-musl
- build: linux-arm64
os: ubuntu-22.04
rust: stable
target: aarch64-unknown-linux-gnu
- build: linux-armhf
os: ubuntu-22.04
rust: stable
target: armv7-unknown-linux-gnueabihf
- build: macos
os: macos-15
rust: stable
target: x86_64-apple-darwin
mcpb_platform: darwin
mcpb_alias: macos-x64
- build: macos-aarch64
os: macos-15
rust: stable
target: aarch64-apple-darwin
mcpb_platform: darwin
mcpb_alias: macos-arm64
- build: windows
os: ubuntu-22.04
rust: stable
target: x86_64-pc-windows-gnu
mcpb_platform: win32
mcpb_alias: windows-x64
- build: windows-32
os: ubuntu-22.04
rust: stable
target: i686-pc-windows-gnu
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
- name: Use Cross
shell: bash
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
- name: Show command used for Cargo
run: |
echo "cargo command is: ${{ env.CARGO }}"
echo "target flag is: ${{ env.TARGET_FLAGS }}"
echo "target dir is: ${{ env.TARGET_DIR }}"
- name: Build release binary
run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}
- name: Strip release binary (linux and macos)
if: matrix.build == 'linux' || matrix.build == 'macos'
run: strip "target/${{ matrix.target }}/release/screenly"
- name: Package
shell: bash
run: |
cd target/${{ matrix.target }}/release
if [[ "${{ matrix.build }}" == windows* ]]; then
zip ../../../screenly-cli-${{ matrix.target }}.zip screenly.exe
else
tar czvf ../../../screenly-cli-${{ matrix.target }}.tar.gz screenly
fi
cd -
# Only desktop targets are bundled: Claude Desktop runs on macOS and Windows.
- name: Package MCP Bundle
if: matrix.mcpb_platform != ''
shell: bash
run: |
set -euo pipefail
mkdir -p mcpb-build/server
cp mcpb/README.md mcpb/icon.png mcpb-build/
if [[ "${{ matrix.build }}" == windows* ]]; then
cp "target/${{ matrix.target }}/release/screenly.exe" mcpb-build/server/
else
cp "target/${{ matrix.target }}/release/screenly" mcpb-build/server/
fi
# The committed manifest carries a 0.0.0 placeholder so the version cannot
# drift from Cargo.toml; the tag is the single source of truth.
# Windows packs screenly.exe, so entry_point/command must match the artifact.
if [[ "${{ matrix.build }}" == windows* ]]; then
entry_point="server/screenly.exe"
else
entry_point="server/screenly"
fi
jq --arg version "${GITHUB_REF_NAME#v}" \
--arg platform "${{ matrix.mcpb_platform }}" \
--arg entry_point "$entry_point" \
'.version = $version
| .compatibility.platforms = [$platform]
| .server.entry_point = $entry_point
| .server.mcp_config.command = ("${__dirname}/" + $entry_point)
| del(.server.mcp_config.platform_overrides)' \
mcpb/manifest.json > mcpb-build/manifest.json
npx --yes @anthropic-ai/mcpb@2.1.2 pack \
mcpb-build "screenly-cli-${{ matrix.target }}.mcpb"
# Friendlier alias next to the rustc-target name (both are published).
cp "screenly-cli-${{ matrix.target }}.mcpb" \
"screenly-${{ matrix.mcpb_alias }}.mcpb"
- name: Publish
uses: softprops/action-gh-release@v1
# TODO: if any of the build step fails, the release should be deleted.
with:
files: "screenly*"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Attest
uses: actions/attest-build-provenance@v1
with:
subject-path: "${{ github.workspace }}/screenly*"
build-docker-image:
environment: master
name: docker
needs: build-release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build container
run: |
docker build . \
--build-arg "RELEASE=$GITHUB_REF_NAME" \
-t "screenly/cli:$GITHUB_REF_NAME"
- name: Tag container
run: |
docker tag \
"screenly/cli:$GITHUB_REF_NAME" \
"screenly/cli:latest"
- name: Login to DockerHub
if: success() && github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker containers
run: |
docker push "screenly/cli:$GITHUB_REF_NAME"
docker push "screenly/cli:latest"