Files
komari-theme-purcarte/.github/workflows/build.yaml
2025-08-13 04:59:38 +08:00

114 lines
3.1 KiB
YAML

name: Build and Release Assets
on:
workflow_dispatch:
push:
tags:
- "v*"
jobs:
build-and-package:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn
- name: Build project
run: yarn build
- name: Update theme configuration
run: |
echo "Updated theme configuration:"
cat komari-theme.json
- name: Verify required files exist
run: |
echo "Checking required files..."
ls -la preview.png || (echo "preview.png not found" && exit 1)
ls -la komari-theme.json || (echo "komari-theme.json not found" && exit 1)
ls -la dist/ || (echo "dist/ directory not found" && exit 1)
echo "All required files found!"
- name: Create theme package
run: |
# Create a temporary directory for the package
mkdir -p theme-package
# Copy required files
cp preview.png theme-package/
cp komari-theme.json theme-package/
cp -r dist/ theme-package/
# Create zip file with version and commit hash
ZIP_NAME="komari-theme-purcarte.zip"
cd theme-package
zip -r ../${ZIP_NAME} .
cd ..
echo "ZIP_NAME=${ZIP_NAME}" >> $GITHUB_ENV
echo "Created package: ${ZIP_NAME}"
ls -la ${ZIP_NAME}
- 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: 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: 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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }}
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.ASSET_NAME }}
asset_name: ${{ env.ASSET_NAME }}
asset_content_type: application/zip