feat: Update build workflows for Catalog Lite and Windows Avalonia with improved input types and release handling
Some checks failed
Build Windows Avalonia / build (push) Failing after 1m43s
Some checks failed
Build Windows Avalonia / build (push) Failing after 1m43s
This commit is contained in:
parent
50f0209eb9
commit
3fea86fa78
3 changed files with 185 additions and 90 deletions
|
|
@ -7,10 +7,12 @@ on:
|
||||||
description: Catalog Lite expiration date, yyyy-MM-dd
|
description: Catalog Lite expiration date, yyyy-MM-dd
|
||||||
required: true
|
required: true
|
||||||
default: '2026-12-31'
|
default: '2026-12-31'
|
||||||
|
type: string
|
||||||
publish_release:
|
publish_release:
|
||||||
description: Publish Forgejo release when running on a tag ref
|
description: Publish Forgejo release when running on a tag ref
|
||||||
required: true
|
required: true
|
||||||
default: 'false'
|
default: false
|
||||||
|
type: boolean
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOTNET_VERSION: 10.0.x
|
DOTNET_VERSION: 10.0.x
|
||||||
|
|
@ -92,7 +94,7 @@ jobs:
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
release:
|
release:
|
||||||
if: ${{ inputs.publish_release == 'true' && startsWith(github.ref, 'refs/tags/') }}
|
if: inputs.publish_release && startsWith(forgejo.ref, 'refs/tags/')
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
env:
|
env:
|
||||||
|
|
@ -122,8 +124,8 @@ jobs:
|
||||||
- name: Create or update release
|
- name: Create or update release
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
api_base="${GITHUB_SERVER_URL%/}/api/v1/repos/${GITHUB_REPOSITORY}"
|
api_base="${FORGEJO_SERVER_URL%/}/api/v1/repos/${FORGEJO_REPOSITORY}"
|
||||||
tag="${GITHUB_REF_NAME}"
|
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}")"
|
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}")"
|
||||||
update_payload="$(printf '{"body":"Catalog Lite\\n\\nScadenza build: %s"}' "${CATALOG_LITE_EXPIRATION_DATE}")"
|
update_payload="$(printf '{"body":"Catalog Lite\\n\\nScadenza build: %s"}' "${CATALOG_LITE_EXPIRATION_DATE}")"
|
||||||
|
|
||||||
|
|
@ -166,8 +168,8 @@ jobs:
|
||||||
- name: Upload release assets
|
- name: Upload release assets
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
api_base="${GITHUB_SERVER_URL%/}/api/v1/repos/${GITHUB_REPOSITORY}"
|
api_base="${FORGEJO_SERVER_URL%/}/api/v1/repos/${FORGEJO_REPOSITORY}"
|
||||||
short_sha="$(printf '%s' "${GITHUB_SHA}" | cut -c1-12)"
|
short_sha="$(printf '%s' "${FORGEJO_SHA}" | cut -c1-12)"
|
||||||
|
|
||||||
windows_exe="$(find artifacts/release/win-x64 -maxdepth 1 -type f -iname '*.exe' | head -n1)"
|
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)"
|
linux_exe="$(find artifacts/release/linux-x64 -maxdepth 1 -type f -name 'CatalogLite' | head -n1)"
|
||||||
|
|
@ -182,7 +184,7 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
linux_archive="CatalogLite-linux-x64-${GITHUB_REF_NAME}-${short_sha}.tar.gz"
|
linux_archive="CatalogLite-linux-x64-${FORGEJO_REF_NAME}-${short_sha}.tar.gz"
|
||||||
tar -czf "${linux_archive}" -C "$(dirname "${linux_exe}")" "$(basename "${linux_exe}")"
|
tar -czf "${linux_archive}" -C "$(dirname "${linux_exe}")" "$(basename "${linux_exe}")"
|
||||||
|
|
||||||
upload_asset() {
|
upload_asset() {
|
||||||
|
|
@ -195,5 +197,5 @@ jobs:
|
||||||
"${api_base}/releases/${RELEASE_ID}/assets?name=${asset_name}"
|
"${api_base}/releases/${RELEASE_ID}/assets?name=${asset_name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
upload_asset "${windows_exe}" "CatalogLite-win-x64-${GITHUB_REF_NAME}-${short_sha}.exe"
|
upload_asset "${windows_exe}" "CatalogLite-win-x64-${FORGEJO_REF_NAME}-${short_sha}.exe"
|
||||||
upload_asset "${linux_archive}" "${linux_archive}"
|
upload_asset "${linux_archive}" "${linux_archive}"
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,13 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- develop
|
- develop
|
||||||
tags:
|
paths:
|
||||||
- '*'
|
- '.forgejo/workflows/build-windows-avalonia.yml'
|
||||||
paths-ignore:
|
- 'Catalog.Communication/**'
|
||||||
- 'CatalogLite/**'
|
- 'GitVersion.yml'
|
||||||
|
- 'NuGet.Config'
|
||||||
|
- 'MaddoShared/**'
|
||||||
|
- 'imagecatalog/**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|
@ -95,80 +98,3 @@ jobs:
|
||||||
path: ${{ env.PUBLISH_DIR }}
|
path: ${{ env.PUBLISH_DIR }}
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
release:
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
needs: build
|
|
||||||
runs-on: docker
|
|
||||||
env:
|
|
||||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Download publish artifact
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: ${{ env.ARTIFACT_NAME }}
|
|
||||||
path: artifacts/release
|
|
||||||
|
|
||||||
- name: Validate release token
|
|
||||||
run: |
|
|
||||||
set -eu
|
|
||||||
if [ -z "${FORGEJO_TOKEN}" ]; then
|
|
||||||
echo "secrets.FORGEJO_TOKEN is required for tagged releases"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Create or reuse release
|
|
||||||
run: |
|
|
||||||
set -eu
|
|
||||||
api_base="${GITHUB_SERVER_URL%/}/api/v1/repos/${GITHUB_REPOSITORY}"
|
|
||||||
tag="${GITHUB_REF_NAME}"
|
|
||||||
|
|
||||||
http_code="$(curl -sS -o release.json -w '%{http_code}' \
|
|
||||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
|
||||||
"${api_base}/releases/tags/${tag}")"
|
|
||||||
|
|
||||||
if [ "${http_code}" = "200" ]; then
|
|
||||||
release_id="$(sed -n 's/.*"id":\([0-9][0-9]*\).*/\1/p' release.json | head -n1)"
|
|
||||||
elif [ "${http_code}" = "404" ]; then
|
|
||||||
payload="$(printf '{"tag_name":"%s","name":"%s","draft":false,"prerelease":false}' "${tag}" "${tag}")"
|
|
||||||
curl -fsS \
|
|
||||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-X POST \
|
|
||||||
-d "${payload}" \
|
|
||||||
"${api_base}/releases" \
|
|
||||||
-o release.json
|
|
||||||
release_id="$(sed -n 's/.*"id":\([0-9][0-9]*\).*/\1/p' release.json | head -n1)"
|
|
||||||
else
|
|
||||||
echo "Unexpected response while loading release for tag ${tag}: ${http_code}"
|
|
||||||
cat release.json
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${release_id}" ]; then
|
|
||||||
echo "Unable to resolve Forgejo release id"
|
|
||||||
cat release.json
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "RELEASE_ID=${release_id}" >> "${GITHUB_ENV}"
|
|
||||||
|
|
||||||
- name: Upload executable to release
|
|
||||||
run: |
|
|
||||||
set -eu
|
|
||||||
api_base="${GITHUB_SERVER_URL%/}/api/v1/repos/${GITHUB_REPOSITORY}"
|
|
||||||
executable_path="$(find artifacts/release -maxdepth 1 -type f -iname '*.exe' | head -n1)"
|
|
||||||
|
|
||||||
if [ -z "${executable_path}" ]; then
|
|
||||||
echo "No executable found in downloaded artifact"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
short_sha="$(printf '%s' "${GITHUB_SHA}" | cut -c1-12)"
|
|
||||||
asset_name="ImageCatalog-avalonia-win-x64-${GITHUB_REF_NAME}-${short_sha}.exe"
|
|
||||||
|
|
||||||
curl -fsS \
|
|
||||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
|
||||||
--data-binary @"${executable_path}" \
|
|
||||||
"${api_base}/releases/${RELEASE_ID}/assets?name=${asset_name}"
|
|
||||||
167
.forgejo/workflows/release-windows-avalonia.yml
Normal file
167
.forgejo/workflows/release-windows-avalonia.yml
Normal file
|
|
@ -0,0 +1,167 @@
|
||||||
|
name: Release Windows Avalonia
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOTNET_VERSION: 10.0.x
|
||||||
|
PROJECT_PATH: imagecatalog/ImageCatalog 2.csproj
|
||||||
|
PUBLISH_DIR: artifacts/publish/win-x64
|
||||||
|
ARTIFACT_NAME: imagecatalog-windows-avalonia
|
||||||
|
NUGET_SOURCE_NAME: Nuget-Forgejo-AIFotoONLUS
|
||||||
|
NUGET_SOURCE_URL: ${{ vars.AIFOTOONLUS_NUGET_SOURCE_URL || format('{0}/api/packages/{1}/nuget/index.json', forgejo.server_url, vars.AIFOTOONLUS_PACKAGE_OWNER || forgejo.repository_owner) }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: docker
|
||||||
|
env:
|
||||||
|
FORGEJO_PACKAGE_USERNAME: ${{ secrets.FORGEJO_PACKAGE_USERNAME }}
|
||||||
|
FORGEJO_PACKAGE_TOKEN: ${{ secrets.FORGEJO_PACKAGE_TOKEN }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup .NET
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||||
|
|
||||||
|
- name: Validate NuGet secrets
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
if [ -z "${FORGEJO_PACKAGE_USERNAME}" ]; then
|
||||||
|
echo "secrets.FORGEJO_PACKAGE_USERNAME is required"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "${FORGEJO_PACKAGE_TOKEN}" ]; then
|
||||||
|
echo "secrets.FORGEJO_PACKAGE_TOKEN is required"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Configure private NuGet source
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
temp_config="${RUNNER_TEMP}/nuget.config"
|
||||||
|
cp NuGet.Config "${temp_config}"
|
||||||
|
|
||||||
|
dotnet nuget update source "${{ env.NUGET_SOURCE_NAME }}" \
|
||||||
|
--source "${{ env.NUGET_SOURCE_URL }}" \
|
||||||
|
--username "${FORGEJO_PACKAGE_USERNAME}" \
|
||||||
|
--password "${FORGEJO_PACKAGE_TOKEN}" \
|
||||||
|
--store-password-in-clear-text \
|
||||||
|
--configfile "${temp_config}"
|
||||||
|
|
||||||
|
echo "NUGET_CONFIG_PATH=${temp_config}" >> "${GITHUB_ENV}"
|
||||||
|
|
||||||
|
- name: Restore
|
||||||
|
run: dotnet restore "${{ env.PROJECT_PATH }}" -r win-x64 --configfile "${NUGET_CONFIG_PATH}"
|
||||||
|
|
||||||
|
- name: Publish Windows Avalonia build
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
dotnet publish "${{ env.PROJECT_PATH }}" \
|
||||||
|
-c Release \
|
||||||
|
-r win-x64 \
|
||||||
|
--self-contained true \
|
||||||
|
--no-restore \
|
||||||
|
-p:AvaloniaWindowsCrossPublish=true \
|
||||||
|
-p:PublishSingleFile=true \
|
||||||
|
-p:PublishTrimmed=false \
|
||||||
|
-p:PublishReadyToRun=false \
|
||||||
|
-o "${{ env.PUBLISH_DIR }}"
|
||||||
|
|
||||||
|
- name: Validate published executable
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
exe_count="$(find "${{ env.PUBLISH_DIR }}" -maxdepth 1 -type f -iname '*.exe' | wc -l | tr -d ' ')"
|
||||||
|
if [ "${exe_count}" -eq 0 ]; then
|
||||||
|
echo "No Windows executable produced in ${{ env.PUBLISH_DIR }}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Upload publish artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ env.ARTIFACT_NAME }}
|
||||||
|
path: ${{ env.PUBLISH_DIR }}
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: build
|
||||||
|
runs-on: docker
|
||||||
|
env:
|
||||||
|
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download publish artifact
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ env.ARTIFACT_NAME }}
|
||||||
|
path: artifacts/release
|
||||||
|
|
||||||
|
- name: Validate release token
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
if [ -z "${FORGEJO_TOKEN}" ]; then
|
||||||
|
echo "secrets.FORGEJO_TOKEN is required for tagged releases"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create or reuse release
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
api_base="${FORGEJO_SERVER_URL%/}/api/v1/repos/${FORGEJO_REPOSITORY}"
|
||||||
|
tag="${FORGEJO_REF_NAME}"
|
||||||
|
|
||||||
|
http_code="$(curl -sS -o release.json -w '%{http_code}' \
|
||||||
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
|
"${api_base}/releases/tags/${tag}")"
|
||||||
|
|
||||||
|
if [ "${http_code}" = "200" ]; then
|
||||||
|
release_id="$(sed -n 's/.*"id":\([0-9][0-9]*\).*/\1/p' release.json | head -n1)"
|
||||||
|
elif [ "${http_code}" = "404" ]; then
|
||||||
|
payload="$(printf '{"tag_name":"%s","name":"%s","draft":false,"prerelease":false}' "${tag}" "${tag}")"
|
||||||
|
curl -fsS \
|
||||||
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-X POST \
|
||||||
|
-d "${payload}" \
|
||||||
|
"${api_base}/releases" \
|
||||||
|
-o release.json
|
||||||
|
release_id="$(sed -n 's/.*"id":\([0-9][0-9]*\).*/\1/p' release.json | head -n1)"
|
||||||
|
else
|
||||||
|
echo "Unexpected response while loading release for tag ${tag}: ${http_code}"
|
||||||
|
cat release.json
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${release_id}" ]; then
|
||||||
|
echo "Unable to resolve Forgejo release id"
|
||||||
|
cat release.json
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "RELEASE_ID=${release_id}" >> "${GITHUB_ENV}"
|
||||||
|
|
||||||
|
- name: Upload executable to release
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
api_base="${FORGEJO_SERVER_URL%/}/api/v1/repos/${FORGEJO_REPOSITORY}"
|
||||||
|
executable_path="$(find artifacts/release -maxdepth 1 -type f -iname '*.exe' | head -n1)"
|
||||||
|
|
||||||
|
if [ -z "${executable_path}" ]; then
|
||||||
|
echo "No executable found in downloaded artifact"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
short_sha="$(printf '%s' "${FORGEJO_SHA}" | cut -c1-12)"
|
||||||
|
asset_name="ImageCatalog-avalonia-win-x64-${FORGEJO_REF_NAME}-${short_sha}.exe"
|
||||||
|
|
||||||
|
curl -fsS \
|
||||||
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary @"${executable_path}" \
|
||||||
|
"${api_base}/releases/${RELEASE_ID}/assets?name=${asset_name}"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue