Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate platform packages #113

Merged
merged 24 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4d5c813
(#92) Build: migrate from .nuspec to .proj
ForNeVeR May 19, 2024
4e840a7
(#92) Build: extract common properties to Directory.Build.props
ForNeVeR May 19, 2024
aa73159
(#92) CI: update the step naming
ForNeVeR May 19, 2024
7625136
(#92) Build: ignore the warning about fake TFM
ForNeVeR May 19, 2024
22db4c3
(#92) Pack: add documentation and update TFM
ForNeVeR May 19, 2024
9203830
(#92) Pack: suppress the dependency groups in the generated .nuspec
ForNeVeR May 19, 2024
95e9744
(#92) Build: separate packages per platform
ForNeVeR May 19, 2024
b6ec094
(#92) Test: prepare NuGet package from the right project on CI
ForNeVeR May 19, 2024
943132f
(#92) Test: use the proper package name for installation
ForNeVeR May 19, 2024
0314677
(#92) Test: remove the base package during testing
ForNeVeR May 19, 2024
5548fda
(#92) Test: more diagnostics for package installation
ForNeVeR May 19, 2024
91adcdb
(#92) Pack: fix the platform package names
ForNeVeR May 19, 2024
3560be0
(#92) Release: choose the correct project file
ForNeVeR May 19, 2024
25c38b4
(#92) CI: update the way we use NuGet for packaging
ForNeVeR May 19, 2024
4c6fee6
(#92) CI: minor wording update
ForNeVeR May 19, 2024
dc4fee0
(#92) CI: more logging of the package dir contents
ForNeVeR May 19, 2024
b856422
(#92) CI: fix syntax for dotnet pack invocation
ForNeVeR May 19, 2024
f72beb9
(#92) Pack: fix the NuGet source preparation script
ForNeVeR May 19, 2024
22b748b
(#92) CI: more diagnostics
ForNeVeR May 19, 2024
3749e1f
(#92) Build: sort the dependencies
ForNeVeR May 19, 2024
e51ba13
(#92) CI: read the file tree in the source
ForNeVeR May 19, 2024
b8a31cf
(#92) Build: fix the package references
ForNeVeR May 19, 2024
0bb71a1
(#92) CI: fix the release workflow
ForNeVeR May 19, 2024
7f22650
(#92) Docs: update the maintainer guide
ForNeVeR May 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 92 additions & 31 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ jobs:
dotnet-version: 7.0.x
- name: Pack NuGet
shell: pwsh
run: dotnet pack -p:PackageVersion=${{ env.PACKAGE_VERSION_BASE }}-preview --output build
run: dotnet pack tdlib.native.linux-x64.proj -p:Version=${{ env.PACKAGE_VERSION_BASE }}-preview --output build
- name: NuGet cache
uses: actions/cache@v4
with:
key: ${{ runner.os }}.nuget.${{ hashFiles('tdsharp/**/*.csproj') }}
path: ${{ env.NUGET_PACKAGES }}
- name: Test
shell: pwsh
run: ./common/test.ps1 -NuGet $env:GITHUB_WORKSPACE/tools/nuget.exe -UseMono
run: ./common/test.ps1 -PackageName tdlib.native.linux-x64 -NuGet $env:GITHUB_WORKSPACE/tools/nuget.exe -UseMono
test-macos-aarch64:
needs:
- build-macos-aarch64
Expand All @@ -200,15 +200,15 @@ jobs:
dotnet-version: 7.0.x
- name: Pack NuGet
shell: pwsh
run: dotnet pack -p:PackageVersion=${{ env.PACKAGE_VERSION_BASE }}-preview --output build
run: dotnet pack tdlib.native.osx-arm64.proj -p:Version=${{ env.PACKAGE_VERSION_BASE }}-preview --output build
- name: NuGet cache
uses: actions/cache@v4
with:
key: ${{ runner.os }}.nuget.${{ hashFiles('tdsharp/**/*.csproj') }}
path: ${{ env.NUGET_PACKAGES }}
- name: Test
shell: pwsh
run: ./common/test.ps1 -NuGet nuget
run: ./common/test.ps1 -PackageName tdlib.native.osx-arm64 -NuGet nuget
test-macos-x86-64:
needs:
- build-macos-x86-64
Expand All @@ -234,15 +234,15 @@ jobs:
dotnet-version: 7.0.x
- name: Pack NuGet
shell: pwsh
run: dotnet pack -p:PackageVersion=${{ env.PACKAGE_VERSION_BASE }}-preview --output build
run: dotnet pack tdlib.native.osx-x64.proj -p:Version=${{ env.PACKAGE_VERSION_BASE }}-preview --output build
- name: NuGet cache
uses: actions/cache@v4
with:
key: ${{ runner.os }}.nuget.${{ hashFiles('tdsharp/**/*.csproj') }}
path: ${{ env.NUGET_PACKAGES }}
- name: Test
shell: pwsh
run: ./common/test.ps1 -NuGet nuget
run: ./common/test.ps1 -PackageName tdlib.native.osx-x64 -NuGet nuget
test-windows-x86-64:
needs:
- build-windows-x86-64
Expand Down Expand Up @@ -279,15 +279,15 @@ jobs:
dotnet-version: 7.0.x
- name: Pack NuGet
shell: pwsh
run: dotnet pack -p:PackageVersion=${{ env.PACKAGE_VERSION_BASE }}-preview --output build
run: dotnet pack tdlib.native.win-x64.proj -p:Version=${{ env.PACKAGE_VERSION_BASE }}-preview --output build
- name: NuGet cache
uses: actions/cache@v4
with:
key: ${{ runner.os }}.nuget.${{ hashFiles('tdsharp/**/*.csproj') }}
path: ${{ env.NUGET_PACKAGES }}
- name: Test
shell: pwsh
run: ./common/test.ps1 -NuGet nuget
run: ./common/test.ps1 -PackageName tdlib.native.win-x64 -NuGet nuget
release:
needs:
- build-linux-x86-64
Expand All @@ -307,31 +307,31 @@ jobs:
with:
name: tdlib.linux.x86-64
path: ./build/runtimes/linux-x64/native
- name: 'Archive artifact for platform: linux'
- name: 'Archive artifact for platform: linux.x86-64'
shell: pwsh
run: Set-Location ./build/runtimes/linux-x64/native && zip -r $env:GITHUB_WORKSPACE/tdlib.linux.x86-64.zip *
- name: 'Download artifact: macos.aarch64'
uses: actions/download-artifact@v4
with:
name: tdlib.macos.aarch64
path: ./build/runtimes/osx-arm64/native
- name: 'Archive artifact for platform: macos'
- name: 'Archive artifact for platform: macos.aarch64'
shell: pwsh
run: Set-Location ./build/runtimes/osx-arm64/native && zip -r $env:GITHUB_WORKSPACE/tdlib.macos.aarch64.zip *
- name: 'Download artifact: macos.x86-64'
uses: actions/download-artifact@v4
with:
name: tdlib.macos.x86-64
path: ./build/runtimes/osx-x64/native
- name: 'Archive artifact for platform: macos'
- name: 'Archive artifact for platform: macos.x86-64'
shell: pwsh
run: Set-Location ./build/runtimes/osx-x64/native && zip -r $env:GITHUB_WORKSPACE/tdlib.macos.x86-64.zip *
- name: 'Download artifact: windows.x86-64'
uses: actions/download-artifact@v4
with:
name: tdlib.windows.x86-64
path: ./build/runtimes/win-x64/native
- name: 'Archive artifact for platform: windows'
- name: 'Archive artifact for platform: windows.x86-64'
shell: pwsh
run: Set-Location ./build/runtimes/win-x64/native && zip -r $env:GITHUB_WORKSPACE/tdlib.windows.x86-64.zip *
- name: Set up .NET SDK
Expand All @@ -342,29 +342,38 @@ jobs:
name: Read version from ref
shell: pwsh
run: "\"version=$(if ($env:GITHUB_REF.StartsWith('refs/tags/v')) { $env:GITHUB_REF -replace '^refs/tags/v', '' } else { \"$env:PACKAGE_VERSION_BASE-preview\" })\" >> $env:GITHUB_OUTPUT"
- name: Prepare the release notes (text)
uses: ForNeVeR/ChangelogAutomation.action@v1
with:
format: PlainText
input: ./CHANGELOG.md
output: releaseNotes.txt
- name: Prepare the release notes (Markdown)
- name: Prepare the release notes
uses: ForNeVeR/ChangelogAutomation.action@v1
with:
format: Markdown
input: ./CHANGELOG.md
output: release-notes.md
- name: Update the release notes
- name: 'Pack NuGet package: linux.x86-64'
shell: pwsh
run: ./common/update-release-notes.ps1 ./releaseNotes.txt
- name: Prepare NuGet package
run: dotnet pack tdlib.native.linux-x64.proj -p:Version=${{ steps.version.outputs.version }} --output build
- name: 'Pack NuGet package: macos.aarch64'
shell: pwsh
run: dotnet pack -p:PackageVersion=${{ steps.version.outputs.version }} --output build
- name: Upload NuGet package
run: dotnet pack tdlib.native.osx-arm64.proj -p:Version=${{ steps.version.outputs.version }} --output build
- name: 'Pack NuGet package: macos.x86-64'
shell: pwsh
run: dotnet pack tdlib.native.osx-x64.proj -p:Version=${{ steps.version.outputs.version }} --output build
- name: 'Pack NuGet package: windows.x86-64'
shell: pwsh
run: dotnet pack tdlib.native.win-x64.proj -p:Version=${{ steps.version.outputs.version }} --output build
- name: Install dependencies
shell: pwsh
run: ./linux/install.ps1 -ForPack
- name: Prepare NuGet source
shell: pwsh
run: common/New-NuGetSource.ps1 -UseMono -NuGet $env:GITHUB_WORKSPACE/tools/nuget.exe
- name: 'Pack NuGet package: main'
shell: pwsh
run: dotnet pack tdlib.native.proj -p:Version=${{ steps.version.outputs.version }} --output build
- name: Upload NuGet packages
uses: actions/upload-artifact@v4
with:
name: tdlib.nuget
path: ./build/tdlib.native.${{ steps.version.outputs.version }}.nupkg
path: ./build/*.nupkg
- if: startsWith(github.ref, 'refs/tags/v')
id: release
name: Create release
Expand All @@ -376,7 +385,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: startsWith(github.ref, 'refs/tags/v')
name: 'Release artifact: linux.x86-64'
name: 'Upload archive: linux.x86-64'
uses: actions/upload-release-asset@v1
with:
asset_content_type: application/zip
Expand All @@ -386,7 +395,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: startsWith(github.ref, 'refs/tags/v')
name: 'Release artifact: macos.aarch64'
name: 'Upload archive: macos.aarch64'
uses: actions/upload-release-asset@v1
with:
asset_content_type: application/zip
Expand All @@ -396,7 +405,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: startsWith(github.ref, 'refs/tags/v')
name: 'Release artifact: macos.x86-64'
name: 'Upload archive: macos.x86-64'
uses: actions/upload-release-asset@v1
with:
asset_content_type: application/zip
Expand All @@ -406,7 +415,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: startsWith(github.ref, 'refs/tags/v')
name: 'Release artifact: windows.x86-64'
name: 'Upload archive: windows.x86-64'
uses: actions/upload-release-asset@v1
with:
asset_content_type: application/zip
Expand All @@ -416,7 +425,47 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: startsWith(github.ref, 'refs/tags/v')
name: Release NuGet package
name: 'Upload NuGet package: tdlib.native.linux-x64.${{ steps.version.outputs.version }}.nupkg'
uses: actions/upload-release-asset@v1
with:
asset_content_type: application/zip
asset_name: tdlib.native.linux-x64.${{ steps.version.outputs.version }}.nupkg
asset_path: ./build/tdlib.native.linux-x64.${{ steps.version.outputs.version }}.nupkg
upload_url: ${{ steps.release.outputs.upload_url }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: startsWith(github.ref, 'refs/tags/v')
name: 'Upload NuGet package: tdlib.native.osx-arm64.${{ steps.version.outputs.version }}.nupkg'
uses: actions/upload-release-asset@v1
with:
asset_content_type: application/zip
asset_name: tdlib.native.osx-arm64.${{ steps.version.outputs.version }}.nupkg
asset_path: ./build/tdlib.native.osx-arm64.${{ steps.version.outputs.version }}.nupkg
upload_url: ${{ steps.release.outputs.upload_url }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: startsWith(github.ref, 'refs/tags/v')
name: 'Upload NuGet package: tdlib.native.osx-x64.${{ steps.version.outputs.version }}.nupkg'
uses: actions/upload-release-asset@v1
with:
asset_content_type: application/zip
asset_name: tdlib.native.osx-x64.${{ steps.version.outputs.version }}.nupkg
asset_path: ./build/tdlib.native.osx-x64.${{ steps.version.outputs.version }}.nupkg
upload_url: ${{ steps.release.outputs.upload_url }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: startsWith(github.ref, 'refs/tags/v')
name: 'Upload NuGet package: tdlib.native.win-x64.${{ steps.version.outputs.version }}.nupkg'
uses: actions/upload-release-asset@v1
with:
asset_content_type: application/zip
asset_name: tdlib.native.win-x64.${{ steps.version.outputs.version }}.nupkg
asset_path: ./build/tdlib.native.win-x64.${{ steps.version.outputs.version }}.nupkg
upload_url: ${{ steps.release.outputs.upload_url }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: startsWith(github.ref, 'refs/tags/v')
name: 'Upload NuGet package: tdlib.native.${{ steps.version.outputs.version }}.nupkg'
uses: actions/upload-release-asset@v1
with:
asset_content_type: application/zip
Expand All @@ -426,7 +475,19 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
name: Push the package to nuget.org
name: Push tdlib.native.linux-x64.${{ steps.version.outputs.version }} to nuget.org
run: dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} ./build/tdlib.native.linux-x64.${{ steps.version.outputs.version }}.nupkg
- if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
name: Push tdlib.native.osx-arm64.${{ steps.version.outputs.version }} to nuget.org
run: dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} ./build/tdlib.native.osx-arm64.${{ steps.version.outputs.version }}.nupkg
- if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
name: Push tdlib.native.osx-x64.${{ steps.version.outputs.version }} to nuget.org
run: dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} ./build/tdlib.native.osx-x64.${{ steps.version.outputs.version }}.nupkg
- if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
name: Push tdlib.native.win-x64.${{ steps.version.outputs.version }} to nuget.org
run: dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} ./build/tdlib.native.win-x64.${{ steps.version.outputs.version }}.nupkg
- if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
name: Push tdlib.native.${{ steps.version.outputs.version }} to nuget.org
run: dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} ./build/tdlib.native.${{ steps.version.outputs.version }}.nupkg
verify-encoding:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/.idea/
/build/

bin/
obj/

*.temp.txt
24 changes: 24 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project>
<PropertyGroup>
<PackageLicenseExpression>BSL-1.0</PackageLicenseExpression>
<Copyright>2024 tdlib.native contributors</Copyright>
<PackageProjectUrl>https://github.com/ForNeVeR/tdlib.native</PackageProjectUrl>
<Description>NuGet packaging for tdlib: Telegram client library.</Description>
<PackageTags>telegram</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ChangelogAutomation.MSBuild" Version="2.0.0" PrivateAssets="All" />
<Content Include="LICENSE_1_0.txt" PackagePath="/" />
<Content Include="README.md" PackagePath="/" />
<Content Include="CHANGELOG.md" PackagePath="/" />
</ItemGroup>

<PropertyGroup>
<ChangelogFilePath>CHANGELOG.md</ChangelogFilePath>
<PackageReadmeFile>README.md</PackageReadmeFile>

<TargetFramework>native</TargetFramework>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
</PropertyGroup>
</Project>
6 changes: 4 additions & 2 deletions MAINTAINERSHIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Publish a New Version
3. Optionally, also update the submodule containing the tdsharp sources.
4. Prepare a corresponding entry in the `CHANGELOG.md`.
5. Update the license, if required.
6. Update the copyright year in the `copyright` section of the `tdlib.native.nuspec` file.
6. Update the copyright information in the `Copyright` element of the `Directory.Build.props` file.
7. Update the `PACKAGE_VERSION_BASE` to the new library version in the `github-actions.fsx`.
8. Regenerate the GitHub Actions workflow by running `dotnet fsi github-actions.fsx`.
9. Create a pull request, verify that the tests are okay. Merge it afterward.
Expand All @@ -27,9 +27,11 @@ To update the key:

1. Sign in onto nuget.org.
2. Go to the [API keys][nuget.api-keys] section.
3. Create a new key with permission to **Push new packages and package versions** and only allowed to publish **tdlib.native** package.
3. Create a new key with permission to **Push only new package versions** with the glob pattern of `github-actions.tdlib.native`.

Alternately, if you have such key already and want to regenerate it, press the **Regenerate** button in its page section.

If you are adding a new package, then use the **Push new packages and package versions** permission, but limit the key lifetime to the minimum possible date range — you will refresh it again using the limited set of permissions next time.
4. Paste the generated API keys to the [action secrets][github.secrets] section on GitHub settings (update the `NUGET_KEY` secret).

[docs.unlist]: https://docs.microsoft.com/en-us/nuget/nuget-org/policies/deleting-packages#unlisting-a-package
Expand Down
44 changes: 44 additions & 0 deletions common/New-NuGetSource.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
param (
$SourceRoot = "$PSScriptRoot/..",
$PackageDir = "$SourceRoot/build",
$PackageSource = "$SourceRoot/nuget",
$NuGetConfigTarget = "$SourceRoot/nuget.config",

[Parameter(Mandatory = $true)]
[string] $NuGet,
[switch] $UseMono,
$Mono = 'mono'
)

$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest

New-Item -Type Directory $PackageSource -ErrorAction Ignore
@"
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="local" value="$(Resolve-Path $PackageSource)"/>
</packageSources>
</configuration>
"@ > $NuGetConfigTarget

Write-Output "Contents of $($NuGetConfigTarget):"
Get-Content $NuGetConfigTarget

Write-Output "Contents of the packages directory:"
Get-ChildItem $PackageDir

Get-Item $PackageDir/*.nupkg | ForEach-Object {
$package = $_.FullName

Write-Output "Adding a package $package into NuGet source $PackageSource"
if ($UseMono) {
& $Mono $NuGet add $package -Source $PackageSource
} else {
& $NuGet add $package -Source $PackageSource
}
}

Write-Output "Content of the source ($(Resolve-Path $PackageSource)):"
Get-ChildItem -Recurse $PackageSource
11 changes: 8 additions & 3 deletions common/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ param (
[string] $PackageSource = "$BuildRoot/../build/nuget/",
[string] $TdSharpRoot = "$PSScriptRoot/../tdsharp",
[string] $TdSharpTestProjectName = 'TdLib.Tests',
[string] $PackageName = 'tdlib.native',
[string] $BasePackageName = 'tdlib.native',
[Parameter(Mandatory = $true)]
[string] $PackageName,

[string] $NuGet = 'NuGet.exe',
[switch] $UseMono,
Expand All @@ -27,14 +29,17 @@ if (!$?) { throw 'Cannot add a NuGet package into source' }

Push-Location "$TdSharpRoot/$TdSharpTestProjectName"
try {
Write-Output "Removing a package $PackageName from the project $TdSharpTestProjectName"
& $dotnet remove "$TdSharpTestProjectName.csproj" package $PackageName
Write-Output "Removing a package $BasePackageName from the project $TdSharpTestProjectName"
& $dotnet remove "$TdSharpTestProjectName.csproj" package $BasePackageName
if (!$?) { throw 'Cannot uninstall package from the test project' }

Write-Output 'Performing dotnet restore'
& $dotnet restore
if (!$?) { throw 'Cannot perform dotnet restore' }

Write-Output 'Available files at the package source:'
Get-ChildItem $PackageSource

Write-Output "Adding a package $PackageName from the project $TdSharpTestProjectName"
& $dotnet add "$TdSharpTestProjectName.csproj" package $PackageName --prerelease --source $PackageSource
if (!$?) { throw 'Cannot add package into the test project' }
Expand Down
Loading