Skip to content

Commit 82953aa

Browse files
committed
add matrix build in workflow for multiple version build
1 parent e821341 commit 82953aa

File tree

2 files changed

+125
-91
lines changed

2 files changed

+125
-91
lines changed

.github/workflows/generate-fake-module-file.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: generate fake pyi file
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
krita_version:
7+
description: 'select krita version: (1)for git master branch, please input "master". (2)for other released version, please input the version number, such as "5.1.0". (3)for more than one version, please split them by space, for example "master 5.1.0 5.1.2 5.1.3"'
8+
required: true
9+
type: string
10+
default: 'master'
11+
is_to_release:
12+
description: 'release the generated file?(y/n, default is n. Even if you select "n", you still can download the generated file from the "Artifacts" column in the jobs summary page.)'
13+
required: true
14+
default: 'n'
15+
16+
jobs:
17+
setup_version_matrix:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- id: setMatrix
21+
run: |
22+
count=0
23+
for i in ${{ inputs.krita_version }};do
24+
count=$[$count+1]
25+
done
26+
echo -n "versions={\"versions\":[" > temp.json
27+
for i in ${{ inputs.krita_version }};do
28+
if [ $count != 1 ];then
29+
echo -n "\"$i\", " >> temp.json
30+
count=$[$count-1]
31+
else
32+
echo -n "\"$i\"" >> temp.json
33+
fi
34+
done
35+
echo -n "]}" >> temp.json
36+
echo "request versions:"
37+
cat temp.json
38+
cat temp.json >> $GITHUB_OUTPUT
39+
outputs:
40+
versions: ${{ steps.setMatrix.outputs.versions }}
41+
42+
krita-pyi:
43+
runs-on: ubuntu-latest
44+
needs: setup_version_matrix
45+
strategy:
46+
fail-fast: false
47+
matrix: ${{ fromJSON(needs.setup_version_matrix.outputs.versions) }}
48+
permissions:
49+
contents: write
50+
steps:
51+
- name: install packages
52+
run: |
53+
sudo apt-get update -y
54+
sudo apt-get install -y wget
55+
56+
- name: setup python3
57+
uses: actions/setup-python@v4
58+
with:
59+
python-version: '3.10'
60+
61+
- name: download this repo
62+
uses: actions/checkout@v3
63+
with:
64+
path: krita-python-auto-complete
65+
66+
- name: download krita source code (from git master)
67+
if: matrix.versions == 'master'
68+
uses: actions/checkout@v3
69+
with:
70+
repository: KDE/krita
71+
sparse-checkout: |
72+
CMakeLists.txt
73+
libs/libkis
74+
fetch-depth: 1
75+
path: krita-${{ matrix.versions }}
76+
77+
- name: download krita source code (from released tag)
78+
if: matrix.versions != 'master'
79+
uses: actions/checkout@v3
80+
with:
81+
repository: KDE/krita
82+
ref: ${{ matrix.versions }}
83+
sparse-checkout: |
84+
CMakeLists.txt
85+
libs/libkis
86+
fetch-depth: 1
87+
path: krita-${{ matrix.versions }}
88+
89+
- name: retrieve actual krita version
90+
id: retrieve_actual_version
91+
run: |
92+
cd "krita-${{ matrix.versions }}"
93+
s="$(grep -i "set(KRITA_VERSION_STRING" CMakeLists.txt)"
94+
s="${s%\"*}"
95+
s="${s#*\"}"
96+
echo "actual_krita_version=$s" >> $GITHUB_OUTPUT
97+
cd ${{ github.workspace }}
98+
99+
- name: generate krita.py
100+
run: |
101+
echo "actual krita version is:"
102+
echo "${{ steps.retrieve_actual_version.outputs.actual_krita_version }}"
103+
echo "kritaHomeDir = \"$(pwd)/krita-${{ matrix.versions }}\""
104+
echo "kritaHomeDir = \"$(pwd)/krita-${{ matrix.versions }}\"" > /tmp/kritaHomeDirSave.py
105+
python ./krita-python-auto-complete/generate-python-autocomplete-file.py
106+
cp output/krita.pyi .
107+
108+
- name: save krita.py to artifact
109+
uses: actions/upload-artifact@v3
110+
with:
111+
name: krita-${{ steps.retrieve_actual_version.outputs.actual_krita_version }}.pyi
112+
path: krita.pyi
113+
retention-days: 5
114+
115+
- name: auto release
116+
if: github.event.inputs.is_to_release == 'y'
117+
uses: softprops/action-gh-release@v1
118+
with:
119+
prerelease: true
120+
name: "fake definition wrapper krita.pyi for krita-${{ steps.retrieve_actual_version.outputs.actual_krita_version }}"
121+
tag_name: ${{ steps.retrieve_actual_version.outputs.actual_krita_version }}
122+
files: |
123+
krita.pyi
124+
125+

0 commit comments

Comments
 (0)