docs: 更新 README 截图与使用说明 #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Release tag. Leave empty to update latest." | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-windows: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "24" | |
| - name: Enable pnpm | |
| shell: pwsh | |
| run: | | |
| corepack enable | |
| corepack prepare pnpm@10 --activate | |
| - name: Install dependencies | |
| shell: pwsh | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -e .[dev] | |
| pnpm install --frozen-lockfile | |
| - name: Run tests | |
| shell: pwsh | |
| run: | | |
| python -m pytest tests -q | |
| - name: Build Electron package | |
| shell: pwsh | |
| run: | | |
| pnpm run electron:pack | |
| - name: Upload release artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: weekflow-windows-release | |
| path: | | |
| dist/WeekFlow-V*.zip | |
| publish-release: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-windows | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v5 | |
| - name: Resolve release tag | |
| id: release | |
| shell: bash | |
| run: | | |
| PACKAGE_VERSION="$(python -c 'import json; print(json.load(open("package.json", encoding="utf-8"))["version"])')" | |
| if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && -n "${{ inputs.tag }}" ]]; then | |
| TAG_NAME="${{ inputs.tag }}" | |
| elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then | |
| TAG_NAME="${GITHUB_REF_NAME}" | |
| else | |
| TAG_NAME="latest" | |
| fi | |
| TITLE="WeekFlow-V$PACKAGE_VERSION" | |
| echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT" | |
| echo "title=$TITLE" >> "$GITHUB_OUTPUT" | |
| - name: Download built artifacts | |
| uses: actions/download-artifact@v6 | |
| with: | |
| path: release-assets | |
| merge-multiple: true | |
| - name: Publish GitHub release assets | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GH_REPO: ${{ github.repository }} | |
| TAG_NAME: ${{ steps.release.outputs.tag_name }} | |
| TITLE: ${{ steps.release.outputs.title }} | |
| run: | | |
| ls -la release-assets | |
| if gh release view "$TAG_NAME" --repo "$GH_REPO" >/dev/null 2>&1; then | |
| gh release edit "$TAG_NAME" --repo "$GH_REPO" --title "$TITLE" | |
| if [[ "$TAG_NAME" == "latest" ]]; then | |
| gh api --method PATCH "repos/$GH_REPO/git/refs/tags/$TAG_NAME" -f sha="$GITHUB_SHA" -F force=true | |
| fi | |
| gh release view "$TAG_NAME" --repo "$GH_REPO" --json assets --jq '.assets[].name' | | |
| while read -r asset_name; do | |
| if [[ "$asset_name" == WeekFlow-* ]]; then | |
| gh release delete-asset "$TAG_NAME" "$asset_name" --repo "$GH_REPO" --yes | |
| fi | |
| done | |
| gh release upload "$TAG_NAME" release-assets/* --repo "$GH_REPO" --clobber | |
| else | |
| gh release create "$TAG_NAME" release-assets/* --repo "$GH_REPO" --title "$TITLE" --generate-notes --latest | |
| fi |