-
Notifications
You must be signed in to change notification settings - Fork 1
160 lines (154 loc) · 5.7 KB
/
Copy pathrelease.yml
File metadata and controls
160 lines (154 loc) · 5.7 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
154
155
156
157
158
159
160
# GitHub Actions workflow for building, testing, and releasing Delve on version bump
# This workflow runs on both Windows and Ubuntu runners
# It only creates a release if the version in delve/__init__.py changes on main
name: Build, Test, and Release Delve
on:
push:
branches:
- main
jobs:
build-test-windows:
name: Build and Test on Windows
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run build script
run: python bootstrap.py all
- name: Cache node modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Prepare settings and urls
run: |
copy build\assemble\delve\example-settings.py build\assemble\delve\settings.py
copy build\assemble\delve\example-urls.py build\assemble\delve\urls.py
- name: Run test suite
shell: cmd
run: |
cd build\assemble
python manage.py test
- name: Upload Windows Artifacts
uses: actions/upload-artifact@v4
with:
name: windows-dist
path: dist/DELVE_*.zip
build-test-linux:
name: Build and Test on Ubuntu
runs-on: ubuntu-latest
outputs:
version: ${{ steps.current_version.outputs.version }}
version_changed: ${{ steps.version_changed.outputs.changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run build script
run: python bootstrap.py all
- name: Cache node modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Prepare settings and urls
run: |
cp build/assemble/delve/example-settings.py build/assemble/delve/settings.py
cp build/assemble/delve/example-urls.py build/assemble/delve/urls.py
- name: Get current version
id: current_version
run: |
VERSION=$(grep -Po '(?<=__version__ = ")([^"]+)' delve/__init__.py)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Get previous version
id: previous_version
run: |
git fetch origin main --depth=2
PREV_VERSION=$(git show HEAD^:delve/__init__.py 2>/dev/null | grep -Po '(?<=__version__ = ")([^"]+)' || echo "")
echo "version=$PREV_VERSION" >> $GITHUB_OUTPUT
- name: Check if release exists
id: check_release
run: |
if gh release view "v${{ steps.current_version.outputs.version }}" > /dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set version_changed output based on release existence
id: version_changed
run: |
if [ "${{ steps.check_release.outputs.exists }}" = "false" ] && [ "${{ steps.current_version.outputs.version }}" != "" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Run test suite
run: |
cd build/assemble
python manage.py test
- name: Upload Linux Artifacts
uses: actions/upload-artifact@v4
with:
name: linux-dist
path: dist/DELVE_*.zip
release:
name: Create Release and Upload All Artifacts
needs: [build-test-linux, build-test-windows]
if: needs.build-test-linux.outputs.version_changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up GitHub CLI
run: sudo apt-get install -y gh
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Check if release exists
id: check_release
run: |
if gh release view "v${{ needs.build-test-linux.outputs.version }}" > /dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
if: steps.check_release.outputs.exists == 'false'
run: |
gh release create "v${{ needs.build-test-linux.outputs.version }}" --title "Delve ${{ needs.build-test-linux.outputs.version }}" --notes ""
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Assets
run: |
for file in dist/**/*.zip; do
gh release upload "v${{ needs.build-test-linux.outputs.version }}" "$file" --clobber
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Notes:
# - The release and asset upload steps only run if the version number changed.
# - Both Windows and Linux jobs will upload their artifacts to the same release.
# - Make sure the dist/ directory contains the correct artifacts before these steps.
# - The GITHUB_TOKEN secret is provided by GitHub Actions for authentication.