-
Notifications
You must be signed in to change notification settings - Fork 90
144 lines (125 loc) · 5.18 KB
/
build-flatpak-x86_64.yml
File metadata and controls
144 lines (125 loc) · 5.18 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
name: Build Flatpak
on:
push:
tags:
- "*"
workflow_dispatch:
inputs:
branch:
description: 'Checkout branch'
required: false
default: dev
tag:
description: 'Checkout tag'
required: false
permissions:
contents: write
jobs:
flatpak:
name: Flatpak Build
runs-on: ubuntu-latest
container:
image: ubuntu:24.04
options: --privileged --security-opt seccomp=unconfined
steps:
- name: Install dependencies
run: |
export DEBIAN_FRONTEND=noninteractive
apt update
apt install -y flatpak-builder flatpak
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.event.inputs.branch || github.ref_name }}
- name: Determine ref_type and ref_name
run: |
if [ "${{ github.ref_type }}" = "tag" ] || [ -n "${{ github.event.inputs.tag }}" ]; then
REF_TYPE="tags"
if [ -n "${{ github.event.inputs.tag }}" ]; then
REF_NAME="${{ github.event.inputs.tag }}"
else
REF_NAME="${{ github.ref_name }}"
fi
else
REF_TYPE="heads"
REF_NAME="${{ github.ref_name }}"
fi
echo "REF_TYPE=$REF_TYPE" >> $GITHUB_ENV
echo "REF_NAME=$REF_NAME" >> $GITHUB_ENV
echo "Ref name is: $REF_NAME"
echo "Ref type is: $REF_TYPE"
- name: Setup flatpak channel
run: |
if [ "${{ env.REF_NAME }}" = "dev" ] || { [ "${{ github.event.inputs.branch }}" = "dev" ] && [ -z "${{ github.event.inputs.tag }}" ]; }; then
FLATPAK_CHANNEL="unstable"
else
FLATPAK_CHANNEL="stable"
fi
echo "FLATPAK_CHANNEL=$FLATPAK_CHANNEL" >> $GITHUB_ENV
echo "Selected flatpak channel: $FLATPAK_CHANNEL"
- name: Set Flatpak manifest ref
run: |
REF="branch"
if [ "${{ env.REF_TYPE }}" = "tags" ]; then
REF="tag"
fi
sed -i -e "s|branch: main|$REF: ${{ env.REF_NAME }}|g" \
-e "s|branch: stable|branch: ${{ env.FLATPAK_CHANNEL }}|g" \
.github/linux/flatpak/io.github.sanny32.omodscan.yaml
- name: Extract version from CMakeLists.txt
run: |
FULL_VERSION=$(grep -oP 'VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' src/CMakeLists.txt)
if [ "${{ env.REF_NAME }}" = "dev" ] || { [ "${{ github.event.inputs.branch }}" = "dev" ] && [ -z "${{ github.event.inputs.tag }}" ]; }; then
MAJOR_MINOR=$(echo "$FULL_VERSION" | cut -d. -f1,2)
APP_VERSION="${MAJOR_MINOR}~dev"
else
APP_VERSION="$FULL_VERSION"
fi
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
echo "Extracted version: $APP_VERSION"
- name: Prepare Flatpak
run: |
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install -y flathub org.kde.Sdk//6.9
- name: Create metainfo file
run: |
sed -e "s|@REF_NAME@|${{ env.REF_NAME }}|g" \
-e "s|@REF_TYPE@|${{ env.REF_TYPE }}|g" \
-e "s|@COMPONENT_ID@|io.github.sanny32.omodscan|g" \
-e "s|@APP_VERSION@|${{ env.APP_VERSION }}|g" \
-e "s|@BUILD_DATE@|$(date +%Y-%m-%d)|g" \
.github/linux/usr/share/metainfo/omodscan.metainfo.xml.in > .github/linux/usr/share/metainfo/omodscan.metainfo.xml
rm .github/linux/usr/share/metainfo/omodscan.metainfo.xml.in
cat -n .github/linux/usr/share/metainfo/omodscan.metainfo.xml
- name: Create desktop file
run: |
sed -e "s|@APP_EXEC@|/app/bin/omodscan|g" \
-e "s|@APP_ICON@|io.github.sanny32.omodscan|g" \
.github/linux/usr/share/applications/omodscan.desktop.in > .github/linux/usr/share/applications/omodscan.desktop
rm .github/linux/usr/share/applications/omodscan.desktop.in
cat -n .github/linux/usr/share/applications/omodscan.desktop
- name: Build Flatpak
run: |
cd .github/linux/flatpak
flatpak info org.kde.Sdk//6.9
echo ""
flatpak-builder --repo=repo --force-clean --disable-rofiles-fuse --verbose build io.github.sanny32.omodscan.yaml
echo ""
flatpak build-bundle repo io.github.sanny32.omodscan.flatpak io.github.sanny32.omodscan ${{ env.FLATPAK_CHANNEL }}
- name: Upload bundle artifact
uses: actions/upload-artifact@v4
with:
name: io.github.sanny32.omodscan.flatpak
path: |
.github/linux/flatpak/io.github.sanny32.omodscan.flatpak
- name: Create or update GitHub Release and upload FLATPAK
if: success() && github.event_name == 'push' && github.ref_type == 'tag'
uses: softprops/action-gh-release@v2
with:
draft: true
tag_name: ${{ github.ref_name }}
name: Open ModScan ${{ env.APP_VERSION }}
files: |
.github/linux/flatpak/io.github.sanny32.omodscan.flatpak
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}