diff --git a/.forgejo/workflows/build-catalog-lite.yml b/.forgejo/workflows/build-catalog-lite.yml index c916fe9..8bf031a 100644 --- a/.forgejo/workflows/build-catalog-lite.yml +++ b/.forgejo/workflows/build-catalog-lite.yml @@ -8,11 +8,6 @@ on: required: true default: '2026-12-31' type: string - publish_release: - description: Publish Forgejo release when running on a tag ref - required: true - default: false - type: boolean env: DOTNET_VERSION: 10.0.x @@ -28,8 +23,10 @@ jobs: include: - runtime: win-x64 artifact_name: catalog-lite-win-x64 + executable_name: CatalogLite.exe - runtime: linux-x64 artifact_name: catalog-lite-linux-x64 + executable_name: CatalogLite steps: - name: Checkout @@ -62,12 +59,15 @@ jobs: dotnet publish "${{ env.PROJECT_PATH }}" \ -c Release \ -r "${{ matrix.runtime }}" \ - --self-contained true \ + --self-contained false \ --no-restore \ -p:CatalogLiteExpirationDate="${CATALOG_LITE_EXPIRATION_DATE}" \ -p:PublishSingleFile=true \ + -p:SelfContained=false \ + -p:IncludeNativeLibrariesForSelfExtract=true \ -p:PublishTrimmed=false \ -p:PublishReadyToRun=false \ + -p:DebugType=embedded \ -o "${PUBLISH_DIR}" - name: Validate published files @@ -75,14 +75,23 @@ jobs: PUBLISH_DIR: artifacts/publish/${{ matrix.runtime }} run: | set -eu - if [ "${{ matrix.runtime }}" = "win-x64" ]; then - file_count="$(find "${PUBLISH_DIR}" -maxdepth 1 -type f -iname '*.exe' | wc -l | tr -d ' ')" - else - file_count="$(find "${PUBLISH_DIR}" -maxdepth 1 -type f -name 'CatalogLite' | wc -l | tr -d ' ')" + executable="${PUBLISH_DIR}/${{ matrix.executable_name }}" + if [ ! -f "${executable}" ]; then + echo "Catalog Lite executable was not produced: ${executable}" + exit 1 fi - if [ "${file_count}" -eq 0 ]; then - echo "No Catalog Lite executable produced in ${PUBLISH_DIR}" + loose_library_count="$(find "${PUBLISH_DIR}" -maxdepth 1 -type f \( -iname '*.dll' -o -name '*.so' -o -name '*.dylib' \) | wc -l | tr -d ' ')" + if [ "${loose_library_count}" -ne 0 ]; then + echo "Catalog Lite publish must not contain loose native or managed libraries:" + find "${PUBLISH_DIR}" -maxdepth 1 -type f \( -iname '*.dll' -o -name '*.so' -o -name '*.dylib' \) -print + exit 1 + fi + + extra_file_count="$(find "${PUBLISH_DIR}" -maxdepth 1 -type f ! -name "${{ matrix.executable_name }}" | wc -l | tr -d ' ')" + if [ "${extra_file_count}" -ne 0 ]; then + echo "Catalog Lite publish artifact must contain only ${{ matrix.executable_name }}:" + find "${PUBLISH_DIR}" -maxdepth 1 -type f ! -name "${{ matrix.executable_name }}" -print exit 1 fi @@ -90,11 +99,10 @@ jobs: uses: actions/upload-artifact@v3 with: name: ${{ matrix.artifact_name }} - path: artifacts/publish/${{ matrix.runtime }} + path: artifacts/publish/${{ matrix.runtime }}/${{ matrix.executable_name }} if-no-files-found: error release: - if: inputs.publish_release && startsWith(forgejo.ref, 'refs/tags/') needs: build runs-on: docker env: @@ -107,12 +115,6 @@ jobs: name: catalog-lite-win-x64 path: artifacts/release/win-x64 - - name: Download Linux artifact - uses: actions/download-artifact@v3 - with: - name: catalog-lite-linux-x64 - path: artifacts/release/linux-x64 - - name: Validate release token run: | set -eu @@ -125,8 +127,10 @@ jobs: run: | set -eu api_base="${FORGEJO_SERVER_URL%/}/api/v1/repos/${FORGEJO_REPOSITORY}" - tag="${FORGEJO_REF_NAME}" - create_payload="$(printf '{"tag_name":"%s","name":"%s","body":"Catalog Lite\\n\\nScadenza build: %s","draft":false,"prerelease":false}' "${tag}" "${tag}" "${CATALOG_LITE_EXPIRATION_DATE}")" + tag="catalog-lite-${CATALOG_LITE_EXPIRATION_DATE}" + name="Catalog Lite ${CATALOG_LITE_EXPIRATION_DATE}" + commit="${FORGEJO_SHA:-${GITHUB_SHA:-}}" + create_payload="$(printf '{"tag_name":"%s","target_commitish":"%s","name":"%s","body":"Catalog Lite\\n\\nScadenza build: %s","draft":false,"prerelease":false}' "${tag}" "${commit}" "${name}" "${CATALOG_LITE_EXPIRATION_DATE}")" update_payload="$(printf '{"body":"Catalog Lite\\n\\nScadenza build: %s"}' "${CATALOG_LITE_EXPIRATION_DATE}")" http_code="$(curl -sS -o release.json -w '%{http_code}' \ @@ -169,23 +173,25 @@ jobs: run: | set -eu api_base="${FORGEJO_SERVER_URL%/}/api/v1/repos/${FORGEJO_REPOSITORY}" - short_sha="$(printf '%s' "${FORGEJO_SHA}" | cut -c1-12)" windows_exe="$(find artifacts/release/win-x64 -maxdepth 1 -type f -iname '*.exe' | head -n1)" - linux_exe="$(find artifacts/release/linux-x64 -maxdepth 1 -type f -name 'CatalogLite' | head -n1)" if [ -z "${windows_exe}" ]; then echo "No Windows executable found in downloaded artifact" exit 1 fi - if [ -z "${linux_exe}" ]; then - echo "No Linux executable found in downloaded artifact" - exit 1 - fi + curl -fsS \ + -H "Authorization: token ${FORGEJO_TOKEN}" \ + "${api_base}/releases/${RELEASE_ID}/assets" \ + -o assets.json - linux_archive="CatalogLite-linux-x64-${FORGEJO_REF_NAME}-${short_sha}.tar.gz" - tar -czf "${linux_archive}" -C "$(dirname "${linux_exe}")" "$(basename "${linux_exe}")" + for asset_id in $(tr '{' '\n' < assets.json | sed -n 's/.*"id":\([0-9][0-9]*\).*"name":"[^"]*".*/\1/p'); do + curl -fsS \ + -H "Authorization: token ${FORGEJO_TOKEN}" \ + -X DELETE \ + "${api_base}/releases/${RELEASE_ID}/assets/${asset_id}" + done upload_asset() { asset_path="$1" @@ -197,5 +203,4 @@ jobs: "${api_base}/releases/${RELEASE_ID}/assets?name=${asset_name}" } - upload_asset "${windows_exe}" "CatalogLite-win-x64-${FORGEJO_REF_NAME}-${short_sha}.exe" - upload_asset "${linux_archive}" "${linux_archive}" + upload_asset "${windows_exe}" "CatalogLite-${CATALOG_LITE_EXPIRATION_DATE}.exe" diff --git a/CatalogLite/App.axaml b/CatalogLite/App.axaml index c01ea2f..7b4ec8a 100644 --- a/CatalogLite/App.axaml +++ b/CatalogLite/App.axaml @@ -36,6 +36,6 @@ - + \ No newline at end of file diff --git a/CatalogLite/CatalogLite.csproj b/CatalogLite/CatalogLite.csproj index 97280a9..7ad0f07 100644 --- a/CatalogLite/CatalogLite.csproj +++ b/CatalogLite/CatalogLite.csproj @@ -8,6 +8,14 @@ CatalogLite false 2026-12-31 + false + true + false + true + true + false + false + embedded @@ -19,14 +27,14 @@ - + - + @@ -45,4 +53,25 @@ Overwrite="true" Lines="using System.Reflection%3B [assembly: AssemblyMetadata("CatalogLiteGeneratedExpirationDate", "$(CatalogLiteExpirationDate)")] [assembly: AssemblyMetadata("CatalogLiteExpirationDate", "$(CatalogLiteExpirationDate)")] namespace CatalogLite%3B internal static class BuildExpiration { public const string ExpirationDate = "$(CatalogLiteExpirationDate)"%3B }" /> + + + + <_CatalogLiteForbiddenReference Include="@(ReferencePath)" Condition="$([System.String]::Copy('%(FileName)').StartsWith('AIFotoONLUS')) Or '%(FileName)' == 'Catalog.Communication' Or '%(FileName)' == 'Microsoft.Windows.Compatibility' Or '%(FileName)' == 'System.Drawing.Common' Or '%(FileName)' == 'System.Private.Windows.GdiPlus' Or '%(FileName)' == 'System.Windows.Extensions'" /> + + + + + + + <_CatalogLiteSidecarFile Include="$(PublishDir)**\*.dll.config;$(PublishDir)**\*.pdb" /> + + + + + + + <_CatalogLiteLooseNativeFile Include="$(PublishDir)**\*.dll;$(PublishDir)**\*.so;$(PublishDir)**\*.dylib" /> + + + \ No newline at end of file diff --git a/MaddoShared/MaddoShared.csproj b/MaddoShared/MaddoShared.csproj index 7e3998c..a0cfd03 100644 --- a/MaddoShared/MaddoShared.csproj +++ b/MaddoShared/MaddoShared.csproj @@ -1,13 +1,15 @@  - net10.0 + net10.0;net10.0-windows Library enable enable false x64 - - $(DefineConstants);WINDOWS + true + false + + $(DefineConstants);WINDOWS @@ -31,6 +33,6 @@ all - + \ No newline at end of file