Skip to content

Commit 37004cc

Browse files
Add release workflow
1 parent f28591f commit 37004cc

32 files changed

Lines changed: 211 additions & 6 deletions

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
id-token: write
12+
attestations: write
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
env:
18+
BUILD_PROJECT: src/vv.build/vv.build.csproj
19+
ARTIFACTS_PATH: src/vv.build/bin/artifacts/*
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Setup .NET
26+
uses: actions/setup-dotnet@v4
27+
with:
28+
dotnet-version: '10.0.102'
29+
30+
- name: Build vv.build and create release artifacts
31+
run: dotnet run --project ${{ env.BUILD_PROJECT }}
32+
33+
- name: Upload artifacts
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: release-artifacts
37+
path: ${{ env.ARTIFACTS_PATH }}
38+
if-no-files-found: error
39+
40+
- name: Attest build provenance
41+
uses: actions/attest-build-provenance@v3
42+
with:
43+
subject-path: ${{ env.ARTIFACTS_PATH }}
44+
45+
- name: Create GitHub Release
46+
uses: softprops/action-gh-release@v2
47+
if: startsWith(github.ref, 'refs/tags/')
48+
with:
49+
files: ${{ env.ARTIFACTS_PATH }}
50+
generate_release_notes: true
51+
prerelease: true
52+
draft: true
53+
make_latest: true

src/Directory.Build.props

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project>
2+
<PropertyGroup>
3+
<LangVersion>latest</LangVersion>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
6+
<OutputPath>bin</OutputPath>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>disable</Nullable>
9+
</PropertyGroup>
10+
</Project>

src/src.sln

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 18
4+
VisualStudioVersion = 18.3.11312.210 d18.3
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vv", "vv\vv.csproj", "{54B35286-309C-483A-AF2C-E144A39B1765}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vv.build", "vv.build\vv.build.csproj", "{F4100060-5C7B-473D-AA5C-28076DC3A96C}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Debug|x64 = Debug|x64
14+
Debug|x86 = Debug|x86
15+
Release|Any CPU = Release|Any CPU
16+
Release|x64 = Release|x64
17+
Release|x86 = Release|x86
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{54B35286-309C-483A-AF2C-E144A39B1765}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{54B35286-309C-483A-AF2C-E144A39B1765}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{54B35286-309C-483A-AF2C-E144A39B1765}.Debug|x64.ActiveCfg = Debug|Any CPU
23+
{54B35286-309C-483A-AF2C-E144A39B1765}.Debug|x64.Build.0 = Debug|Any CPU
24+
{54B35286-309C-483A-AF2C-E144A39B1765}.Debug|x86.ActiveCfg = Debug|Any CPU
25+
{54B35286-309C-483A-AF2C-E144A39B1765}.Debug|x86.Build.0 = Debug|Any CPU
26+
{54B35286-309C-483A-AF2C-E144A39B1765}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{54B35286-309C-483A-AF2C-E144A39B1765}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{54B35286-309C-483A-AF2C-E144A39B1765}.Release|x64.ActiveCfg = Release|Any CPU
29+
{54B35286-309C-483A-AF2C-E144A39B1765}.Release|x64.Build.0 = Release|Any CPU
30+
{54B35286-309C-483A-AF2C-E144A39B1765}.Release|x86.ActiveCfg = Release|Any CPU
31+
{54B35286-309C-483A-AF2C-E144A39B1765}.Release|x86.Build.0 = Release|Any CPU
32+
{F4100060-5C7B-473D-AA5C-28076DC3A96C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{F4100060-5C7B-473D-AA5C-28076DC3A96C}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{F4100060-5C7B-473D-AA5C-28076DC3A96C}.Debug|x64.ActiveCfg = Debug|Any CPU
35+
{F4100060-5C7B-473D-AA5C-28076DC3A96C}.Debug|x64.Build.0 = Debug|Any CPU
36+
{F4100060-5C7B-473D-AA5C-28076DC3A96C}.Debug|x86.ActiveCfg = Debug|Any CPU
37+
{F4100060-5C7B-473D-AA5C-28076DC3A96C}.Debug|x86.Build.0 = Debug|Any CPU
38+
{F4100060-5C7B-473D-AA5C-28076DC3A96C}.Release|Any CPU.ActiveCfg = Release|Any CPU
39+
{F4100060-5C7B-473D-AA5C-28076DC3A96C}.Release|Any CPU.Build.0 = Release|Any CPU
40+
{F4100060-5C7B-473D-AA5C-28076DC3A96C}.Release|x64.ActiveCfg = Release|Any CPU
41+
{F4100060-5C7B-473D-AA5C-28076DC3A96C}.Release|x64.Build.0 = Release|Any CPU
42+
{F4100060-5C7B-473D-AA5C-28076DC3A96C}.Release|x86.ActiveCfg = Release|Any CPU
43+
{F4100060-5C7B-473D-AA5C-28076DC3A96C}.Release|x86.Build.0 = Release|Any CPU
44+
EndGlobalSection
45+
GlobalSection(SolutionProperties) = preSolution
46+
HideSolutionNode = FALSE
47+
EndGlobalSection
48+
GlobalSection(ExtensibilityGlobals) = postSolution
49+
SolutionGuid = {A18FC44D-389F-408D-BDB4-7A404BF32340}
50+
EndGlobalSection
51+
EndGlobal

src/vv.build/Program.cs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using System.Diagnostics;
2+
using System.Formats.Tar;
3+
using System.IO.Compression;
4+
5+
(string runtime, string binaryExtension, Action<string, Func<string, Stream>> compressionMethod)[] targets =
6+
[
7+
("osx-arm64", string.Empty, CompressTar),
8+
("osx-x64", string.Empty, CompressTar),
9+
("linux-arm64", string.Empty, CompressTar),
10+
("linux-x64", string.Empty, CompressTar),
11+
("win-arm64", ".exe", CompressZip),
12+
("win-x64", ".exe", CompressZip),
13+
];
14+
15+
var vvDir = Path.Combine(new DirectoryInfo(AppContext.BaseDirectory).Parent.Parent.FullName, "vv");
16+
17+
var artifactsDir = PrepareOutputDirectory("artifacts");
18+
19+
List<string> artifactFiles = [];
20+
21+
foreach ((string runtime, string binaryExt, var compressionMethod) in targets)
22+
{
23+
var publishDirectory = Publish(runtime);
24+
var sourceFile = Path.Combine(publishDirectory, "vv" + binaryExt);
25+
26+
compressionMethod.Invoke(sourceFile, ext =>
27+
{
28+
var outputFile = Path.Combine(artifactsDir, $"vv-{runtime}") + ext;
29+
30+
Console.WriteLine($"Created {outputFile}");
31+
32+
artifactFiles.Add(outputFile);
33+
34+
return File.Create(outputFile);
35+
});
36+
Console.WriteLine();
37+
}
38+
39+
return 0;
40+
41+
string Publish(string runtime)
42+
{
43+
Run("dotnet", $"publish --runtime {runtime}", vvDir);
44+
return Path.Combine(vvDir, "bin", runtime, "publish");
45+
}
46+
47+
void CompressTar(string sourceFile, Func<string, Stream> streamFactory)
48+
{
49+
using var stream = streamFactory.Invoke(".tar.gz");
50+
using var gzipStream = new GZipStream(stream, CompressionMode.Compress);
51+
using var tarWriter = new TarWriter(gzipStream);
52+
tarWriter.WriteEntry(sourceFile, "vv");
53+
}
54+
55+
void CompressZip(string sourceFile, Func<string, Stream> streamFactory)
56+
{
57+
using var stream = streamFactory.Invoke(".zip");
58+
using var archive = new ZipArchive(stream, ZipArchiveMode.Create);
59+
archive.CreateEntryFromFile(sourceFile, "vv.exe", CompressionLevel.Optimal);
60+
}
61+
62+
string PrepareOutputDirectory(string name)
63+
{
64+
var artifactsDirectory = new DirectoryInfo(Path.Combine(AppContext.BaseDirectory, name));
65+
66+
if (!artifactsDirectory.Exists)
67+
artifactsDirectory.Create();
68+
else
69+
{
70+
foreach (FileInfo file in artifactsDirectory.EnumerateFiles())
71+
file.Delete();
72+
73+
foreach (DirectoryInfo subDir in artifactsDirectory.EnumerateDirectories())
74+
subDir.Delete(recursive: true);
75+
}
76+
77+
return artifactsDirectory.FullName;
78+
}
79+
80+
Process Run(string fileName, string arguments, string workingDirectory)
81+
{
82+
using var process = Process.Start(new ProcessStartInfo
83+
{
84+
FileName = fileName,
85+
Arguments = arguments,
86+
WorkingDirectory = workingDirectory,
87+
});
88+
process.WaitForExit();
89+
return process;
90+
}

src/vv.build/vv.build.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
</PropertyGroup>
6+
7+
</Project>

src/vv.slnx

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)