Skip to content

Commit

Permalink
Add publish github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Romanx committed Nov 17, 2022
1 parent 3c0474a commit cee90a2
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Run the build script
uses: cake-build/cake-action@v1
with:
target: Github
target: Pack
- name: Upload a Build Artifact
uses: actions/[email protected]
if: runner.os == 'Windows'
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish

on:
push:
branches:
- main

jobs:
release:
name: Release
if: "!contains(github.event.head_commit.message, 'skip-ci')"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x

- name: Nerdbank.GitVersioning
uses: dotnet/[email protected]
with:
setAllVars: true

- name: Build
uses: cake-build/cake-action@v1
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
with:
target: Github
19 changes: 0 additions & 19 deletions appveyor.yml

This file was deleted.

24 changes: 21 additions & 3 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,29 @@ Task("Pack")
DotNetPack("./src/Cake.Coverlet/Cake.Coverlet.csproj", data.PackSettings);
});

Task("Appveyor")
.IsDependentOn("Pack");
Task("Publish")
.IsDependentOn("Pack")
.Does<MyBuildData>((ICakeContext context, MyBuildData data) =>
{
// Make sure that there is an API key.
var apiKey = context.EnvironmentVariable("NUGET_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) {
throw new CakeException("No NuGet API key specified.");
}

// Publish all projects
foreach(var file in GetFiles($"./{data.ArtifactsDirectory}/*.nupkg"))
{
context.Information("Publishing {0}...", file.GetFilename().FullPath);
context.NuGetPush(file, new NuGetPushSettings {
ApiKey = apiKey,
Source = "https://api.nuget.org/v3/index.json"
});
}
});

Task("Github")
.IsDependentOn("Pack");
.IsDependentOn("Publish");

Task("Default")
.IsDependentOn("Pack");
Expand Down

0 comments on commit cee90a2

Please sign in to comment.