-
Notifications
You must be signed in to change notification settings - Fork 9
182 lines (151 loc) · 5.3 KB
/
build-and-release.yml
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: CI/CD
on:
push:
branches:
- "master"
paths-ignore:
- "README.md"
- "doc/**"
- "map_samples/**"
jobs:
validate_release_version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.write_output.outputs.version }}
tag_name: ${{ steps.write_output.outputs.tag_name }}
package_desc: ${{ steps.write_output.outputs.package_desc }}
steps:
- uses: actions/checkout@v3
- name: Determine Version
id: get_version
run: |
package_version=$(python ./src/version.py --version)
package_desc=$(python ./src/version.py --description)
echo "package_version=$package_version" >> $GITHUB_ENV
echo "tag_name=v$package_version" >> $GITHUB_ENV
echo "package_desc<<EOF" >> $GITHUB_ENV
echo "$package_desc" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- uses: mukunku/[email protected]
id: check_tag
with:
tag: ${{ env.tag_name }}
- name: Write Output
id: write_output
run: |
if [ ${{ steps.check_tag.outputs.exists }} = 'true' ]; then
echo "Tag for this release already exists! Bump version in src/version.py"
exit 1
else
echo "tag_name=${{ env.tag_name }}" >> $GITHUB_OUTPUT
echo "version=${{ env.package_version }}" >> $GITHUB_OUTPUT
echo "package_desc<<EOF" >> $GITHUB_OUTPUT
echo "${{ env.package_desc }}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
build_linux:
runs-on: ubuntu-latest
needs: validate_release_version
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
sudo apt-get install qtbase5-dev qt5-qmake
pip install -r src/requirements.txt
- name: Install build dependencies
run: pip install -r build/requirements-dev.txt
- name: Make staging directory for build
run: mkdir stage
- name: Package tools for Linux
run: cp -r tools/linux stage/tools
- name: Package support files
run: |
cp -r resources stage
cp LICENSE stage
cp README.md stage
- name: Package build
run: |
cd build/linux
sh build.sh
cd ../..
cp -r bin/pymapconv stage
tar -czvf "pymapconv.v${{ needs.validate_release_version.outputs.version }}.linux-amd64.tar.gz" -C stage .
- uses: actions/upload-artifact@v3
with:
name: linux-build
path: pymapconv.v${{ needs.validate_release_version.outputs.version }}.linux-amd64.tar.gz
build_windows:
runs-on: windows-latest
needs: validate_release_version
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install -r src/requirements.txt
- name: Install build dependencies
run: |
pip install -r build/requirements-dev.txt
- name: Make staging directory for build
run: mkdir stage
- name: Package tools for Windows
run: cp -r tools/win stage/tools
- name: Package support files
run: |
cp -r resources stage
cp LICENSE stage
cp README.md stage
cp build/win/nvdxt.exe stage
- name: Package build
run: |
cd ./build/win
powershell ./build.ps1
cd ../..
cp -r bin/pymapconv.exe stage
Compress-Archive -Path stage/* -DestinationPath pymapconv.v${{ needs.validate_release_version.outputs.version }}.windows-amd64.zip
- uses: actions/upload-artifact@v3
with:
name: windows-build
path: pymapconv.v${{ needs.validate_release_version.outputs.version }}.windows-amd64.zip
release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
permissions:
contents: write
needs:
- build_linux
- build_windows
- validate_release_version
steps:
- uses: actions/checkout@v3
- name: Download Linux Artifact
uses: actions/download-artifact@v3
with:
name: linux-build
- name: Download Windows Artifact
uses: actions/download-artifact@v3
with:
name: windows-build
- name: Create Release Tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ needs.validate_release_version.outputs.tag_name }}
tag_exists_error: true
message: Release ${{ needs.validate_release_version.outputs.tag_name }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: v${{ needs.validate_release_version.outputs.version }}
tag_name: ${{ needs.validate_release_version.outputs.tag_name }}
prerelease: false
body: ${{ needs.validate_release_version.outputs.package_desc }}
files: |
pymapconv.v${{ needs.validate_release_version.outputs.version }}.linux-amd64.tar.gz
pymapconv.v${{ needs.validate_release_version.outputs.version }}.windows-amd64.zip