-
Notifications
You must be signed in to change notification settings - Fork 1
153 lines (132 loc) · 4.75 KB
/
create-release.yml
File metadata and controls
153 lines (132 loc) · 4.75 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Create Release
on:
workflow_dispatch:
inputs:
version_bump:
description: "Select the version bump type"
required: true
default: "patch"
type: choice
options:
- none
- patch
- minor
- major
# Prevent multiple release workflows in parallel
concurrency:
group: release
cancel-in-progress: false
jobs:
prepare_release:
runs-on: ubuntu-latest
outputs:
app_version: ${{ steps.set_version.outputs.APP_VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install dependencies
run: python -m pip install -r requirements.txt --upgrade
- name: Determine Version and Tag
id: set_version
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
if [ "${{ github.event.inputs.version_bump }}" != "none" ]; then
# Bump version
new_version=$(python bump_version.py ${{ github.event.inputs.version_bump }})
git add src/utils/version.py
git commit -m "Bump version to $new_version" || echo "No changes to commit"
git push origin ${{ github.ref_name }}
version=$new_version
else
# Use current version from file
version=$(python -c "from src.utils.version import APP_VERSION; print(APP_VERSION)")
fi
# Force-create/update tag
git tag -f v$version
git push origin -f v$version
echo "APP_VERSION=$version" >> $GITHUB_OUTPUT
build:
runs-on: ${{ matrix.runner_label }}
needs: prepare_release
strategy:
matrix:
include:
- runner_label: windows-latest
python_arch: x64
artifact_suffix: ""
target_arch: "" # Not used for Windows
- runner_label: macos-13
python_arch: x64
artifact_suffix: "_x86_64"
target_arch: x86_64
- runner_label: macos-latest
python_arch: arm64
artifact_suffix: "_arm64"
target_arch: arm64
steps:
- name: Checkout latest code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
architecture: ${{ matrix.python_arch }}
- name: Install dependencies
run: python -m pip install -r requirements.txt --upgrade
- name: Install PyInstaller (macOS)
if: runner.os == 'macOS'
run: python -m pip install pyinstaller --upgrade
shell: bash
- name: Install create-dmg (macOS)
if: runner.os == 'macOS'
run: brew install create-dmg
shell: bash
- name: Bundle application (Windows)
if: runner.os == 'Windows'
run: powershell -ExecutionPolicy Bypass -File .\bundle_app_windows.ps1 --ci
shell: pwsh
- name: Verify artifact exists (Windows)
if: runner.os == 'Windows'
run: |
$file = "./dist/NITools_${{ runner.os }}_v${{ needs.prepare_release.outputs.app_version }}.zip"
if (-Not (Test-Path $file)) {
Write-Error "Expected artifact not found: $file"
exit 1
}
shell: pwsh
- name: Bundle application (macOS)
if: runner.os == 'macOS'
run: bash ./bundle_app_macos.sh ${{ matrix.target_arch }} --ci
shell: bash
- name: Verify artifact exists (macOS)
if: runner.os == 'macOS'
run: |
file="./dist/NITools_macOS${{ matrix.artifact_suffix }}_v${{ needs.prepare_release.outputs.app_version }}.dmg"
if [ ! -f "$file" ]; then
echo "::error::Expected artifact not found: $file"
exit 1
fi
shell: bash
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.prepare_release.outputs.app_version }}
files: |
${{ runner.os == 'Windows' && format('./dist/NITools_Windows_v{0}.zip', needs.prepare_release.outputs.app_version) || '' }}
${{ runner.os == 'macOS' && format('./dist/NITools_macOS{0}_v{1}.dmg', matrix.artifact_suffix, needs.prepare_release.outputs.app_version) || '' }}
name: Release v${{ needs.prepare_release.outputs.app_version }}
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}