Skip to content

Commit

Permalink
Remove gh cli dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
SKProCH committed Jan 28, 2024
1 parent 6419d21 commit 66f2654
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
- name: 'Run: PublishNugetPackages'
run: ./build.cmd PublishNugetPackages
- name: 'Run: PublishNugetPackages, AppendNightlyVersionIfNeeded'
run: ./build.cmd PublishNugetPackages AppendNightlyVersionIfNeeded
env:
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
- name: 'Publish: nuget'
Expand Down
60 changes: 30 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,37 @@
name: release

on:
push:
tags:
- '*'
push:
tags:
- '*'

permissions:
contents: write
contents: write

jobs:
ubuntu-latest:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
- name: 'Run: PublishRelease'
run: ./build.cmd PublishRelease
env:
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
- name: 'Publish: demo'
uses: actions/upload-artifact@v3
with:
name: demo
path: artifacts/demo
- name: 'Publish: nuget'
uses: actions/upload-artifact@v3
with:
name: nuget
path: artifacts/nuget
ubuntu-latest:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
- name: 'Run: PublishRelease'
run: ./build.cmd PublishRelease
env:
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
- name: 'Publish: demo'
uses: actions/upload-artifact@v3
with:
name: demo
path: artifacts/demo
- name: 'Publish: nuget'
uses: actions/upload-artifact@v3
with:
name: nuget
path: artifacts/nuget
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageVersion Include="ShowMeTheXaml.Avalonia.AvaloniaEdit" Version="$(ShowMeTheXamlVersion)" />
<PackageVersion Include="ShowMeTheXaml.Avalonia.Generator" Version="$(ShowMeTheXamlVersion)" />
<!--For _build-->
<PackageVersion Include="Nuke.Common" Version="7.0.2" />
<PackageVersion Include="Nuke.Common" Version="8.0.0" />
<PackageVersion Include="NuGet.Protocol" Version="6.7.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
</ItemGroup>
Expand Down
18 changes: 12 additions & 6 deletions build/BuildOnPipelines.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
Expand All @@ -14,8 +15,6 @@
using Octokit.Internal;
using Serilog;
partial class Build {
[LocalPath("gh")] readonly Tool GHActions = null!;

Target FetchNuget => _ => _
.Unlisted()
.OnlyWhenDynamic(() => Parameters.ShouldPublishNugetPackages)
Expand Down Expand Up @@ -75,18 +74,25 @@ partial class Build {
.Triggers(PublishNugetPackages)
.Executes(async () => {
var releaseVersion = NuGetVersion.Parse(GitHubActions.Instance.RefName.TrimStart('v'));
var tagName = $"v{releaseVersion}";
Parameters.Version = releaseVersion.ToString();
GHActions.Invoke($"release delete --yes {releaseVersion}");
var (owner, name) = (Repository.GetGitHubOwner(), Repository.GetGitHubName());
var credentials = new Credentials(GitHubActions.Instance.Token);
GitHubTasks.GitHubClient = new GitHubClient(
new ProductHeaderValue(nameof(NukeBuild)),
new InMemoryCredentialStore(credentials));
var (owner, name) = (Repository.GetGitHubOwner(), Repository.GetGitHubName());
try {
var oldRelease = await GitHubTasks.GitHubClient.Repository.Release.Get(owner, name, tagName);
await GitHubTasks.GitHubClient.Repository.Release.Delete(owner, name, oldRelease.Id);
}
catch (Exception _) {
// ignored
}
var newRelease = new NewRelease(releaseVersion.ToString()) {
Name = $"v{releaseVersion}",
Name = tagName,
GenerateReleaseNotes = true
};
var release = await GitHubTasks.GitHubClient.Repository.Release.Create(owner, name, newRelease);
Expand Down

0 comments on commit 66f2654

Please sign in to comment.