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:
@@ -4,8 +4,8 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
description: 'Release version (e.g., v0.1.20260711 or v1.0.0)'
|
description: 'Release version (auto-generated if empty, e.g. quant_20260711.1.abc1234)'
|
||||||
required: true
|
required: false
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
env:
|
env:
|
||||||
@@ -16,6 +16,9 @@ jobs:
|
|||||||
name: Build & Create Release
|
name: Build & Create Release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.metadata.outputs.version }}
|
||||||
|
commit: ${{ steps.metadata.outputs.commit }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -29,14 +32,26 @@ jobs:
|
|||||||
- name: Generate Metadata
|
- name: Generate Metadata
|
||||||
id: metadata
|
id: metadata
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ github.event.inputs.version }}"
|
VERSION_INPUT="${{ github.event.inputs.version }}"
|
||||||
COMMIT=$(git rev-parse --short HEAD)
|
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 "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||||
echo "artifact=${ARTIFACT}" >> $GITHUB_OUTPUT
|
|
||||||
echo "commit=${COMMIT}" >> $GITHUB_OUTPUT
|
echo "commit=${COMMIT}" >> $GITHUB_OUTPUT
|
||||||
echo "timestamp=${TIMESTAMP}" >> $GITHUB_OUTPUT
|
echo "Version: $VERSION"
|
||||||
|
echo "Commit: $COMMIT"
|
||||||
|
|
||||||
- name: Restore
|
- name: Restore
|
||||||
run: |
|
run: |
|
||||||
@@ -85,8 +100,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Package Artifact
|
- name: Package Artifact
|
||||||
run: |
|
run: |
|
||||||
ARTIFACT="${{ steps.metadata.outputs.artifact }}"
|
VERSION="${{ steps.metadata.outputs.version }}"
|
||||||
|
ARTIFACT="quantengine_${VERSION}.tar.gz"
|
||||||
tar -czf "$ARTIFACT" -C ./publish .
|
tar -czf "$ARTIFACT" -C ./publish .
|
||||||
|
echo "artifact=${ARTIFACT}" >> $GITHUB_OUTPUT
|
||||||
echo "✓ Package: $(du -sh $ARTIFACT | cut -f1)"
|
echo "✓ Package: $(du -sh $ARTIFACT | cut -f1)"
|
||||||
file "$ARTIFACT"
|
file "$ARTIFACT"
|
||||||
|
|
||||||
@@ -99,31 +116,24 @@ jobs:
|
|||||||
echo "✓ Tag created: $VERSION"
|
echo "✓ Tag created: $VERSION"
|
||||||
|
|
||||||
- name: Create Gitea Release
|
- name: Create Gitea Release
|
||||||
|
env:
|
||||||
|
VERSION: ${{ steps.metadata.outputs.version }}
|
||||||
|
COMMIT: ${{ steps.metadata.outputs.commit }}
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ steps.metadata.outputs.version }}"
|
ARTIFACT="quantengine_${VERSION}.tar.gz"
|
||||||
ARTIFACT="${{ steps.metadata.outputs.artifact }}"
|
BUILD_TIME=$(date '+%Y-%m-%d %H:%M:%S UTC')
|
||||||
COMMIT="${{ steps.metadata.outputs.commit }}"
|
|
||||||
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
|
||||||
REPO="kjh2064/QuantEngineByItz"
|
|
||||||
|
|
||||||
# Create release
|
|
||||||
gh release create "$VERSION" "$ARTIFACT" \
|
gh release create "$VERSION" "$ARTIFACT" \
|
||||||
--title "Release $VERSION" \
|
--title "Release $VERSION" \
|
||||||
--notes "Commit: $COMMIT
|
--notes "Commit: ${COMMIT}
|
||||||
Platform: .NET 10
|
Platform: .NET 10
|
||||||
Build: $(date '+%Y-%m-%d %H:%M:%S UTC')
|
Build Time: ${BUILD_TIME}
|
||||||
|
|
||||||
## Files
|
Version Format: quant_YYYYMMDD.count.hash
|
||||||
- quantengine_release.tar.gz
|
Artifact: quantengine_${VERSION}.tar.gz"
|
||||||
- QuantEngine.Web.dll
|
|
||||||
- appsettings.Production.json
|
|
||||||
- All dependencies
|
|
||||||
|
|
||||||
## Deployment
|
|
||||||
Use deploy-prod.yml with release: \`$VERSION\`"
|
|
||||||
|
|
||||||
echo "✓ Release created: $VERSION"
|
echo "✓ Release created: $VERSION"
|
||||||
echo "✓ Artifact attached"
|
echo "✓ Artifact attached: $ARTIFACT"
|
||||||
|
|
||||||
notification:
|
notification:
|
||||||
name: Release Notification
|
name: Release Notification
|
||||||
|
|||||||
Reference in New Issue
Block a user