fix: 尝试修复 build 流程

This commit is contained in:
Montia37
2025-08-13 04:59:38 +08:00
parent af6f7b1d09
commit b1a2e27705

View File

@@ -5,8 +5,6 @@ on:
push:
tags:
- "v*"
release:
types: [created]
jobs:
build-and-package:
@@ -37,22 +35,6 @@ jobs:
- name: Update theme configuration
run: |
# Get current date in YY.MM.DD format
VERSION_DATE=$(date +"%y.%m.%d")
# Get commit hash (short)
COMMIT_HASH=$(git rev-parse --short HEAD)
echo "VERSION_DATE=${VERSION_DATE}" >> $GITHUB_ENV
echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV
# Update komari-theme.json with new version and description
jq --arg version "$VERSION_DATE" \
--arg desc "Theme for Komari Monitor (commit: $COMMIT_HASH)" \
'.version = $version | .description = $desc' \
komari-theme.json > komari-theme-updated.json
mv komari-theme-updated.json komari-theme.json
echo "Updated theme configuration:"
cat komari-theme.json
@@ -75,7 +57,7 @@ jobs:
cp -r dist/ theme-package/
# Create zip file with version and commit hash
ZIP_NAME="komari-theme-purcarte-v${VERSION_DATE}-${COMMIT_HASH}.zip"
ZIP_NAME="komari-theme-purcarte.zip"
cd theme-package
zip -r ../${ZIP_NAME} .
@@ -85,23 +67,30 @@ jobs:
echo "Created package: ${ZIP_NAME}"
ls -la ${ZIP_NAME}
create-release:
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: theme-package
path: ${{ env.ZIP_NAME }}
retention-days: 1
create-release-on-tag-push:
needs: build-and-package
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: theme-package
path: .
- name: Display structure of downloaded files
run: ls -R
- name: Get Asset Name
id: get_asset_name
run: |
ASSET_NAME=$(ls *.zip)
echo "ASSET_NAME=${ASSET_NAME}" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
@@ -110,17 +99,15 @@ jobs:
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }}
body: |
New release based on commit ${{ env.COMMIT_HASH }}
body: "Automated release for tag ${{ github.ref_name }}"
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.ZIP_NAME }}
asset_name: ${{ env.ZIP_NAME }}
asset_path: ./${{ env.ASSET_NAME }}
asset_name: ${{ env.ASSET_NAME }}
asset_content_type: application/zip