-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (105 loc) · 3.53 KB
/
Copy pathrelease.yml
File metadata and controls
121 lines (105 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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