Skip to content

ci: enhance release workflow #5

ci: enhance release workflow

ci: enhance release workflow #5

Workflow file for this run

name: Flutter Web
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.22.3'
channel: 'stable'
- name: Install dependencies
run: flutter pub get
- name: Build web
run: flutter build web --release --base-href /json2dart/
# 上传构建产物作为 Artifacts
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: web-build
path: build/web/
retention-days: 30
# 创建发布压缩包
- name: Create Release Archive
run: |
cd build/web
zip -r ../../json2dart-web.zip .
cd ../..
# 获取时间戳作为版本号
- name: Get current date
id: date
run: echo "BUILD_DATE=$(date +'%Y%m%d_%H%M%S')" >> $GITHUB_ENV
# 创建发布版本
- name: Create Release
uses: ncipollo/release-action@v1
if: github.ref == 'refs/heads/main'
with:
artifacts: "json2dart-web.zip"
token: ${{ secrets.GITHUB_TOKEN }}
tag: build_${{ env.BUILD_DATE }}
name: Build ${{ env.BUILD_DATE }}
body: |
JSON to Dart Converter Web Build
Build Date: ${{ env.BUILD_DATE }}
This release contains:
- Compiled web application
- All build artifacts
## Installation
1. Download the zip file
2. Extract it to your web server
3. Access through your web server
## Direct Usage
Online version: https://invincible1996.github.io/json2dart/
## Changes
This is an automated build from the main branch.
# 部署到 GitHub Pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/web