-
-
Notifications
You must be signed in to change notification settings - Fork 5
167 lines (152 loc) · 6 KB
/
Copy pathrelease.yml
File metadata and controls
167 lines (152 loc) · 6 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for release (e.g. v0.3.3)'
required: false
type: string
permissions:
contents: write
env:
VCPKG_COMMIT: 45f9f39362a4c52e2b1fbe57b7e649db7f3d96d4
jobs:
build-release:
name: Build and Release Binary
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libwayland-dev \
wayland-protocols \
libxkbcommon-dev \
libegl-dev \
libgles-dev \
libx11-dev \
libasound2-dev \
libudev-dev \
pkg-config \
cmake \
ninja-build \
nasm
- name: Cache vcpkg (binary cache, installed, sources)
id: vcpkg-cache
uses: actions/cache@v4
with:
path: |
/opt/vcpkg/installed
/opt/vcpkg/downloads
/opt/vcpkg/bincache
# Includes the manifest hash so a triplet/feature-list change (edits
# to .github/vcpkg-triplets or the ffmpeg feature string below)
# correctly busts the cache instead of restoring a stale build.
key: vcpkg-${{ env.VCPKG_COMMIT }}-static-ffmpeg-${{ hashFiles('.github/vcpkg-triplets/**') }}
restore-keys: |
vcpkg-${{ env.VCPKG_COMMIT }}-static-ffmpeg-
vcpkg-${{ env.VCPKG_COMMIT }}-
vcpkg-static-ffmpeg-
- name: Install vcpkg
run: |
git clone --depth 1 --branch master https://github.com/microsoft/vcpkg /opt/vcpkg
git -C /opt/vcpkg fetch --depth 1 origin "$VCPKG_COMMIT"
git -C /opt/vcpkg checkout "$VCPKG_COMMIT"
/opt/vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Build static FFmpeg
env:
VCPKG_ROOT: /opt/vcpkg
VCPKG_DEFAULT_BINARY_CACHE: /opt/vcpkg/bincache
run: |
mkdir -p /opt/vcpkg/bincache
if [ "${{ steps.vcpkg-cache.outputs.cache-hit }}" = "true" ]; then
echo "Exact vcpkg cache hit — running install to verify, should be a fast no-op."
else
echo "No exact vcpkg cache hit — full or partial FFmpeg build expected."
fi
/opt/vcpkg/vcpkg install \
'ffmpeg[core,avcodec,avformat,swscale,swresample]:x64-linux-static' \
--overlay-triplets="$GITHUB_WORKSPACE/.github/vcpkg-triplets"
- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry and build artifacts
uses: Swatinem/rust-cache@v2
with:
# No custom `key` override: rust-cache hashes Cargo.lock, the Rust
# toolchain version, and the job's `runs-on` automatically. A fixed
# key here (as in the original) never changes, so it restores the
# same snapshot forever and never saves a fresh one after the
# first run — this is the actual caching bug in the original file.
# rust-cache's default env-vars list ("CARGO CC CFLAGS CXX CMAKE
# RUST") already matches PKG_CONFIG_ALL_STATIC's C-toolchain
# neighbors but not the two FFmpeg linkage vars themselves, since
# matching is by *prefix*: MEDIA_PREFIX and PKG_CONFIG_PATH share
# no prefix with any default entry. Add both explicitly (alongside
# the defaults, since setting env-vars replaces rather than
# extends them) so a vcpkg triplet edit that changes either path
# can't silently reuse stale linked artifacts.
env-vars: CARGO CC CFLAGS CXX CMAKE RUST MEDIA_PREFIX PKG_CONFIG
shared-key: release-static-ffmpeg
- name: Build release binary with static FFmpeg
env:
MEDIA_PREFIX: /opt/vcpkg/installed/x64-linux-static
PKG_CONFIG_PATH: /opt/vcpkg/installed/x64-linux-static/lib/pkgconfig
PKG_CONFIG_ALL_STATIC: "1"
run: cargo build --release --bin wallr --features static-ffmpeg
- name: Verify binary is self-contained
run: |
set -euo pipefail
BIN=target/release/wallr
if [ ! -x "$BIN" ]; then
echo "ERROR: $BIN not found or not executable — build did not produce a binary"
exit 1
fi
if ldd "$BIN" | grep -qE 'libav(a|util|codec|format|sw)'; then
echo "ERROR: binary links dynamic FFmpeg libraries"
ldd "$BIN"
exit 1
fi
echo "OK: no dynamic FFmpeg dependencies"
- name: Prepare Release Asset
run: |
set -euo pipefail
mkdir -p staging
cp target/release/wallr staging/
cp README.md staging/
cp -r docs staging/
cd staging
tar -czf ../wallr-linux-amd64.tar.gz *
cd ..
- name: Determine Tag
id: determine_tag
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.tag_name }}" ]; then
TAG_NAME="${{ inputs.tag_name }}"
elif [ "${{ github.ref_type }}" = "tag" ]; then
TAG_NAME="${{ github.ref_name }}"
else
VERSION="$(cargo metadata --no-deps --format-version 1 | jq -re '.packages[] | select(.name=="wallr") | .version')"
if [ -z "$VERSION" ]; then
echo "ERROR: could not resolve wallr's version from cargo metadata" >&2
exit 1
fi
TAG_NAME="v${VERSION}"
fi
echo "TAG_NAME=${TAG_NAME}" >> "$GITHUB_ENV"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.TAG_NAME }}
name: Release ${{ env.TAG_NAME }}
draft: false
prerelease: false
files: |
wallr-linux-amd64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}