Skip to content

Commit 3586a39

Browse files
authored
Merge pull request #3 from ConvertAPI/release-automation
Release automation and documentation
2 parents 77d5743 + 9b03dc6 commit 3586a39

File tree

8 files changed

+92
-33
lines changed

8 files changed

+92
-33
lines changed

.github/workflows/release.yml

Lines changed: 56 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,80 @@
1-
name: Build and Package
1+
name: Build and Release
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version tag (e.g. v1.0.0)'
8+
required: true
9+
default: 'v1.0.0'
510
push:
611
tags:
712
- 'v*'
813

914
jobs:
10-
build:
15+
create_release_job:
1116
runs-on: ubuntu-latest
12-
timeout-minutes: 30
13-
env:
14-
GITHUB_ACTIONS: true
15-
PUBLISH_DIR: bin/Release/net8.0/win-x64/publish
16-
OUTPUT_ZIP: output/convertApi-cli.zip
17-
17+
outputs:
18+
release_upload_url: ${{ steps.create_release.outputs.upload_url }}
1819
steps:
19-
# Checkout the code
2020
- name: Checkout
2121
uses: actions/checkout@v4
22-
23-
# Setup .NET SDK
22+
2423
- name: Setup .NET SDK
2524
uses: actions/setup-dotnet@v4
2625
with:
2726
dotnet-version: '8.x'
2827

29-
# Run tests
3028
- name: Test
3129
run: dotnet test ConvertApi.Cli.Tests
3230

33-
# Build the project
34-
- name: Build
35-
run: dotnet publish -c Release -r win-x64 --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
31+
- name: Create Release
32+
id: create_release
33+
uses: actions/create-release@v1
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
with:
37+
tag_name: ${{ github.event.inputs.version || github.ref_name }}
38+
release_name: ${{ github.event.inputs.version || github.ref_name }}
39+
draft: false
40+
prerelease: false
41+
42+
build_and_upload:
43+
runs-on: ubuntu-latest
44+
needs: create_release_job
45+
strategy:
46+
matrix:
47+
runtime: [ "win-x64", "linux-x64", "linux-arm64", "osx-x64", "osx-arm64" ]
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v4
51+
52+
- name: Setup .NET SDK
53+
uses: actions/setup-dotnet@v4
54+
with:
55+
dotnet-version: '8.x'
56+
57+
- name: Publish for ${{ matrix.runtime }}
58+
run: |
59+
dotnet publish ConvertApi.Cli/ConvertApi.Cli.csproj \
60+
-c Release \
61+
-r ${{ matrix.runtime }} \
62+
--self-contained true \
63+
/p:PublishSingleFile=true \
64+
/p:IncludeNativeLibrariesForSelfExtract=true \
65+
/p:DebugType=none \
66+
/p:DebugSymbols=false
3667
37-
# Create a zip package
38-
- name: Create ZIP package
68+
- name: Zip package
3969
run: |
40-
mkdir -p output
41-
zip -j ${{ env.OUTPUT_ZIP }} ${{ env.PUBLISH_DIR }}/*
70+
zip -j convertApi-cli-${{ matrix.runtime }}.zip ConvertApi.Cli/bin/Release/net8.0/${{ matrix.runtime }}/publish/*
4271
43-
# Upload the artifact
44-
- name: Upload artifact
45-
uses: actions/upload-artifact@v3
72+
- name: Upload Release Asset
73+
uses: actions/upload-release-asset@v1
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4676
with:
47-
name: convertApi-cli
48-
path: ${{ env.OUTPUT_ZIP }}
77+
upload_url: ${{ needs.create_release_job.outputs.release_upload_url }}
78+
asset_path: ./convertApi-cli-${{ matrix.runtime }}.zip
79+
asset_name: convertApi-cli-${{ matrix.runtime }}.zip
80+
asset_content_type: application/zip
Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
using System.Diagnostics;
22

3-
namespace ConvertApi.Cli.Test;
3+
namespace ConvertApi.Cli.Tests;
44

55
[TestFixture]
66
public class CliTests
77
{
8-
private static readonly string CliExecutablePath = Path.Combine(Directory.GetCurrentDirectory(), "convertapi-cli.exe");
98
private const string ApiToken = "token_ST4z2qhE"; // Provide your API token
109
private static readonly string TestOutputDir = Path.Combine(Directory.GetCurrentDirectory(), "test_output");
1110

@@ -67,14 +66,15 @@ public void TestProtectPdfWithPassword()
6766

6867
private Process RunCli(string arguments)
6968
{
70-
if (!File.Exists(CliExecutablePath))
71-
throw new FileNotFoundException($"CLI executable not found at {CliExecutablePath}");
69+
var cliExecutablePath = GetCliExecutablePath();
70+
if (!File.Exists(cliExecutablePath))
71+
throw new FileNotFoundException($"CLI executable not found at {cliExecutablePath}");
7272

7373
var process = new Process
7474
{
7575
StartInfo = new ProcessStartInfo
7676
{
77-
FileName = CliExecutablePath,
77+
FileName = cliExecutablePath,
7878
Arguments = arguments,
7979
UseShellExecute = true, // Run in a normal console environment, because otherwise process hangs because of readline in program.cs
8080
CreateNoWindow = true
@@ -96,4 +96,25 @@ private Process RunCli(string arguments)
9696

9797
return process;
9898
}
99+
100+
private string GetCliExecutablePath()
101+
{
102+
var executableName = Path.Combine(Directory.GetCurrentDirectory(), "convertapi-cli");
103+
if (OperatingSystem.IsWindows())
104+
{
105+
executableName += ".exe";
106+
}
107+
108+
var path = Path.Combine(
109+
AppContext.BaseDirectory,
110+
executableName
111+
);
112+
113+
if (!File.Exists(path))
114+
{
115+
throw new FileNotFoundException($"CLI executable not found at {path}");
116+
}
117+
118+
return path;
119+
}
99120
}

ConvertApi.Cli.Test/ContentDispositionHeaderValueTests.cs renamed to ConvertApi.Cli.Tests/ContentDispositionHeaderValueTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Microsoft.Net.Http.Headers;
22

3-
namespace ConvertApi.Cli.Test;
3+
namespace ConvertApi.Cli.Tests;
44

55
[TestFixture]
66
public class ContentDispositionHeaderValueTests

ConvertApi.Cli.Test/ConvertApi.Cli.Test.csproj renamed to ConvertApi.Cli.Tests/ConvertApi.Cli.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
<IsPackable>false</IsPackable>
99
<IsTestProject>true</IsTestProject>
10+
<RootNamespace>ConvertApi.Cli.Tests</RootNamespace>
1011
</PropertyGroup>
1112

1213
<ItemGroup>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace ConvertApi.Cli.Test;
1+
namespace ConvertApi.Cli.Tests;
22

33
[TestFixture]
44
public class DirectCallTests

ConvertApi.Cli.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvertApi.Cli", "ConvertApi.Cli\ConvertApi.Cli.csproj", "{006B1430-754B-46E0-BF11-2B9A759E6611}"
44
EndProject
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvertApi.Cli.Test", "ConvertApi.Cli.Test\ConvertApi.Cli.Test.csproj", "{B14DD22A-6CF3-4515-BFCB-7A7FDE5FD036}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvertApi.Cli.Tests", "ConvertApi.Cli.Tests\ConvertApi.Cli.Tests.csproj", "{B14DD22A-6CF3-4515-BFCB-7A7FDE5FD036}"
66
EndProject
77
Global
88
GlobalSection(SolutionConfigurationPlatforms) = preSolution

ConvertApi.Cli/ConvertApi.Cli.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>-->
1313
<AssemblyName>convertapi-cli</AssemblyName>
1414
<RootNamespace>ConvertApi.Cli</RootNamespace>
15+
<Authors>ConvertAPI</Authors>
16+
<Description>convertapi-cli</Description>
17+
<Copyright>ConvertAPI</Copyright>
18+
<Company>ConvertAPI</Company>
19+
<Version>0.0.1</Version>
1520
</PropertyGroup>
1621

1722
<ItemGroup>

ConvertApi.Cli/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static void DisplayHelp()
7979
Console.WriteLine("ConvertAPI provides a simple way to convert files between different formats, merge, and apply transformations using its powerful API.");
8080
Console.WriteLine();
8181
Console.WriteLine("Usage:");
82-
Console.WriteLine(" convertapi-cli.exe <api-token> <output-file> <input-files...> [from-format] [to-format] [key1=value1 key2=value2 ...]");
82+
Console.WriteLine(" convertapi-cli.exe <api-token> <output-directory> <input-files...> [from-format] [to-format] [key1=value1 key2=value2 ...]");
8383
Console.WriteLine();
8484
Console.WriteLine("Examples:");
8585
Console.WriteLine(" Convert a single PDF to DOCX:");

0 commit comments

Comments
 (0)