Skip to content

Commit

Permalink
post release action
Browse files Browse the repository at this point in the history
  • Loading branch information
pierotibou committed Jan 30, 2024
1 parent af38e3b commit 564f1cd
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/auto_on_rel_published.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Auto on rel published

on:
release:
types: [published]

jobs:
trigger_aas_release:
runs-on: windows-latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

steps:
- name: Checkout
uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.101'

- name: "Get version following release"
id: versions
run: ./tracer/build.sh OutputCurrentVersionToGitHub

- name: "Close previous milestone"
run: .\tracer\build.ps1 CloseMilestone
env:
Version: ${{steps.versions.outputs.version}}

34 changes: 34 additions & 0 deletions github-actions-helpers/Build.Release.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,40 @@ partial class Build
Console.WriteLine("Changelog updated");
});

Target CloseMilestone => _ => _
.Unlisted()
.Requires(() => GitHubToken)
.Requires(() => Version)
.Executes(async() =>
{
var client = GetGitHubClient();

var milestone = await GetMilestone(client, Version);
if (milestone is null)
{
Console.WriteLine($"Milestone {Version} not found. Doing nothing");
return;
}

Console.WriteLine($"Closing {milestone.Title}");

try
{
await client.Issue.Milestone.Update(
owner: GitHubRepositoryOwner,
name: GitHubRepositoryName,
number: milestone.Number,
new MilestoneUpdate { State = ItemState.Closed });
}
catch (ApiValidationException ex)
{
Console.WriteLine($"Unable to close {milestone.Title}. Exception: {ex}");
return; // shouldn't be blocking
}

Console.WriteLine($"Milestone closed");
});

private async Task<Milestone> GetOrCreateCurrentMilestone(GitHubClient gitHubClient)
{
var milestoneName = Version;
Expand Down

0 comments on commit 564f1cd

Please sign in to comment.