Files
QuantEngineByItz/.gitea/workflows/prepare-release.yml
T
kjh2064 02c7bdaeda debug: Add detailed logging to prepare-release.yml
- Add git config output for debugging tag creation
- Add artifact existence check
- Add gh CLI version check
- Add explicit --repo parameter for gh release create
- Make tag push non-fatal to continue workflow
2026-07-11 23:59:11 +09:00

169 lines
5.4 KiB
YAML

name: Prepare Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (auto-generated if empty, e.g. quant_20260711.1.abc1234)'
required: false
type: string
env:
DOTNET_VERSION: '10.0.x'
jobs:
build-and-release:
name: Build & Create Release
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
version: ${{ steps.metadata.outputs.version }}
commit: ${{ steps.metadata.outputs.commit }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Generate Metadata
id: metadata
run: |
VERSION_INPUT="${{ github.event.inputs.version }}"
COMMIT=$(git rev-parse --short HEAD)
# Auto-generate version if not provided
if [ -z "$VERSION_INPUT" ]; then
TODAY=$(TZ=UTC date +%Y%m%d)
# Count releases for today
RELEASES_TODAY=$(git tag -l "quant_${TODAY}.*" | wc -l)
DEPLOY_COUNT=$((RELEASES_TODAY + 1))
VERSION="quant_${TODAY}.${DEPLOY_COUNT}.${COMMIT}"
else
VERSION="$VERSION_INPUT"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "commit=${COMMIT}" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
echo "Commit: $COMMIT"
- name: Restore
run: |
dotnet restore src/dotnet/QuantEngine.Web/QuantEngine.Web.csproj
- name: Build (Release)
run: |
dotnet build src/dotnet/QuantEngine.Web/QuantEngine.Web.csproj \
-c Release \
--no-restore \
-p:ContinuousIntegrationBuild=true
- name: Publish
run: |
dotnet publish src/dotnet/QuantEngine.Web/QuantEngine.Web.csproj \
-c Release \
-o ./publish \
--no-restore \
--no-build
- name: Write Production Config
run: |
mkdir -p ./publish
python3 -c '
import json
import pathlib
config = {
"ConnectionStrings": {
"DefaultConnection": "Host=127.0.0.1;Database=quantenginedb;Username=quantengine_app;Password=quantengine_app;Search Path=quantengine;"
},
"Logging": {
"LogLevel": {
"Default": "Information"
}
}
}
pathlib.Path("./publish/appsettings.Production.json").write_text(
json.dumps(config, ensure_ascii=False, indent=2),
encoding="utf-8"
)'
test -s ./publish/appsettings.Production.json || { echo "ERROR: appsettings.Production.json is empty"; exit 1; }
echo "✓ Production config created"
- name: Package Artifact
run: |
VERSION="${{ steps.metadata.outputs.version }}"
ARTIFACT="quantengine_${VERSION}.tar.gz"
tar -czf "$ARTIFACT" -C ./publish .
echo "artifact=${ARTIFACT}" >> $GITHUB_OUTPUT
echo "✓ Package: $(du -sh $ARTIFACT | cut -f1)"
file "$ARTIFACT"
- name: Create Git Tag
run: |
VERSION="${{ steps.metadata.outputs.version }}"
COMMIT="${{ steps.metadata.outputs.commit }}"
echo "Git config:"
git config user.name
git config user.email
git tag -a "$VERSION" -m "Release $VERSION (commit: $COMMIT)" HEAD
echo "✓ Local tag created: $VERSION"
git push origin "$VERSION" || echo "⚠️ Tag push failed, continuing..."
echo "✓ Tag creation complete"
- name: Create Gitea Release
env:
VERSION: ${{ steps.metadata.outputs.version }}
COMMIT: ${{ steps.metadata.outputs.commit }}
GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
ARTIFACT="quantengine_${VERSION}.tar.gz"
echo "Checking artifact..."
ls -lh "$ARTIFACT" || echo "⚠️ Artifact not found: $ARTIFACT"
echo ""
echo "Checking gh CLI..."
which gh || echo "⚠️ gh CLI not found"
gh version || echo "⚠️ gh version failed"
echo ""
echo "Creating release..."
gh release create "$VERSION" "$ARTIFACT" \
--title "Release $VERSION" \
--notes "Release Version: $VERSION | Commit: ${COMMIT}" \
--repo kjh2064/QuantEngineByItz
echo "✓ Release created: $VERSION"
echo "✓ Artifact attached: $ARTIFACT"
notification:
name: Release Notification
runs-on: ubuntu-latest
if: always()
needs: build-and-release
steps:
- name: Notify Release Ready
if: needs.build-and-release.result == 'success'
run: |
echo "════════════════════════════════════════"
echo "✅ Release Ready for Deployment"
echo "════════════════════════════════════════"
echo "Version: ${{ needs.build-and-release.outputs.version }}"
echo "Commit: ${{ needs.build-and-release.outputs.commit }}"
echo ""
echo "Next: Use deploy-prod.yml to deploy this release"
echo "════════════════════════════════════════"