Skip to content

Commit

Permalink
Add release github action
Browse files Browse the repository at this point in the history
Update packages
  • Loading branch information
JadynWong committed Mar 3, 2021
1 parent 84f8e61 commit cc40305
Show file tree
Hide file tree
Showing 13 changed files with 205 additions and 168 deletions.
4 changes: 4 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-P ubuntu-latest=catthehacker/ubuntu:act-latest
-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
-P ubuntu-18.04=catthehacker/ubuntu:act-18.04
ubuntu-16.04=catthehacker/ubuntu:act-16.04
4 changes: 3 additions & 1 deletion .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
dotnet-version: 5.0.103
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Test with dotnet
run: dotnet test --configuration Release
- name: Pack with dotnet
run: dotnet pack --configuration Release
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This is a basic workflow to help you get started with Actions

name: release

# Controls when the action will run.
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- '*' # Push events to matching v*, i.e. v1.0, v20.15.10

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: windows-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Get the version
id: get_version
shell: bash
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.103

- name: Build project
run: |
.\Build.ps1 -version ${{ steps.get_version.outputs.VERSION }} -nugetKey ${{ secrets.NugetKey }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: Release ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false

- name: Upload Release Asset
id: action-gh-release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
./artifacts/QQWry.${{ steps.get_version.outputs.VERSION }}.nupkg
./artifacts/QQWry.DependencyInjection.${{ steps.get_version.outputs.VERSION }}.nupkg
2 changes: 2 additions & 0 deletions .github/workflows/sync_qqwry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
# Runs a set of commands using the runners shell
- name: Git push
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m 'sync qqwry'
git push
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,5 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/
act/actions-setup-dotnet@v1
act/actions-setup-dotnet@v1
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

34 changes: 16 additions & 18 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
param(
[Parameter(Mandatory = $true)][string]$version = $(throw "Parameter missing: -version Version"),
[string]$nugetKey
)

$rootFolder = (Get-Item -Path "./" -Verbose).FullName
$outputFolder = (Join-Path $rootFolder "artifacts")
if(Test-Path $outputFolder) { Remove-Item $outputFolder -Force -Recurse }
if (Test-Path $outputFolder) { Remove-Item $outputFolder -Force -Recurse }

dotnet restore
Write-Output "Version:$version"

$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$NULL -ne $env:APPVEYOR_BUILD_NUMBER];
dotnet build QQWrySln.sln --configuration Release

$revision = [convert]::ToInt32($revision, 10)
dotnet test QQWrySln.sln --configuration Release

Write-Output $revision
dotnet pack .\QQWry -o $outputFolder -p:Version=$version --configuration Release

$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "-1"}[$NULL -ne $env:APPVEYOR_BUILD_VERSION];
dotnet pack .\QQWry.DependencyInjection -o $outputFolder -p:Version=$version --configuration Release

if($version -eq "-1"){
throw "can't read version"
if ($nugetKey) {
dotnet nuget push "$outputFolder\*.nupkg" --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key $nugetKey
}
else {
Write-Output "Skip nuget push"
}

Write-Output $version

dotnet test .\QQWryTest -c Release

dotnet build QQWrySln.sln

dotnet pack .\QQWry -o $outputFolder -p:Version=$version --version-suffix=$revision

dotnet pack .\QQWry.DependencyInjection -o $outputFolder -p:Version=$version --version-suffix=$revision

Set-Location $outputFolder

Expand Down
23 changes: 13 additions & 10 deletions QQWry.DependencyInjection/QQWry.DependencyInjection.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net5;</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>JadynWong</Copyright>
<PackageProjectUrl>https://github.com/JadynWong/IP_qqwry</PackageProjectUrl>
Expand All @@ -13,32 +13,35 @@
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.*" />
</ItemGroup>



<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.*" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.*" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.*" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.2' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.*" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.*" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.*" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net5' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.*" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 3 additions & 5 deletions QQWry/QQWry.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net4.5</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net5;net4.5</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>JadynWong</Copyright>
Expand All @@ -15,17 +15,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SharpZipLib" Version="1.2.0" />
<PackageReference Include="SharpZipLib" Version="1.3.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net4.5'">
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net4.5'">
<PackageReference Include="System.Text.Encoding.CodePages">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.Text.Encoding.CodePages" Version="5.0.0" />
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions QQWryTest/QQWry.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5</TargetFramework>
<IsPackable>false</IsPackable>
<RootNamespace>QQWry.Test</RootNamespace>
<AssemblyName>QQWry.Test</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit cc40305

Please sign in to comment.