Skip to content

Commit

Permalink
CI improvements (#30)
Browse files Browse the repository at this point in the history
* Add LibXboxOne.Common.AppVersion to get InformationalVersion of ExecutingAssembly

* CI flow

* Change artifact name
  • Loading branch information
tuxuser authored Sep 11, 2020
1 parent ae3ba75 commit bedc69d
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 49 deletions.
87 changes: 78 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,97 @@ jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
rid: ['osx.10.12-x64', 'linux-x64', 'win-x64', 'win-x86']

steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.2
with:
versionSpec: '5.2.x'
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v0.9.2
- name: Show enumerated Git version strings
run: |
echo "Major: ${{ steps.gitversion.outputs.major }}"
echo "Minor: ${{ steps.gitversion.outputs.minor }}"
echo "Patch: ${{ steps.gitversion.outputs.patch }}"
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}"
echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}"
echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}"
echo "PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}"
echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}"
echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}"
echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}"
echo "FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}"
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
echo "LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}"
echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}"
echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}"
echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}"
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}"
echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}"
echo "BranchName: ${{ steps.gitversion.outputs.branchName }}"
echo "Sha: ${{ steps.gitversion.outputs.sha }}"
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}"
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}"
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}"
echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}"
echo "VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}"
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}"
echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}"
echo "CommitDate: ${{ steps.gitversion.outputs.commitDate }}"
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
run: dotnet build --configuration Release --no-restore /p:AssemblyVersion=${{ steps.gitversion.outputs.assemblySemFileVer }} /p:FileVersion=${{ steps.gitversion.outputs.assemblySemFileVer }} /p:InformationalVersion=${{ steps.gitversion.outputs.SemVer }}-${{ steps.gitversion.outputs.ShortSha }}
- name: Test
run: dotnet test --no-restore --verbosity normal
run: dotnet test --no-restore --verbosity normal /p:AssemblyVersion=${{ steps.gitversion.outputs.assemblySemFileVer }} /p:FileVersion=${{ steps.gitversion.outputs.assemblySemFileVer }} /p:InformationalVersion=${{ steps.gitversion.outputs.SemVer }}-${{ steps.gitversion.outputs.ShortSha }}
- name: Create publishable builds
run: ./build_release.sh ${{ matrix.rid }} ci
run: dotnet publish --no-restore --configuration Release /p:AssemblyVersion=${{ steps.gitversion.outputs.assemblySemFileVer }} /p:FileVersion=${{ steps.gitversion.outputs.assemblySemFileVer }} /p:InformationalVersion=${{ steps.gitversion.outputs.SemVer }}-${{ steps.gitversion.outputs.ShortSha }}
- name: Copy files
run: |
mkdir ./release
find ./DurangoKeyExtractor/bin/Release/netcoreapp3.1/publish ./XVDTool/bin/Release/netcoreapp3.1/publish ./XBFSTool/bin/Release/netcoreapp3.1/publish -mindepth 1 -type f -printf '%p %f\n' | sort -t ' ' -k 2,2 | uniq -f 1|cut -d' ' -f1 | xargs -I '{}' cp '{}' ./release/
cp ./README.md ./xvd_info.md ./CHANGELOG.md ./release/
- name: List current directory
run: find .
- name: Generate zip for release
run: |
zip -j XVDTool-${{ steps.gitversion.outputs.assemblySemVer }}.zip ./release/*
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: XVDTool-${{ matrix.rid }}-ci.zip
path: 'release/XVDTool-${{ matrix.rid }}*.zip'
name: XVDTool-${{ steps.gitversion.outputs.SemVer }}-${{ steps.gitversion.outputs.ShortSha }}.zip
path: ./release/
- name: Create release (on tag)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./XVDTool-${{ steps.gitversion.outputs.assemblySemVer }}.zip
asset_name: XVDTool-${{ steps.gitversion.outputs.assemblySemVer }}.zip
asset_content_type: application/zip
4 changes: 3 additions & 1 deletion DurangoKeyExtractor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace DurangoKeyExtractor
{
class Program
{
static string AppVersion => LibXboxOne.Common.AppVersion;

static void Main(string[] args)
{
var printHelp = false;
Expand Down Expand Up @@ -36,7 +38,7 @@ static void Main(string[] args)
Console.WriteLine();
}

Console.WriteLine("durangokeyextractor 0.1: Durango key extractor");
Console.WriteLine($"DurangoKeyExtractor {AppVersion}: Durango key extractor");
if (printHelp || extraArgs.Count <= 0)
{
Console.WriteLine("Usage : durangokeyextractor.exe [parameters] [filepath]");
Expand Down
13 changes: 13 additions & 0 deletions LibXboxOne/Common.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Reflection;

namespace LibXboxOne
{
public static class Common
{
public static string AppVersion =>
Assembly.GetExecutingAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion;
}
}
4 changes: 3 additions & 1 deletion XBFSTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace XBFSTool
{
class Program
{
static string AppVersion => LibXboxOne.Common.AppVersion;

static void Main(string[] args)
{
var printHelp = false;
Expand Down Expand Up @@ -39,7 +41,7 @@ static void Main(string[] args)
Console.WriteLine();
}

Console.WriteLine("xbfstool 0.1: Xbox boot filesystem tool");
Console.WriteLine($"XBFSTool {AppVersion}: Xbox boot filesystem tool");
Console.WriteLine();
if (printHelp || extraArgs.Count <= 0)
{
Expand Down
3 changes: 2 additions & 1 deletion XVDTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace XVDTool
{
class Program
{
static string AppVersion => LibXboxOne.Common.AppVersion;
static readonly string AppName = "xvdtool";
static void EnsureConfigDirectoryStructure(string basePath)
{
Expand Down Expand Up @@ -131,7 +132,7 @@ static void Main(string[] args)
return;
}

Console.WriteLine("xvdtool 0.5: XVD file manipulator");
Console.WriteLine($"XVDTool {AppVersion}: XVD file manipulator");

if (printHelp || (String.IsNullOrEmpty(fileList) && String.IsNullOrEmpty(folder) && !listKeys && extraArgs.Count <= 0))
{
Expand Down
37 changes: 0 additions & 37 deletions build_release.sh

This file was deleted.

0 comments on commit bedc69d

Please sign in to comment.