Skip to content

Commit

Permalink
👷 Add GH Actions CI
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelJansson committed Jul 12, 2023
1 parent f1ce642 commit d1b923d
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 4 deletions.
16 changes: 16 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name-template: 'v$NEXT_PATCH_VERSION'
tag-template: 'v$NEXT_PATCH_VERSION'
template: |
# What's Changed
$CHANGES
categories:
- title: '🚀 Features'
label: 'Feature'
- title: '🐛 Bug Fixes'
label: 'Bug'
- title: '🧰 Maintenance'
label: 'Maintenance'
- title: '📖 Documentation'
label: 'Docs'
change-template: '- (#$NUMBER) $TITLE - Thanks to @$AUTHOR '
54 changes: 54 additions & 0 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build Main

on:
push:
branches: [ main ]
release:
types: [ published ]

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
PROJECT_NAME: BlazorTurnstile
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_FEED: https://api.nuget.org/v3/index.json
NUGET_KEY: ${{ secrets.NUGET_KEY }}

jobs:
build:
name: Build and pack
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3

- name: Restore
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore src/$PROJECT_NAME/$PROJECT_NAME.csproj

deploy:
needs: build
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3

- name: Create Release NuGet package
run: |
arrTag=(${GITHUB_REF//\// })
VERSION="${arrTag[2]}"
echo Version: $VERSION
VERSION="${VERSION/v}"
echo Clean Version: $VERSION
dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg src/$PROJECT_NAME/$PROJECT_NAME.csproj
- name: Push to NuGet Feed
run: dotnet nuget push ./nupkg/*.nupkg --source $NUGET_FEED --api-key $NUGET_KEY --skip-duplicate
24 changes: 24 additions & 0 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build PR

on:
pull_request:
branches: [ main ]

env:
PROJECT_NAME: BlazorTurnstile

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3

- name: Restore
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore src/$PROJECT_NAME/$PROJECT_NAME.csproj
20 changes: 20 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release Drafter

on:
push:
branches: [ main ]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write

runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion BlazorTurnstile.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CCBFA76A-6F1C-4707-8424-77DCD36BAE1E}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
.github\workflows\ci-main.yml = .github\workflows\ci-main.yml
.github\workflows\ci-pr.yml = .github\workflows\ci-pr.yml
global.json = global.json
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{0C00FBA8-0C21-43E5-AA2F-88754D087503}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWebAssembly", "samples\BlazorWebAssembly\BlazorWebAssembly.csproj", "{88185F43-375F-4D3B-B720-70C4C6487DD8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWebAssembly", "samples\BlazorWebAssembly\BlazorWebAssembly.csproj", "{88185F43-375F-4D3B-B720-70C4C6487DD8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "7.0.100",
"rollForward": "latestFeature"
}
}
8 changes: 5 additions & 3 deletions src/BlazorTurnstile/BlazorTurnstile.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
Expand All @@ -20,6 +20,10 @@
<PackageProjectUrl>https://github.com/MichelJansson/BlazorTurnstile</PackageProjectUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/MichelJansson/BlazorTurnstile</RepositoryUrl>

<!-- SourceLink settings -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>


Expand All @@ -29,13 +33,11 @@

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="6.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.12" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.8" />
</ItemGroup>

Expand Down

0 comments on commit d1b923d

Please sign in to comment.