fix: Update prepare-release.yml with version auto-generation

- Auto-generate version format: quant_YYYYMMDD.count.hash
- Count existing tags for today to determine deploy count
- Add job outputs for version and commit
- Simplify release notes format to fix YAML parsing error
- Make version input optional (auto-generated if empty)
This commit is contained in:
2026-07-11 23:35:48 +09:00
parent 352b440e8d
commit f2938c232a
+35 -25
View File
@@ -4,8 +4,8 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v0.1.20260711 or v1.0.0)'
required: true
description: 'Release version (auto-generated if empty, e.g. quant_20260711.1.abc1234)'
required: false
type: string
env:
@@ -16,6 +16,9 @@ jobs:
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
@@ -29,14 +32,26 @@ jobs:
- name: Generate Metadata
id: metadata
run: |
VERSION="${{ github.event.inputs.version }}"
VERSION_INPUT="${{ github.event.inputs.version }}"
COMMIT=$(git rev-parse --short HEAD)
TIMESTAMP=$(TZ=UTC date +%Y%m%d_%H%M%S)
ARTIFACT="quantengine_${VERSION}_${COMMIT}.tar.gz"
# 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 "artifact=${ARTIFACT}" >> $GITHUB_OUTPUT
echo "commit=${COMMIT}" >> $GITHUB_OUTPUT
echo "timestamp=${TIMESTAMP}" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
echo "Commit: $COMMIT"
- name: Restore
run: |
@@ -85,8 +100,10 @@ jobs:
- name: Package Artifact
run: |
ARTIFACT="${{ steps.metadata.outputs.artifact }}"
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"
@@ -99,31 +116,24 @@ jobs:
echo "✓ Tag created: $VERSION"
- name: Create Gitea Release
env:
VERSION: ${{ steps.metadata.outputs.version }}
COMMIT: ${{ steps.metadata.outputs.commit }}
run: |
VERSION="${{ steps.metadata.outputs.version }}"
ARTIFACT="${{ steps.metadata.outputs.artifact }}"
COMMIT="${{ steps.metadata.outputs.commit }}"
TOKEN="${{ secrets.GITEA_TOKEN }}"
REPO="kjh2064/QuantEngineByItz"
ARTIFACT="quantengine_${VERSION}.tar.gz"
BUILD_TIME=$(date '+%Y-%m-%d %H:%M:%S UTC')
# Create release
gh release create "$VERSION" "$ARTIFACT" \
--title "Release $VERSION" \
--notes "Commit: $COMMIT
--notes "Commit: ${COMMIT}
Platform: .NET 10
Build: $(date '+%Y-%m-%d %H:%M:%S UTC')
Build Time: ${BUILD_TIME}
## Files
- quantengine_release.tar.gz
- QuantEngine.Web.dll
- appsettings.Production.json
- All dependencies
## Deployment
Use deploy-prod.yml with release: \`$VERSION\`"
Version Format: quant_YYYYMMDD.count.hash
Artifact: quantengine_${VERSION}.tar.gz"
echo "✓ Release created: $VERSION"
echo "✓ Artifact attached"
echo "✓ Artifact attached: $ARTIFACT"
notification:
name: Release Notification