-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from Lachee/feat-gh-actions
Github Action
- Loading branch information
Showing
51 changed files
with
927 additions
and
676 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Create Documentation 📚 | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
# Build the documentation | ||
build: | ||
runs-on: ubuntu-latest #windows-latest # Required by DocFX | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-dotnet@v2 | ||
- uses: crazy-max/[email protected] | ||
|
||
- name: Install DocFX | ||
run: choco install -y docfx && docfx --version | ||
|
||
- name: Use README.md as index.md | ||
run: cp README.md Docfx/index.md | ||
|
||
- name: Build Site | ||
run: docfx Docfx/docfx.json -t default,templates/darkfx | ||
|
||
# Upload the generated documentation | ||
- name: Upload site artifact | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: _site | ||
path: _site # Must equals the 'build.dest' value on your docfx.json | ||
|
||
# Deploy the generated documentation to the gh-pages branch | ||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
|
||
# Download the generated documentation | ||
- name: Download site artifact | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: _site | ||
|
||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_branch: gh-pages | ||
publish_dir: _site |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Publish Package 💌 | ||
|
||
on: | ||
release: | ||
types: [published, released] | ||
|
||
jobs: | ||
push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-dotnet@v2 | ||
|
||
- name: Fetch Release Asset | ||
uses: dsaltares/[email protected] | ||
with: | ||
file: "DiscordRichPresence(.[0-9]+)+.nupkg" | ||
version: ${{github.event.release.id}} | ||
regex: true | ||
|
||
- name: Publish Package | ||
run: | | ||
dotnet nuget push "**/*.nupkg" -k ${{secrets.NUGET_KEY}} -s https://api.nuget.org/v3/index.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Create Release 📦 | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
# Tag the build | ||
tag: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: Klemensas/action-autotag@stable | ||
id: auto-tag | ||
with: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
tag_prefix: "v" | ||
outputs: | ||
version: "${{steps.auto-tag.outputs.version}}.${{github.run_number}}" | ||
tag: ${{ steps.auto-tag.outputs.tagname }} | ||
|
||
# build the packages | ||
build: | ||
runs-on: ubuntu-latest | ||
needs: [ tag ] | ||
steps: | ||
# Check-out repository | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-dotnet@v2 | ||
|
||
# Version the repository | ||
- name: Update Versions | ||
shell: pwsh | ||
run: | | ||
./.github/workflows/scripts/PatchAssemblyInfoVersion.ps1 ${{needs.tag.outputs.version}} | ||
./.github/workflows/scripts/PatchNuspecVersion.ps1 ${{needs.tag.outputs.version}} | ||
# Library Build | ||
- name: Build Library | ||
run: dotnet build DiscordRPC -c Release | ||
|
||
- name: Upload Library | ||
uses: actions/[email protected] | ||
with: | ||
name: "netstandard2.0-dll" | ||
path: "DiscordRPC/bin/Release/netstandard2.0" | ||
|
||
# Nuget Builds | ||
- name: Build Nuget | ||
run: dotnet pack DiscordRPC -c Release | ||
|
||
- name: Upload Nuget | ||
uses: actions/[email protected] | ||
with: | ||
name: "netstandard2.0-nuget" | ||
path: "DiscordRPC/bin/Release/*.nupkg" | ||
|
||
# Update the release | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: [ tag, build ] | ||
if: ${{ startsWith(needs.tag.outputs.tag, 'v') }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
path: artifacts | ||
- uses: "marvinpinto/action-automatic-releases@latest" | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
automatic_release_tag: ${{ needs.tag.outputs.tag }} | ||
prerelease: true | ||
title: Release ${{ needs.tag.outputs.tag }} | ||
files: artifacts/**/* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# from http://blogs.msdn.com/b/dotnetinterop/archive/2008/04/21/powershell-script-to-batch-update-assemblyinfo-cs-with-new-version.aspx | ||
# | ||
# SetVersion.ps1 | ||
# | ||
# Set the version in all the AssemblyInfo.cs or AssemblyInfo.vb files in any subdirectory. | ||
# | ||
# usage: | ||
# from cmd.exe: | ||
# powershell.exe SetVersion.ps1 2.8.3.0 | ||
# | ||
# from powershell.exe prompt: | ||
# .\SetVersion.ps1 2.8.3.0 | ||
# | ||
# last saved Time-stamp: <Wednesday, April 23, 2008 11:46:40 (by dinoch)> | ||
# | ||
|
||
|
||
function Usage | ||
{ | ||
echo "Usage: "; | ||
echo " from cmd.exe: "; | ||
echo " powershell.exe SetVersion.ps1 2.8.3.0"; | ||
echo " "; | ||
echo " from powershell.exe prompt: "; | ||
echo " .\SetVersion.ps1 2.8.3.0"; | ||
echo " "; | ||
} | ||
|
||
|
||
function Update-SourceVersion | ||
{ | ||
Param ([string]$Version) | ||
$NewVersion = 'AssemblyVersion("' + $Version + '")'; | ||
$NewFileVersion = 'AssemblyFileVersion("' + $Version + '")'; | ||
|
||
foreach ($o in $input) | ||
{ | ||
Write-output $o.FullName | ||
$TmpFile = $o.FullName + ".tmp" | ||
|
||
Get-Content $o.FullName -encoding utf8 | | ||
%{$_ -replace 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewVersion } | | ||
%{$_ -replace 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewFileVersion } | | ||
Set-Content $TmpFile -encoding utf8 | ||
|
||
move-item $TmpFile $o.FullName -force | ||
} | ||
} | ||
|
||
|
||
function Update-AllAssemblyInfoFiles ( $version ) | ||
{ | ||
foreach ($file in "AssemblyInfo.cs", "AssemblyInfo.vb" ) | ||
{ | ||
get-childitem -recurse |? {$_.Name -eq $file} | Update-SourceVersion $version ; | ||
} | ||
} | ||
|
||
|
||
# validate arguments | ||
$r= [System.Text.RegularExpressions.Regex]::Match($args[0], "^[0-9]+(\.[0-9]+){1,3}$"); | ||
|
||
if ($r.Success) | ||
{ | ||
Update-AllAssemblyInfoFiles $args[0]; | ||
} | ||
else | ||
{ | ||
echo " "; | ||
echo "Bad Input!" | ||
echo " "; | ||
Usage ; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# from http://blogs.msdn.com/b/dotnetinterop/archive/2008/04/21/powershell-script-to-batch-update-assemblyinfo-cs-with-new-version.aspx | ||
# | ||
# SetVersion.ps1 | ||
# | ||
# Set the version in all the AssemblyInfo.cs or AssemblyInfo.vb files in any subdirectory. | ||
# | ||
# usage: | ||
# from cmd.exe: | ||
# powershell.exe SetVersion.ps1 2.8.3.0 | ||
# | ||
# from powershell.exe prompt: | ||
# .\SetVersion.ps1 2.8.3.0 | ||
# | ||
# last saved Time-stamp: <Wednesday, April 23, 2008 11:46:40 (by dinoch)> | ||
# | ||
|
||
|
||
function Usage | ||
{ | ||
echo "Usage: "; | ||
echo " from cmd.exe: "; | ||
echo " powershell.exe SetVersion.ps1 2.8.3.0"; | ||
echo " "; | ||
echo " from powershell.exe prompt: "; | ||
echo " .\SetVersion.ps1 2.8.3.0"; | ||
echo " "; | ||
} | ||
|
||
|
||
function Update-SourceVersion | ||
{ | ||
Param ([string]$Version) | ||
$NewVersion = '<version>' + $Version + '</version>'; | ||
|
||
foreach ($o in $input) | ||
{ | ||
Write-output $o.FullName | ||
$TmpFile = $o.FullName + ".tmp" | ||
|
||
Get-Content $o.FullName -encoding utf8 | | ||
%{$_ -replace '<version>[0-9]+(\.([0-9]+|\*)){1,3}</version>', $NewVersion } | | ||
Set-Content $TmpFile -encoding utf8 | ||
|
||
move-item $TmpFile $o.FullName -force | ||
} | ||
} | ||
|
||
function Update-AllAssemblyInfoFiles ( $version ) | ||
{ | ||
get-childitem -Path *.nuspec -recurse | Update-SourceVersion $version; | ||
} | ||
|
||
# validate arguments | ||
$r= [System.Text.RegularExpressions.Regex]::Match($args[0], "^[0-9]+(\.[0-9]+){1,3}$"); | ||
|
||
if ($r.Success) | ||
{ | ||
Update-AllAssemblyInfoFiles $args[0]; | ||
} | ||
else | ||
{ | ||
echo " "; | ||
echo "Bad Input!" | ||
echo " "; | ||
Usage ; | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net35;netstandard2.0</TargetFrameworks> | ||
<TargetFrameworks>netstandard2.0</TargetFrameworks> | ||
<NuspecFile>DiscordRPC.nuspec</NuspecFile> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> | ||
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" /> | ||
</ItemGroup> | ||
</Project> | ||
</Project> |
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
Oops, something went wrong.