Create validation and release workflows for nuget packages #11
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release nuget package | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- master | |
jobs: | |
windows: | |
runs-on: windows-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- arch: 'amd64' | |
platform: 'x64' | |
- arch: 'arm64' | |
platform: 'ARM64' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: compnerd/gha-setup-vsdevenv@main | |
with: | |
host_arch: amd64 | |
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' | |
arch: ${{ matrix.arch }} | |
- uses: actions/setup-python@v4 | |
id: python | |
with: | |
python-version: 3.9 | |
architecture: 'x64' | |
- name: Build StaticRelease | |
run: | |
msbuild .\builds\msvc\vs2022\libsodium.sln /p:Configuration=StaticRelease /p:Platform=${{ matrix.platform }} | |
- name: Build DynRelease | |
run: | |
msbuild .\builds\msvc\vs2022\libsodium.sln /p:Configuration=DynRelease /p:Platform=${{ matrix.platform }} | |
- name: Build LtcgRelease | |
run: | |
msbuild .\builds\msvc\vs2022\libsodium.sln /p:Configuration=LtcgRelease /p:Platform=${{ matrix.platform }} | |
- name: Tree pwd | |
run: | |
tree /f | |
- name: Tree workspace | |
run: | |
tree ${{ github.workspace }} /f | |
- name: LS | |
run: | |
ls ${{ github.workspace }}\bin\${{matrix.platform}}\Release\v143\static\libsodium.lib | |
- name: Package libsodium | |
run: | | |
@" | |
<?xml version="1.0" encoding="utf-8"?> | |
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | |
<metadata> | |
<id>org.libsodium.libsodium.windows.${{ matrix.arch }}</id> | |
<version>0.0.0</version> | |
<title>libsodium </title> | |
<description>libsodium</description> | |
<authors>org.libsodium</authors> | |
<projectUrl>https://libsodium.org</projectUrl> | |
<repository type="git" url="https://github.com/jedisct1/libsodium" branch="master" /> | |
</metadata> | |
<files> | |
<file src="${{ github.workspace }}\bin\${{matrix.platform}}\Release\v143\static\libsodium.lib" target="lib/static" /> | |
<file src="${{ github.workspace }}\bin\${{matrix.platform}}\Release\v143\static\libsodium.pdb" target="lib/static" /> | |
<file src="${{ github.workspace }}\bin\${{matrix.platform}}\Release\v143\dynamic\libsodium.lib" target="lib/dynamic" /> | |
<file src="${{ github.workspace }}\bin\${{matrix.platform}}\Release\v143\dynamic\libsodium.pdb" target="lib/dynamic" /> | |
<file src="${{ github.workspace }}\bin\${{matrix.platform}}\Release\v143\dynamic\libsodium.dll" target="lib/dynamic" /> | |
<file src="${{ github.workspace }}\bin\${{matrix.platform}}\Release\v143\dynamic\libsodium.exp" target="lib/dynamic" /> | |
<file src="${{ github.workspace }}\bin\${{matrix.platform}}\Release\v143\ltcg\libsodium.lib" target="lib/ltcg" /> | |
</files> | |
</package> | |
"@ | Out-File -Encoding UTF8 libsodium.nuspec | |
nuget pack -Suffix (git -C log -1 --format=%h) libsodium.nuspec | |
shell: pwsh | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: windows-${{ matrix.arch }}.nupkg | |
path: org.libsodium.libsodium.windows.${{ matrix.arch }}.*.nupkg | |
- name: Publish NuGet Packages | |
env: | |
NUGET_SOURCE_NAME: TheBrowserCompany | |
NUGET_SOURCE_URL: https://nuget.pkg.github.com/thebrowsercompany/index.json | |
NUGET_SOURCE_USERNAME: thebrowsercompany-bot2 | |
NUGET_SOURCE_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
NUGET_API_KEY: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if ((nuget sources List | Select-String "${env:NUGET_SOURCE_NAME}").Count -gt 0) { | |
nuget sources Remove -Name "${env:NUGET_SOURCE_NAME}" | |
} | |
nuget sources Add -Name ${env:NUGET_SOURCE_NAME} -Source ${env:NUGET_SOURCE_URL} -Username ${env:NUGET_SOURCE_USERNAME} -Password ${env:NUGET_SOURCE_PASSWORD} -StorePasswordInClearText | |
nuget setApiKey ${env:NUGET_API_KEY} -Source ${env:NUGET_SOURCE_URL} | |
$pkgs = Get-ChildItem -Path org.libsodium.libsodium.windows.${{ matrix.arch }}.*.nupkg | |
nuget push $pkgs[0].Name -Source ${env:NUGET_SOURCE_URL} -SkipDuplicate | |
shell: pwsh |