diff --git a/.github/workflows/publish_console.yml b/.github/workflows/publish_console.yml new file mode 100644 index 0000000..7210d03 --- /dev/null +++ b/.github/workflows/publish_console.yml @@ -0,0 +1,98 @@ +name: Publish Console +on: + workflow_dispatch: + push: + paths: + - src/StreamShorts.Console/** + - src/StreamShorts.Console.Tests/** + branches: + - main +jobs: + version: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.ACTIONS_PAT }} + - name: Setup .NET 9 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.x + - name: Install versionize + run: dotnet tool install --global Versionize + - name: Setup git + run: | + git config --local user.email "65925598+StevanFreeborn@users.noreply.github.com" + git config --local user.name "Stevan Freeborn" + - name: Run versionize + id: versionize + run: versionize -i --exit-insignificant-commits --workingDir ./src/StreamShorts.Console --commit-suffix "[skip ci]" + continue-on-error: true + - name: Upload changelog + if: steps.versionize.outcome == 'success' + uses: actions/upload-artifact@v4 + with: + name: change-log + path: src/StreamShorts.Console/CHANGELOG.md + - name: Push changes to GitHub + if: steps.versionize.outcome == 'success' + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.ACTIONS_PAT }} + branch: ${{ github.ref }} + tags: true + outputs: + is_new_version: ${{ steps.versionize.outcome == 'success' }} + publish: + needs: [version] + if: needs.version.outputs.is_new_version == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.ref }} + token: ${{ secrets.ACTIONS_PAT }} + - name: Setup .NET 9 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.x + - name: Build + run: dotnet build src + - name: Publish for mac-os + run: dotnet publish src/StreamShorts.Console/StreamsShorts.Console.csproj -c Release -r osx-x64 -o dist/mac-os + - name: Rename mac-os file + run: mv dist/mac-os/StreamShorts.Console dist/mac-os/StreamShorts.Console_macos + - name: Publish for linux-os + run: dotnet publish src/StreamShorts.Console/StreamShorts.Console.csproj -c Release -r linux-x64 -o dist/linux-os + - name: Rename linux-os file + run: mv dist/linux-os/StreamShorts.Console dist/linux-os/StreamShorts.Console_linux + - name: Publish for windows-os + run: dotnet publish src/StreamShorts.Console/StreamShorts.Console.csproj -c Release -r win-x64 -o dist/windows-os + - name: Rename windows-os file + run: mv dist/windows-os/StreamShorts.Console.exe dist/windows-os/StreamShorts.Console_windows.exe + - name: Get project version + uses: kzrnm/get-net-sdk-project-versions-action@v1 + id: get-version + with: + proj-path: src/StreamShorts.Console/StreamShorts.Console.csproj + - name: Download changlog + uses: actions/download-artifact@v4 + with: + name: change-log + path: src/StreamShorts.Console + - name: Create release + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.ACTIONS_PAT }} + name: StreamShorts.Console v${{ steps.get-version.outputs.version }} + tag_name: v${{ steps.get-version.outputs.version }} + draft: false + body_path: src/StreamShorts.Console/CHANGELOG.md + files: | + dist/mac-os/StreamShorts.Console_macos + dist/linux-os/StreamShorts.Console_linux + dist/windows-os/StreamShorts.Console_windows.exe \ No newline at end of file diff --git a/src/StreamShorts.Console/Commands/DefaultCommand.cs b/src/StreamShorts.Console/Commands/DefaultCommand.cs index f62528a..f8f0e58 100644 --- a/src/StreamShorts.Console/Commands/DefaultCommand.cs +++ b/src/StreamShorts.Console/Commands/DefaultCommand.cs @@ -88,15 +88,24 @@ internal sealed class DefaultCommand( await foreach (var segment in _transcriber.TranscribeAsync(audioStream)) { transcriptionSegments.Add(segment); - var segmentTimeText = $"[{segment.StartTime:hh\\:mm\\:ss} - {segment.EndTime:hh\\:mm\\:ss}]"; + var segmentTimeText = $@"[{segment.StartTime:hh\:mm\:ss} - {segment.EndTime:hh\:mm\:ss}]"; ctx.Status($"Transcribed segment {segmentTimeText.EscapeMarkup()}"); } }); _console.MarkupLine($"[blue]Transcription completed[/] [green]successfully![/]"); + var now = _timeProvider.GetUtcNow(); + var inputFileName = _fileSystem.Path.GetFileNameWithoutExtension(settings.Stream); + var outputDirectoryPath = _fileSystem.Path.Combine( + AppContext.BaseDirectory, + $"{now:yyyy_MM_dd_HH_mm_ss}_{inputFileName}" + ); + + _fileSystem.Directory.CreateDirectory(outputDirectoryPath); + await _fileSystem.File.WriteAllTextAsync( - _fileSystem.Path.Combine(AppContext.BaseDirectory, "transcription.txt"), + _fileSystem.Path.Combine(outputDirectoryPath, "transcription.txt"), string.Join(Environment.NewLine, transcriptionSegments) ); @@ -117,15 +126,6 @@ internal sealed class DefaultCommand( _console.MarkupLine($"[blue]Transcript analysis completed[/] [green]successfully![/]"); - var now = _timeProvider.GetUtcNow(); - var inputFileName = _fileSystem.Path.GetFileNameWithoutExtension(settings.Stream); - var outputDirectoryPath = _fileSystem.Path.Combine( - AppContext.BaseDirectory, - $"{now:yyyy_MM_dd_HH_mm_ss}_{inputFileName}" - ); - - _fileSystem.Directory.CreateDirectory(outputDirectoryPath); - await _fileSystem.File.WriteAllTextAsync( _fileSystem.Path.Combine(outputDirectoryPath, "analysis.json"), JsonSerializer.Serialize(analysis, _jsonSerializerOptions)