Files
MrTrust/.gitea/workflows/build.yml
MrSphay 16e5d1377c
All checks were successful
Build MrTrust / build (push) Successful in 4m20s
Parse Gitea release id as JSON
2026-05-16 02:42:55 +02:00

80 lines
2.4 KiB
YAML

name: Build MrTrust
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build Windows EXE
shell: bash
run: |
set -euo pipefail
version="0.1.2"
dotnet publish src/MrTrustLauncher.csproj \
--configuration Release \
--runtime win-x64 \
--output dist/build \
-p:EnableWindowsTargeting=true \
-p:PublishSingleFile=true \
-p:SelfContained=true
cp dist/build/MrTrust.exe dist/MrTrust.exe
- name: Build release ZIP
shell: bash
run: |
set -euo pipefail
version="0.1.2"
package_root="dist/MrTrust-${version}"
rm -rf "$package_root" "dist/MrTrust-${version}.zip"
mkdir -p "$package_root"
cp dist/MrTrust.exe "$package_root/"
cp README.md "$package_root/"
(cd dist && zip -r "MrTrust-${version}.zip" "MrTrust-${version}")
- name: Show package contents
shell: bash
run: |
find dist -maxdepth 4 -type f -printf '%p %s bytes\n'
- name: Upload release artifact
uses: actions/upload-artifact@v3
with:
name: MrTrust-0.1.2
path: dist/MrTrust-0.1.2.zip
- name: Attach ZIP to Gitea release
if: github.ref == 'refs/heads/main'
shell: bash
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
version="0.1.2"
api="https://git.wilkensxl.de/api/v1/repos/MrSphay/MrTrust"
release_json="$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" "${api}/releases/tags/v${version}")"
release_id="$(printf '%s' "$release_json" | python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')"
if [ -z "$release_id" ]; then
echo "Could not resolve release id for v${version}" >&2
exit 1
fi
curl -fsS \
-X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-F "attachment=@dist/MrTrust-${version}.zip" \
"${api}/releases/${release_id}/assets?name=MrTrust-${version}.zip"