mirror of
https://github.com/g3rv4/GetMoarFediverse.git
synced 2024-11-24 16:43:17 +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"
|
94
.github/workflows/create-release.yml
vendored
94
.github/workflows/create-release.yml
vendored
@ -4,8 +4,11 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- v*
|
- v*
|
||||||
jobs:
|
jobs:
|
||||||
create-windows-artifact:
|
create-artifact:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
runtime: [ win-x64, linux-x64 ]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@ -13,38 +16,59 @@ jobs:
|
|||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
mkdir output
|
mkdir output
|
||||||
|
mkdir artifact
|
||||||
$outputPath = Join-Path (Pwd) output
|
$outputPath = Join-Path (Pwd) output
|
||||||
$srcPath = Join-Path (Pwd) src
|
$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:
|
$uid = sh -c 'id -u'
|
||||||
runs-on: ubuntu-latest
|
$gid = sh -c 'id -g'
|
||||||
steps:
|
|
||||||
- name: Checkout
|
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"
|
||||||
uses: actions/checkout@v3
|
|
||||||
- name: Build Windows artifact
|
$tag = '${{ github.event.ref }}'.Replace('refs/tags/', '')
|
||||||
shell: pwsh
|
|
||||||
run: |
|
Push-Location output
|
||||||
mkdir output
|
chmod +r *
|
||||||
$outputPath = Join-Path (Pwd) output
|
chmod +x GetMoarFediverse || true
|
||||||
$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
|
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
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: GetMoarFediverse
|
name: ${{ matrix.runtime }}
|
||||||
path: output/GetMoarFediverse
|
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:
|
create-docker-image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ create-release ]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
|
||||||
fetch-depth: 0 # get entire git tree, required for nerdbank gitversioning
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
@ -54,32 +78,8 @@ jobs:
|
|||||||
- name: Build and push the Docker image
|
- name: Build and push the Docker image
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
Push-Location src
|
$version = '${{ github.event.ref }}'.Replace('refs/tags/', '').Replace('v', '')
|
||||||
$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 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:latest
|
||||||
docker push "ghcr.io/g3rv4/getmoarfediverse:$version"
|
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
|
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ launchSettings.json
|
|||||||
.idea/
|
.idea/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
data/
|
data/
|
||||||
|
output/
|
@ -1,5 +1,5 @@
|
|||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using Jil;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace GetMoarFediverse;
|
namespace GetMoarFediverse;
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public class Config
|
|||||||
return;
|
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 importedPath = Path.Join(Path.GetDirectoryName(path), "imported.txt");
|
||||||
var apiKey = string.IsNullOrEmpty(data.FakeRelayApiKey)
|
var apiKey = string.IsNullOrEmpty(data.FakeRelayApiKey)
|
||||||
@ -40,7 +40,7 @@ public class Config
|
|||||||
Instance = new Config(importedPath, data.FakeRelayUrl, apiKey, data.Tags.ToImmutableArray(), data.ImmutableSites);
|
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 FakeRelayUrl { get; set; }
|
||||||
public string? FakeRelayApiKey { get; set; }
|
public string? FakeRelayApiKey { get; set; }
|
||||||
@ -55,8 +55,8 @@ public class Config
|
|||||||
|
|
||||||
public class InternalSiteData
|
public class InternalSiteData
|
||||||
{
|
{
|
||||||
public string Host { get; private set; }
|
public string Host { get; set; }
|
||||||
public string[]? SiteSpecificTags { get; private set; }
|
public string[]? SiteSpecificTags { get; set; }
|
||||||
|
|
||||||
public SiteData ToSiteData() =>
|
public SiteData ToSiteData() =>
|
||||||
new()
|
new()
|
||||||
|
@ -7,8 +7,4 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Jil" Version="2.17.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</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.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
using GetMoarFediverse;
|
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 client = new HttpClient();
|
||||||
var authClient = new HttpClient
|
var authClient = new HttpClient
|
||||||
@ -49,7 +54,7 @@ await Parallel.ForEachAsync(sitesTags, parallelOptions, async (st, _) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
var json = await response.Content.ReadAsStringAsync();
|
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)))
|
foreach (var statusLink in data.OrderedItems.Where(i=>!imported.Contains(i)))
|
||||||
{
|
{
|
||||||
@ -87,5 +92,5 @@ File.WriteAllLines(importedPath, importedList);
|
|||||||
|
|
||||||
public class TagResponse
|
public class TagResponse
|
||||||
{
|
{
|
||||||
public string[] OrderedItems { get; private set; }
|
public string[] OrderedItems { get; set; }
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user