Skip to content

Commit 5ea855a

Browse files
Merge pull request #4 from crispthinking/copilot/build-and-publish-forked-libraries
Switch to 2-stage CI/Publish workflow with MinVer versioning and NuGet trusted publishing
2 parents 5626d73 + 1bc9b27 commit 5ea855a

5 files changed

Lines changed: 124 additions & 51 deletions

File tree

.github/workflows/BuildAndPublish.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: CI
2+
3+
# Trigger on pushes and pull requests to the main branch.
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
workflow_dispatch:
12+
workflow_call: # Allows the workflow to be called by other workflows
13+
14+
# Set permissions for the workflow.
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
checks: write
19+
packages: read
20+
21+
env:
22+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
23+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
24+
DOTNET_NOLOGO: 1
25+
26+
jobs:
27+
build:
28+
runs-on: ${{ matrix.os }}
29+
strategy:
30+
fail-fast: false # This allows the matrix jobs to run independently.
31+
matrix:
32+
os: [ubuntu-latest, windows-latest, macos-latest]
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 0
38+
39+
- name: Setup .NET Core
40+
uses: actions/setup-dotnet@v4
41+
with:
42+
dotnet-version: 8.0.x
43+
44+
- name: Restore dependencies
45+
run: dotnet restore FastText.NetWrapper.sln
46+
47+
- name: Build
48+
run: dotnet build FastText.NetWrapper.sln --configuration Release --no-restore
49+
50+
- name: Test
51+
run: dotnet test FastText.NetWrapper.sln --configuration Release --no-build --logger "trx" --logger "console;verbosity=normal"
52+
53+
- name: Upload test results
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: test-results-${{ matrix.os }}
57+
path: "**/*.trx"
58+
59+
- name: Pack
60+
if: ${{ matrix.os == 'ubuntu-latest' }}
61+
run: dotnet pack FastText.NetWrapper --configuration Release --no-build --output Artifacts
62+
63+
- name: Upload NuGet packages
64+
if: ${{ matrix.os == 'ubuntu-latest' }}
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: artifacts
68+
path: Artifacts/*.nupkg

.github/workflows/publish.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish FastText.NetWrapper
2+
3+
on:
4+
release:
5+
types:
6+
- published # Run the workflow when a new GitHub release is published
7+
workflow_dispatch: # Allow manual triggering from the GitHub UI
8+
9+
# Set permissions for the workflow.
10+
permissions:
11+
contents: write
12+
packages: write
13+
checks: write
14+
pull-requests: write
15+
id-token: write # Required for NuGet trusted publishing (OIDC)
16+
17+
jobs:
18+
build:
19+
uses: ./.github/workflows/ci.yml
20+
21+
publish:
22+
runs-on: ubuntu-latest
23+
needs: build
24+
steps:
25+
- name: Download Package
26+
uses: actions/download-artifact@v4.1.3
27+
with:
28+
name: artifacts
29+
path: bin/artifacts/
30+
31+
- name: Publish NuGet Packages to GitHub Packages
32+
run: dotnet nuget push bin/artifacts/**/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate
33+
34+
- name: NuGet login (OIDC → temp API key)
35+
if: github.event_name == 'release'
36+
uses: NuGet/login@v1
37+
id: login
38+
with:
39+
user: ${{ secrets.NUGET_USER }}
40+
41+
- name: Publish NuGet package
42+
if: github.event_name == 'release'
43+
run: dotnet nuget push bin/artifacts/**/*.nupkg --api-key "${{ steps.login.outputs.apiKey }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate

FastText.NetWrapper/FastText.NetWrapper.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<LangVersion>latest</LangVersion>
77
<ImplicitUsings>true</ImplicitUsings>
88
<NuspecFile>$(MSBuildThisFileDirectory)$(MSBuildProjectName).nuspec</NuspecFile>
9+
<PackageId>CrispThinking.FastText.NetWrapper</PackageId>
910
</PropertyGroup>
1011

1112
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
@@ -17,10 +18,15 @@
1718
<PackageReference Include="FastText.Native.MacOs" Version="1.0.115" />
1819
<PackageReference Include="FastText.Native.Windows" Version="1.0.115" />
1920
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
21+
<PackageReference Include="MinVer" Version="7.0.0">
22+
<PrivateAssets>all</PrivateAssets>
23+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
24+
</PackageReference>
2025
</ItemGroup>
2126

2227
<Target Name="SetNuspecProperties" BeforeTargets="GenerateNuspec">
2328
<PropertyGroup>
29+
<NuspecProperties>$(NuspecProperties);packageId=$(PackageId)</NuspecProperties>
2430
<NuspecProperties>$(NuspecProperties);assemblyName=$(AssemblyName)</NuspecProperties>
2531
<NuspecProperties>$(NuspecProperties);config=$(Configuration)</NuspecProperties>
2632
<NuspecProperties>$(NuspecProperties);version=$(PackageVersion)</NuspecProperties>

FastText.NetWrapper/FastText.NetWrapper.nuspec

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
33
<metadata>
4-
<id>FastText.NetWrapper</id>
4+
<id>$packageId$</id>
55
<version>$version$</version>
6-
<title>FastText.NetWrapper</title>
7-
<authors>Oleg Tarasov</authors>
8-
<licenseUrl>https://raw.githubusercontent.com/olegtarasov/FastText.NetWrapper/master/LICENSE</licenseUrl>
9-
<projectUrl>https://github.com/olegtarasov/FastText.NetWrapper</projectUrl>
6+
<title>CrispThinking.FastText.NetWrapper</title>
7+
<authors>Crisp Thinking</authors>
8+
<licenseUrl>https://raw.githubusercontent.com/crispthinking/FastText.NetWrapper/main/LICENSE</licenseUrl>
9+
<projectUrl>https://github.com/crispthinking/FastText.NetWrapper</projectUrl>
1010
<description>Crossplatform .NET wrapper for Facebook's FastText library. Works on Windows, Linux and MacOs!</description>
11-
<releaseNotes>Attention! We are deprecating some methods in 1.1 and replacing them with new API. Migration is really straightforward, but please be sure to read https://github.com/olegtarasov/FastText.NetWrapper/blob/master/README.md for guidance.</releaseNotes>
11+
<releaseNotes>Attention! We are deprecating some methods in 1.1 and replacing them with new API. Migration is really straightforward, but please be sure to read https://github.com/crispthinking/FastText.NetWrapper/blob/main/README.md for guidance.</releaseNotes>
1212
<copyright>Oleg Tarasov</copyright>
13-
<repository url="https://github.com/olegtarasov/FastText.NetWrapper" />
13+
<repository url="https://github.com/crispthinking/FastText.NetWrapper" />
1414
<dependencies>
1515
<group targetFramework=".NETStandard2.0">
1616
<dependency id="FastText.Native.Linux" version="1.0.115" />

0 commit comments

Comments
 (0)