Skip to content

Commit 0f0fb02

Browse files
committed
init
0 parents  commit 0f0fb02

52 files changed

Lines changed: 10518 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.config/dotnet-tools.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"clangsharppinvokegenerator": {
6+
"version": "21.1.8.2",
7+
"commands": [
8+
"ClangSharpPInvokeGenerator"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}

.gitattributes

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Check VLC Headers
2+
3+
# Runs daily. Regenerates the P/Invoke bindings from the latest VLC headers and,
4+
# if the generated interop file actually changed, derives a version from the VLC
5+
# header macros (libvlc_version.h) as MAJOR.MINOR.REVISION-nightly.<UTC-date>,
6+
# commits the regenerated bindings + bumped version, tags it, and invokes the
7+
# reusable NuGet publish workflow.
8+
#
9+
# Detection is "regenerate-and-diff": it triggers on changes that affect the
10+
# generated binding surface, ignoring header edits that don't (comments, etc.).
11+
on:
12+
schedule:
13+
- cron: '0 3 * * *' # daily at 03:00 UTC
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: write
18+
id-token: write # allows the reusable publish workflow to use trusted publishing (OIDC)
19+
20+
jobs:
21+
check:
22+
runs-on: windows-latest
23+
outputs:
24+
updated: ${{ steps.diff.outputs.updated }}
25+
version: ${{ steps.version.outputs.version }}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Setup .NET
33+
uses: actions/setup-dotnet@v4
34+
with:
35+
dotnet-version: |
36+
8.0.x
37+
9.0.x
38+
39+
# Fetches the latest VLC include/vlc headers into tools/.vlc and regenerates
40+
# src/LibVLCSharp.Core/Generated/LibVLC.Interop.g.cs via ClangSharp.
41+
- name: Regenerate bindings from latest VLC headers
42+
run: ./tools/generate.ps1
43+
shell: pwsh
44+
45+
- name: Detect binding changes
46+
id: diff
47+
shell: pwsh
48+
run: |
49+
# .gitattributes (* text=auto) normalizes line endings, so this only
50+
# reports real content changes, not CRLF/LF noise.
51+
$changed = git status --porcelain -- src/LibVLCSharp.Core/Generated
52+
if ($changed) {
53+
Write-Host "Bindings changed:`n$changed"
54+
"updated=true" >> $env:GITHUB_OUTPUT
55+
} else {
56+
Write-Host 'No binding changes; nothing to publish.'
57+
"updated=false" >> $env:GITHUB_OUTPUT
58+
}
59+
60+
- name: Derive version from VLC headers
61+
id: version
62+
if: steps.diff.outputs.updated == 'true'
63+
shell: pwsh
64+
run: |
65+
$header = 'tools/.vlc/include/vlc/libvlc_version.h'
66+
if (-not (Test-Path $header)) { throw "Not found: $header" }
67+
$text = Get-Content $header -Raw
68+
function Get-Macro([string]$name) {
69+
# VLC headers write the macros as "# define LIBVLC_VERSION_MAJOR (4)"
70+
# (note the space after '#'), so allow optional whitespace there.
71+
if ($text -match "#\s*define\s+$name\s*\(?\s*(\d+)") { return [int]$Matches[1] }
72+
throw "Macro $name not found in libvlc_version.h"
73+
}
74+
$major = Get-Macro 'LIBVLC_VERSION_MAJOR'
75+
$minor = Get-Macro 'LIBVLC_VERSION_MINOR'
76+
$rev = Get-Macro 'LIBVLC_VERSION_REVISION'
77+
$date = (Get-Date).ToUniversalTime().ToString('yyyyMMdd')
78+
$version = "$major.$minor.$rev-nightly.$date"
79+
Write-Host "Derived version: $version"
80+
"version=$version" >> $env:GITHUB_OUTPUT
81+
82+
# Write the version into Directory.Build.props so the package picks it up.
83+
$props = 'Directory.Build.props'
84+
$content = Get-Content $props -Raw
85+
$content = $content -replace '<Version>[^<]*</Version>', "<Version>$version</Version>"
86+
Set-Content -Path $props -Value $content -NoNewline
87+
88+
- name: Commit, tag and push
89+
if: steps.diff.outputs.updated == 'true'
90+
shell: pwsh
91+
run: |
92+
$version = '${{ steps.version.outputs.version }}'
93+
git config user.name 'github-actions[bot]'
94+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
95+
git add src/LibVLCSharp.Core/Generated Directory.Build.props
96+
git commit -m "chore: regenerate bindings for updated VLC headers ($version)"
97+
git tag "v$version"
98+
git push origin "HEAD:${{ github.ref_name }}"
99+
git push origin "v$version"
100+
101+
publish:
102+
needs: check
103+
if: needs.check.outputs.updated == 'true'
104+
# Build & publish the just-tagged commit (the GITHUB_TOKEN that pushed the tag
105+
# cannot trigger the tag-push workflow, so we invoke publish directly here and
106+
# point it at the new tag).
107+
# Trusted publishing needs id-token: write in the called workflow; grant it here.
108+
permissions:
109+
contents: read
110+
id-token: write
111+
uses: ./.github/workflows/nuget-publish.yml
112+
with:
113+
ref: v${{ needs.check.outputs.version }}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: NuGet Publish
2+
3+
# Builds the packable projects (LibVLC4Sharp.Core + LibVLC4Sharp.WPF) in Release
4+
# and pushes the resulting .nupkg/.snupkg to nuget.org.
5+
#
6+
# Triggers:
7+
# - push of a v* tag -> publishes whatever is committed at that tag
8+
# - manual workflow_dispatch -> publishes the default branch
9+
# - workflow_call (reusable) -> invoked by check-vlc-update.yml after it tags a new version
10+
#
11+
# Auth: NuGet Trusted Publishing (OIDC). No long-lived API key secret is needed.
12+
# The job runs in the `production` environment and exchanges a GitHub OIDC token
13+
# for a short-lived nuget.org API key via the NuGet/login action. This requires a
14+
# matching trusted publishing policy on nuget.org:
15+
# Owner: IOL0ol1 Repo: LibVLC4Sharp Workflow: nuget-publish.yml Environment: production
16+
on:
17+
push:
18+
tags:
19+
- 'v*'
20+
workflow_dispatch:
21+
workflow_call:
22+
inputs:
23+
ref:
24+
description: 'Git ref (tag/branch/sha) to build & publish'
25+
type: string
26+
required: false
27+
default: ''
28+
29+
permissions:
30+
contents: read
31+
id-token: write # required to request the GitHub OIDC token for trusted publishing
32+
33+
jobs:
34+
publish:
35+
runs-on: windows-latest
36+
# Must match the Environment configured in the nuget.org trusted publishing policy.
37+
environment: production
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
with:
42+
# Empty for push/dispatch (uses the triggering ref); set by check-vlc-update.yml
43+
# to the freshly created tag so we build the committed, regenerated bindings.
44+
ref: ${{ inputs.ref }}
45+
46+
- name: Setup .NET
47+
uses: actions/setup-dotnet@v4
48+
with:
49+
dotnet-version: |
50+
8.0.x
51+
9.0.x
52+
53+
# Build the whole solution in Release. Packable projects (Core + WPF) emit
54+
# their .nupkg/.snupkg into nupkgs/ via GeneratePackageOnBuild
55+
# (Directory.Build.props); the sample/generator are IsPackable=false and so
56+
# produce no package. FetchLibVLC=false skips the sample's ~100 MB libvlc
57+
# nightly download, which is a runtime-only asset and not needed to compile.
58+
- name: Build & pack (Release)
59+
run: dotnet build LibVLC4Sharp.slnx --configuration Release -p:FetchLibVLC=false
60+
61+
- name: List packages
62+
shell: pwsh
63+
run: Get-ChildItem -Path nupkgs -Filter *.nupkg -Recurse | Select-Object FullName
64+
65+
# Exchange the GitHub OIDC token for a short-lived nuget.org API key.
66+
# The temp key is valid for ~1 hour, so this runs immediately before the push.
67+
- name: NuGet login (OIDC -> temp API key)
68+
uses: NuGet/login@v1
69+
id: login
70+
with:
71+
user: kiolp # nuget.org account/profile name that owns the trusted publishing policy
72+
73+
- name: Push to NuGet
74+
shell: pwsh
75+
env:
76+
NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
77+
run: |
78+
if (-not $env:NUGET_API_KEY) { throw 'Failed to obtain a NuGet API key from trusted publishing.' }
79+
$pkgs = Get-ChildItem -Path nupkgs -Filter *.nupkg -Recurse
80+
if ($pkgs.Count -eq 0) { throw 'No .nupkg files were produced.' }
81+
foreach ($pkg in $pkgs) {
82+
# Pushing the .nupkg also uploads the matching .snupkg symbols package.
83+
dotnet nuget push $pkg.FullName `
84+
--api-key $env:NUGET_API_KEY `
85+
--source https://api.nuget.org/v3/index.json `
86+
--skip-duplicate
87+
}

0 commit comments

Comments
 (0)