-
Notifications
You must be signed in to change notification settings - Fork 1
189 lines (163 loc) · 5.74 KB
/
build-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
183
184
185
186
187
188
189
name: Build and Release DeckTX
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up CMake
uses: lukka/[email protected]
- name: Set environment variables
run: |
echo "build-dir=${{ github.workspace }}/build" >> "$env:GITHUB_ENV"
echo "install-dir=${{ github.workspace }}/install" >> "$env:GITHUB_ENV"
- name: Configure CMake
run: cmake -B ${{ env.build-dir }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ env.install-dir }} -S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ env.build-dir }} --config Release --target install
- name: Package build artifacts
uses: actions/upload-artifact@v4
with:
name: DeckTX-Windows
path: ${{ env.install-dir }}
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Flatpak
run: |
sudo apt update
sudo apt install -y flatpak flatpak-builder
- name: Add Flathub Remote
run: |
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- name: Set environment variables
run: |
echo "build-dir=${{ github.workspace }}/build" >> "$GITHUB_ENV"
echo "flatpak-json=${{ github.workspace }}/flatpak.json" >> "$GITHUB_ENV"
echo "flatpak-file=${{ github.workspace }}/decktx.flatpak" >> "$GITHUB_ENV"
- name: Allow file protocol in Git
run: git config --global protocol.file.allow always
- name: Generate Flatpak manifest
run: |
cat > ${{ env.flatpak-json }} <<EOL
{
"id": "com.pixelyion.DeckTX",
"runtime": "org.freedesktop.Platform",
"runtime-version": "23.08",
"sdk": "org.freedesktop.Sdk",
"command": "/app/DeckTX",
"modules": [
{
"name": "DeckTX",
"buildsystem": "cmake",
"config-opts": [
"-DCMAKE_BUILD_TYPE=Release"
],
"build-options": {
"build-args": [ "--share=network" ]
},
"sources": [
{
"type": "dir",
"path": "."
}
]
}
],
"finish-args": [
"--share=network",
"--share=ipc",
"--device=dri",
"--socket=x11",
"--socket=wayland",
"--device=all"
]
}
EOL
- name: Build Flatpak
run: |
mkdir -p ${{ env.build-dir }}/flatpak-decktx
sudo flatpak-builder --install-deps-from=flathub --force-clean --repo=repo ${{ env.build-dir }}/flatpak-decktx ${{ env.flatpak-json }}
flatpak build-bundle repo ${{ env.flatpak-file }} com.pixelyion.DeckTX
- name: Package build artifacts
uses: actions/upload-artifact@v4
with:
name: DeckTX-Linux
path: ${{ env.flatpak-file }}
release:
runs-on: ubuntu-latest
needs: [build-windows, build-linux]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download Windows build artifacts
uses: actions/download-artifact@v4
with:
name: DeckTX-Windows
path: ${{ github.workspace }}/win
- name: Zip Windows build artifacts
run: |
cd ${{ github.workspace }}/win
zip -r ../decktx-windows.zip *
- name: Download Linux build artifacts
uses: actions/download-artifact@v4
with:
name: DeckTX-Linux
path: ${{ github.workspace }}
- name: Determine Next Tag
run: |
latest_tag=$(git tag --sort=-creatordate --contains v | head -n 1); \
if [ -z "$latest_tag" ]; then \
version=1; \
else \
tag_number=$(echo $latest_tag | sed -E 's/^v([0-9]+).*/\1/'); \
version=$((tag_number + 1)); \
fi; \
echo "VERSION=$version" >> $GITHUB_ENV
- name: Create Annotated Tag
run: |
git config --local user.email "actions-${{ github.run_id }}@github.com"
git config --local user.name "GitHub Actions ${{ github.run_id }}"
git tag -a v${{ env.VERSION }} -m "Release v${{ env.VERSION }}"
git push origin v${{ env.VERSION }}
- name: Create Release
id: create_release
uses: comnoco/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.VERSION }}
release_name: "Release ${{ env.VERSION }}"
body: |
Automatic release of DeckTX for ${{ github.sha }}.
draft: false
prerelease: false
- name: Upload Release Asset (Windows)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/decktx-windows.zip
asset_name: decktx-windows.zip
asset_content_type: application/zip
- name: Upload Release Asset (Linux)
uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/decktx.flatpak
asset_name: decktx-linux.flatpak
asset_content_type: application/vnd.flatpak