mirror of
https://github.com/g3rv4/GetMoarFediverse.git
synced 2024-11-21 15:13:08 +01:00
Make it trimmable
This commit is contained in:
parent
41821ea23a
commit
e71904e1a3
30
.github/workflows/build copy.yml.original
vendored
Normal file
30
.github/workflows/build copy.yml.original
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: build
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # get entire git tree, required for nerdbank gitversioning
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push the Docker image
|
||||
shell: pwsh
|
||||
run: |
|
||||
Push-Location src
|
||||
$version = (nbgv get-version -f json | ConvertFrom-Json).SimpleVersion
|
||||
Write-Host "Version $version"
|
||||
Pop-Location
|
||||
|
||||
docker build . --tag ghcr.io/g3rv4/getmoarfediverse:latest --tag "ghcr.io/g3rv4/getmoarfediverse:$version"
|
||||
docker push ghcr.io/g3rv4/getmoarfediverse:latest
|
||||
docker push "ghcr.io/g3rv4/getmoarfediverse:$version"
|
96
.github/workflows/create-release.yml
vendored
96
.github/workflows/create-release.yml
vendored
@ -4,8 +4,11 @@ on:
|
||||
tags:
|
||||
- v*
|
||||
jobs:
|
||||
create-windows-artifact:
|
||||
create-artifact:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
runtime: [ win-x64, linux-x64 ]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@ -13,38 +16,59 @@ jobs:
|
||||
shell: pwsh
|
||||
run: |
|
||||
mkdir output
|
||||
mkdir artifact
|
||||
$outputPath = Join-Path (Pwd) output
|
||||
$srcPath = Join-Path (Pwd) src
|
||||
docker run -v "$($outputPath):/var/output" -v "$($srcPath):/var/src" mcr.microsoft.com/dotnet/sdk:6.0.403-alpine3.16 dotnet publish -r win-x64 --self-contained -p:PublishTrimmed=true -c Release /var/src/GetMoarFediverse.csproj -o /var/output
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: GetMoarFediverse.exe
|
||||
path: output/GetMoarFediverse.exe
|
||||
|
||||
create-linux-artifact:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Build Windows artifact
|
||||
shell: pwsh
|
||||
run: |
|
||||
mkdir output
|
||||
$outputPath = Join-Path (Pwd) output
|
||||
$srcPath = Join-Path (Pwd) src
|
||||
docker run -v "$($outputPath):/var/output" -v "$($srcPath):/var/src" mcr.microsoft.com/dotnet/sdk:6.0.403-alpine3.16 dotnet publish -r linux-x64 --self-contained -p:PublishTrimmed=true -c Release /var/src/GetMoarFediverse.csproj -o /var/output
|
||||
$uid = sh -c 'id -u'
|
||||
$gid = sh -c 'id -g'
|
||||
|
||||
docker run -v "$($outputPath):/var/output" -v "$($srcPath):/var/src" mcr.microsoft.com/dotnet/sdk:6.0.403-alpine3.16 ash -c "dotnet publish -r ${{ matrix.runtime }} --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -c Release /var/src/GetMoarFediverse.csproj -o /var/output && chown -R $($uid):$($gid) /var/output"
|
||||
|
||||
$tag = '${{ github.event.ref }}'.Replace('refs/tags/', '')
|
||||
|
||||
Push-Location output
|
||||
chmod +r *
|
||||
chmod +x GetMoarFediverse || true
|
||||
|
||||
if ('${{ matrix.runtime }}'.StartsWith('win-')) {
|
||||
Compress-Archive -Path * -DestinationPath "../artifact/GetMoarFediverse_$($tag)_${{ matrix.runtime }}.zip"
|
||||
} else {
|
||||
tar -czf ../artifact/GetMoarFediverse_$($tag)_${{ matrix.runtime }}.tgz *
|
||||
}
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: GetMoarFediverse
|
||||
path: output/GetMoarFediverse
|
||||
name: ${{ matrix.runtime }}
|
||||
path: artifact/*
|
||||
|
||||
create-release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ create-artifact ]
|
||||
steps:
|
||||
- uses: actions/download-artifact@master
|
||||
with:
|
||||
name: win-x64
|
||||
path: artifacts/win-x64
|
||||
- uses: actions/download-artifact@master
|
||||
with:
|
||||
name: linux-x64
|
||||
path: artifacts/linux-x64
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
|
||||
with:
|
||||
generate_release_notes: true
|
||||
fail_on_unmatched_files: true
|
||||
files: |
|
||||
artifacts/win-x64/*.zip
|
||||
artifacts/linux-x64/*.tgz
|
||||
|
||||
create-docker-image:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ create-release ]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # get entire git tree, required for nerdbank gitversioning
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
@ -54,32 +78,8 @@ jobs:
|
||||
- name: Build and push the Docker image
|
||||
shell: pwsh
|
||||
run: |
|
||||
Push-Location src
|
||||
$version = (nbgv get-version -f json | ConvertFrom-Json).SimpleVersion
|
||||
Write-Host "Version $version"
|
||||
Pop-Location
|
||||
$version = '${{ github.event.ref }}'.Replace('refs/tags/', '').Replace('v', '')
|
||||
|
||||
docker build . --tag ghcr.io/g3rv4/getmoarfediverse:latest --tag "ghcr.io/g3rv4/getmoarfediverse:$version"
|
||||
docker push ghcr.io/g3rv4/getmoarfediverse:latest
|
||||
docker push "ghcr.io/g3rv4/getmoarfediverse:$version"
|
||||
|
||||
create-release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ create-windows-artifact, create-linux-artifact ]
|
||||
steps:
|
||||
- uses: actions/download-artifact@master
|
||||
with:
|
||||
name: GetMoarFediverse
|
||||
path: artifacts/GetMoarFediverse
|
||||
- uses: actions/download-artifact@master
|
||||
with:
|
||||
name: GetMoarFediverse.exe
|
||||
path: artifacts/GetMoarFediverse.exe
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
|
||||
with:
|
||||
generate_release_notes: true
|
||||
fail_on_unmatched_files: true
|
||||
files: |
|
||||
artifacts/GetMoarFediverse
|
||||
artifacts/GetMoarFediverse.exe
|
||||
docker push "ghcr.io/g3rv4/getmoarfediverse:$version"
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -6,4 +6,5 @@ obj/
|
||||
launchSettings.json
|
||||
.idea/
|
||||
.DS_Store
|
||||
data/
|
||||
data/
|
||||
output/
|
@ -1,5 +1,5 @@
|
||||
using System.Collections.Immutable;
|
||||
using Jil;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace GetMoarFediverse;
|
||||
|
||||
@ -30,8 +30,8 @@ public class Config
|
||||
return;
|
||||
}
|
||||
|
||||
var data = JSON.Deserialize<ConfigData>(File.ReadAllText(path));
|
||||
|
||||
var data = JsonSerializer.Deserialize<ConfigData>(File.ReadAllText(path), JsonContext.Default.ConfigData);
|
||||
|
||||
var importedPath = Path.Join(Path.GetDirectoryName(path), "imported.txt");
|
||||
var apiKey = string.IsNullOrEmpty(data.FakeRelayApiKey)
|
||||
? Environment.GetEnvironmentVariable("FAKERELAY_APIKEY")
|
||||
@ -40,7 +40,7 @@ public class Config
|
||||
Instance = new Config(importedPath, data.FakeRelayUrl, apiKey, data.Tags.ToImmutableArray(), data.ImmutableSites);
|
||||
}
|
||||
|
||||
private class ConfigData
|
||||
public class ConfigData
|
||||
{
|
||||
public string FakeRelayUrl { get; set; }
|
||||
public string? FakeRelayApiKey { get; set; }
|
||||
@ -55,8 +55,8 @@ public class Config
|
||||
|
||||
public class InternalSiteData
|
||||
{
|
||||
public string Host { get; private set; }
|
||||
public string[]? SiteSpecificTags { get; private set; }
|
||||
public string Host { get; set; }
|
||||
public string[]? SiteSpecificTags { get; set; }
|
||||
|
||||
public SiteData ToSiteData() =>
|
||||
new()
|
||||
|
@ -7,8 +7,4 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Jil" Version="2.17.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
14
src/JsonContexts.cs
Normal file
14
src/JsonContexts.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace GetMoarFediverse;
|
||||
|
||||
[JsonSerializable(typeof(Config.ConfigData))]
|
||||
internal partial class JsonContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
|
||||
[JsonSerializable(typeof(TagResponse))]
|
||||
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
|
||||
internal partial class CamelCaseJsonContext : JsonSerializerContext
|
||||
{
|
||||
}
|
@ -1,8 +1,13 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text.Json;
|
||||
using GetMoarFediverse;
|
||||
using Jil;
|
||||
|
||||
Config.Init(Environment.GetEnvironmentVariable("CONFIG_PATH"));
|
||||
var configPath = Environment.GetEnvironmentVariable("CONFIG_PATH");
|
||||
if (args.Length == 1){
|
||||
configPath = args[0];
|
||||
}
|
||||
|
||||
Config.Init(configPath);
|
||||
|
||||
var client = new HttpClient();
|
||||
var authClient = new HttpClient
|
||||
@ -49,7 +54,7 @@ await Parallel.ForEachAsync(sitesTags, parallelOptions, async (st, _) =>
|
||||
}
|
||||
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
var data = JSON.Deserialize<TagResponse>(json, Options.CamelCase);
|
||||
var data = JsonSerializer.Deserialize<TagResponse>(json, CamelCaseJsonContext.Default.TagResponse);
|
||||
|
||||
foreach (var statusLink in data.OrderedItems.Where(i=>!imported.Contains(i)))
|
||||
{
|
||||
@ -87,5 +92,5 @@ File.WriteAllLines(importedPath, importedList);
|
||||
|
||||
public class TagResponse
|
||||
{
|
||||
public string[] OrderedItems { get; private set; }
|
||||
public string[] OrderedItems { get; set; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user