Skip to content

Commit f7295e6

Browse files
authored
Merge pull request #200 from Lachee/feat-gh-actions
Github Action
2 parents a9fcc8d + 85fcb5f commit f7295e6

Some content is hidden

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

51 files changed

+927
-676
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Create Documentation 📚
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
# Build the documentation
10+
build:
11+
runs-on: ubuntu-latest #windows-latest # Required by DocFX
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-dotnet@v2
15+
- uses: crazy-max/[email protected]
16+
17+
- name: Install DocFX
18+
run: choco install -y docfx && docfx --version
19+
20+
- name: Use README.md as index.md
21+
run: cp README.md Docfx/index.md
22+
23+
- name: Build Site
24+
run: docfx Docfx/docfx.json -t default,templates/darkfx
25+
26+
# Upload the generated documentation
27+
- name: Upload site artifact
28+
uses: actions/upload-artifact@v1
29+
with:
30+
name: _site
31+
path: _site # Must equals the 'build.dest' value on your docfx.json
32+
33+
# Deploy the generated documentation to the gh-pages branch
34+
deploy:
35+
needs: build
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v2
40+
41+
42+
# Download the generated documentation
43+
- name: Download site artifact
44+
uses: actions/download-artifact@v1
45+
with:
46+
name: _site
47+
48+
- name: Deploy
49+
uses: peaceiris/actions-gh-pages@v3
50+
with:
51+
github_token: ${{ secrets.GITHUB_TOKEN }}
52+
publish_branch: gh-pages
53+
publish_dir: _site

.github/workflows/publish.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish Package 💌
2+
3+
on:
4+
release:
5+
types: [published, released]
6+
7+
jobs:
8+
push:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-dotnet@v2
13+
14+
- name: Fetch Release Asset
15+
uses: dsaltares/[email protected]
16+
with:
17+
file: "DiscordRichPresence(.[0-9]+)+.nupkg"
18+
version: ${{github.event.release.id}}
19+
regex: true
20+
21+
- name: Publish Package
22+
run: |
23+
dotnet nuget push "**/*.nupkg" -k ${{secrets.NUGET_KEY}} -s https://api.nuget.org/v3/index.json

.github/workflows/release.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Create Release 📦
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
# Tag the build
10+
tag:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: Klemensas/action-autotag@stable
15+
id: auto-tag
16+
with:
17+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
18+
tag_prefix: "v"
19+
outputs:
20+
version: "${{steps.auto-tag.outputs.version}}.${{github.run_number}}"
21+
tag: ${{ steps.auto-tag.outputs.tagname }}
22+
23+
# build the packages
24+
build:
25+
runs-on: ubuntu-latest
26+
needs: [ tag ]
27+
steps:
28+
# Check-out repository
29+
- uses: actions/checkout@v3
30+
- uses: actions/setup-dotnet@v2
31+
32+
# Version the repository
33+
- name: Update Versions
34+
shell: pwsh
35+
run: |
36+
./.github/workflows/scripts/PatchAssemblyInfoVersion.ps1 ${{needs.tag.outputs.version}}
37+
./.github/workflows/scripts/PatchNuspecVersion.ps1 ${{needs.tag.outputs.version}}
38+
39+
# Library Build
40+
- name: Build Library
41+
run: dotnet build DiscordRPC -c Release
42+
43+
- name: Upload Library
44+
uses: actions/[email protected]
45+
with:
46+
name: "netstandard2.0-dll"
47+
path: "DiscordRPC/bin/Release/netstandard2.0"
48+
49+
# Nuget Builds
50+
- name: Build Nuget
51+
run: dotnet pack DiscordRPC -c Release
52+
53+
- name: Upload Nuget
54+
uses: actions/[email protected]
55+
with:
56+
name: "netstandard2.0-nuget"
57+
path: "DiscordRPC/bin/Release/*.nupkg"
58+
59+
# Update the release
60+
release:
61+
runs-on: ubuntu-latest
62+
needs: [ tag, build ]
63+
if: ${{ startsWith(needs.tag.outputs.tag, 'v') }}
64+
steps:
65+
- uses: actions/checkout@v3
66+
- uses: actions/download-artifact@v3
67+
with:
68+
path: artifacts
69+
- uses: "marvinpinto/action-automatic-releases@latest"
70+
with:
71+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
72+
automatic_release_tag: ${{ needs.tag.outputs.tag }}
73+
prerelease: true
74+
title: Release ${{ needs.tag.outputs.tag }}
75+
files: artifacts/**/*
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# from http://blogs.msdn.com/b/dotnetinterop/archive/2008/04/21/powershell-script-to-batch-update-assemblyinfo-cs-with-new-version.aspx
2+
#
3+
# SetVersion.ps1
4+
#
5+
# Set the version in all the AssemblyInfo.cs or AssemblyInfo.vb files in any subdirectory.
6+
#
7+
# usage:
8+
# from cmd.exe:
9+
# powershell.exe SetVersion.ps1 2.8.3.0
10+
#
11+
# from powershell.exe prompt:
12+
# .\SetVersion.ps1 2.8.3.0
13+
#
14+
# last saved Time-stamp: <Wednesday, April 23, 2008 11:46:40 (by dinoch)>
15+
#
16+
17+
18+
function Usage
19+
{
20+
echo "Usage: ";
21+
echo " from cmd.exe: ";
22+
echo " powershell.exe SetVersion.ps1 2.8.3.0";
23+
echo " ";
24+
echo " from powershell.exe prompt: ";
25+
echo " .\SetVersion.ps1 2.8.3.0";
26+
echo " ";
27+
}
28+
29+
30+
function Update-SourceVersion
31+
{
32+
Param ([string]$Version)
33+
$NewVersion = 'AssemblyVersion("' + $Version + '")';
34+
$NewFileVersion = 'AssemblyFileVersion("' + $Version + '")';
35+
36+
foreach ($o in $input)
37+
{
38+
Write-output $o.FullName
39+
$TmpFile = $o.FullName + ".tmp"
40+
41+
Get-Content $o.FullName -encoding utf8 |
42+
%{$_ -replace 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewVersion } |
43+
%{$_ -replace 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewFileVersion } |
44+
Set-Content $TmpFile -encoding utf8
45+
46+
move-item $TmpFile $o.FullName -force
47+
}
48+
}
49+
50+
51+
function Update-AllAssemblyInfoFiles ( $version )
52+
{
53+
foreach ($file in "AssemblyInfo.cs", "AssemblyInfo.vb" )
54+
{
55+
get-childitem -recurse |? {$_.Name -eq $file} | Update-SourceVersion $version ;
56+
}
57+
}
58+
59+
60+
# validate arguments
61+
$r= [System.Text.RegularExpressions.Regex]::Match($args[0], "^[0-9]+(\.[0-9]+){1,3}$");
62+
63+
if ($r.Success)
64+
{
65+
Update-AllAssemblyInfoFiles $args[0];
66+
}
67+
else
68+
{
69+
echo " ";
70+
echo "Bad Input!"
71+
echo " ";
72+
Usage ;
73+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# from http://blogs.msdn.com/b/dotnetinterop/archive/2008/04/21/powershell-script-to-batch-update-assemblyinfo-cs-with-new-version.aspx
2+
#
3+
# SetVersion.ps1
4+
#
5+
# Set the version in all the AssemblyInfo.cs or AssemblyInfo.vb files in any subdirectory.
6+
#
7+
# usage:
8+
# from cmd.exe:
9+
# powershell.exe SetVersion.ps1 2.8.3.0
10+
#
11+
# from powershell.exe prompt:
12+
# .\SetVersion.ps1 2.8.3.0
13+
#
14+
# last saved Time-stamp: <Wednesday, April 23, 2008 11:46:40 (by dinoch)>
15+
#
16+
17+
18+
function Usage
19+
{
20+
echo "Usage: ";
21+
echo " from cmd.exe: ";
22+
echo " powershell.exe SetVersion.ps1 2.8.3.0";
23+
echo " ";
24+
echo " from powershell.exe prompt: ";
25+
echo " .\SetVersion.ps1 2.8.3.0";
26+
echo " ";
27+
}
28+
29+
30+
function Update-SourceVersion
31+
{
32+
Param ([string]$Version)
33+
$NewVersion = '<version>' + $Version + '</version>';
34+
35+
foreach ($o in $input)
36+
{
37+
Write-output $o.FullName
38+
$TmpFile = $o.FullName + ".tmp"
39+
40+
Get-Content $o.FullName -encoding utf8 |
41+
%{$_ -replace '<version>[0-9]+(\.([0-9]+|\*)){1,3}</version>', $NewVersion } |
42+
Set-Content $TmpFile -encoding utf8
43+
44+
move-item $TmpFile $o.FullName -force
45+
}
46+
}
47+
48+
function Update-AllAssemblyInfoFiles ( $version )
49+
{
50+
get-childitem -Path *.nuspec -recurse | Update-SourceVersion $version;
51+
}
52+
53+
# validate arguments
54+
$r= [System.Text.RegularExpressions.Regex]::Match($args[0], "^[0-9]+(\.[0-9]+){1,3}$");
55+
56+
if ($r.Success)
57+
{
58+
Update-AllAssemblyInfoFiles $args[0];
59+
}
60+
else
61+
{
62+
echo " ";
63+
echo "Bad Input!"
64+
echo " ";
65+
Usage ;
66+
}

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,8 @@ __pycache__/
298298

299299
# Cake - Uncomment if you are using it
300300
tools/
301-
Thumbs.db
301+
Thumbs.db
302+
303+
# Docfx generation
304+
docs/
305+
_site/

DiscordRPC.Example/DiscordRPC.Example.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFrameworks>net45;netcoreapp3.1</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
55
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
66
</PropertyGroup>
77
<ItemGroup>
@@ -13,4 +13,4 @@
1313
<PrivateAssets>all</PrivateAssets>
1414
</PackageReference>
1515
</ItemGroup>
16-
</Project>
16+
</Project>

DiscordRPC.Example/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
//
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
34+
// [assembly: AssemblyVersion("1.0.0.0")]
3535
[assembly: AssemblyVersion("1.0.0.0")]
3636
[assembly: AssemblyFileVersion("1.0.0.0")]

DiscordRPC/DiscordRPC.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
3-
<TargetFrameworks>net35;netstandard2.0</TargetFrameworks>
3+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
44
<NuspecFile>DiscordRPC.nuspec</NuspecFile>
55
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
6+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
7+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
68
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
79
</PropertyGroup>
810
<ItemGroup>
911
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
1012
</ItemGroup>
1113
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
14+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
1215
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
1316
</ItemGroup>
14-
</Project>
17+
</Project>

DiscordRPC/DiscordRPC.nuspec

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
33
<metadata xmlns="http://schemas.microsoft.com/packaging/21.0.07/nuspec.xsd">
44
<id>DiscordRichPresence</id>
5-
<version>0.0.0</version>
5+
<version>1.0.0.0</version>
66
<authors>Lachee</authors>
77
<owners>Lachee</owners>
88
<title>Discord Rich Presence</title>
@@ -23,23 +23,16 @@ This is an unoffical, non-discord supported library.
2323
<tags>Discord Discord Rich Presence RPC Discord-RPC</tags>
2424

2525
<dependencies>
26-
<group targetFramework="net35">
27-
<dependency id="Newtonsoft.Json" version="12.0.2" />
28-
</group>
29-
<group targetFramework="netstandard2.0">
30-
<dependency id="Newtonsoft.Json" version="12.0.2" />
26+
<group targetFramework="netstandard2.0">
27+
<dependency id="Newtonsoft.Json" version="12.0.2" />
3128
<dependency id="Microsoft.Win32.Registry" version="4.5.0" />
32-
</group>
33-
29+
</group>
3430
</dependencies>
3531
</metadata>
3632

3733
<files>
38-
<file src="./bin/Release/net35/DiscordRPC.dll" target="lib\net35" />
39-
<file src="./bin/Release/net35/DiscordRPC.pdb" target="lib\net35" />
40-
<file src="./bin/Release/net35/DiscordRPC.xml" target="lib\net35" />
4134
<file src="./bin/Release/netstandard2.0/DiscordRPC.dll" target="lib\netstandard2.0" />
4235
<file src="./bin/Release/netstandard2.0/DiscordRPC.pdb" target="lib\netstandard2.0" />
4336
<file src="./bin/Release/netstandard2.0/DiscordRPC.xml" target="lib\netstandard2.0" />
4437
</files>
45-
</package>
38+
</package>

0 commit comments

Comments
 (0)