-
Notifications
You must be signed in to change notification settings - Fork 2
204 lines (176 loc) · 7.89 KB
/
build.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: Build
on:
push:
branches: [master]
tags:
- 'v*'
pull_request:
branches: [master]
workflow_dispatch:
env:
DEBIAN_FRONTEND: noninteractive
jobs:
build-artifact:
runs-on: ubuntu-latest
container:
image: ${{matrix.image}}
options: --privileged
strategy:
matrix:
image: ['ubuntu:23.04', 'ubuntu:22.04', 'ubuntu:20.04', 'debian:12', 'debian:11', 'debian:10', 'opensuse/leap:15.4', 'fedora:40', 'fedora:39', 'fedora:38']
fail-fast: false
steps:
- name: Install dependencies (ubuntu & debian)
if: startsWith(matrix.image, 'ubuntu') || startsWith(matrix.image, 'debian')
run: apt update && apt install -y wget file dpkg-dev fuse git g++ cmake qtbase5-dev libicu-dev libglib2.0-dev ibus libibus-1.0-dev fcitx5 libfcitx5core-dev libfcitx5config-dev libfcitx5utils-dev
- name: Install dependencies (opensuse)
if: startsWith(matrix.image, 'opensuse')
run: zypper refresh && zypper install -y tar gzip wget rpm-build git gcc-c++ cmake libqt5-qtbase-devel libicu-devel glibc-devel ibus ibus-devel
- name: Install dependencies (fedora)
if: startsWith(matrix.image, 'fedora')
run: dnf clean expire-cache && dnf install -y tar gzip wget rpm-build git gcc-c++ cmake qt5-qtbase-devel libicu-devel glib-devel fcitx5 fcitx5-devel ibus ibus-devel
- uses: actions/checkout@v3
- run: git config --global --add safe.directory $(realpath .)
continue-on-error: true
- run: git fetch --prune --unshallow --tags --force
continue-on-error: true
- name: Set CPACK_GENERATOR to DEB (ubuntu / debian)
if: startsWith(matrix.image, 'ubuntu') || startsWith(matrix.image, 'debian')
run: |
echo "CPACK_GENERATOR=DEB" >> $GITHUB_ENV
- name: Set CPACK_GENERATOR to RPM (opensuse / fedora)
if: startsWith(matrix.image, 'opensuse') || startsWith(matrix.image, 'fedora')
run: |
echo "CPACK_GENERATOR=RPM" >> $GITHUB_ENV
- name: Create artifact version
run: |
VERSION_LATEST_TAG=$(git describe --match "v[0-9]*" --abbrev=0 HEAD | sed "s/v//")
VERSION_TIMESTAMP=$(date +'%Y%m%d%H%M')
VERSION_GIT_HASH=$(git rev-parse --short HEAD)
VERSION=$VERSION_LATEST_TAG+git$VERSION_TIMESTAMP.$VERSION_GIT_HASH
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION"
continue-on-error: true
- name: Create artifact name
run: |
DISTRO_ID=$(grep "^ID=" "/etc/os-release" | sed "s/ID=//" | sed "s/\"//g")
DISTRO_VERSION_ID=$(grep "^VERSION_ID=" "/etc/os-release" | sed "s/VERSION_ID=//" | sed "s/\"//g")
ARTIFACT_NAME=im-emoji-picker-x86_64
ARTIFACT_NAME_WITH_DISTRO=$ARTIFACT_NAME-$DISTRO_ID-$DISTRO_VERSION_ID
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV
echo "ARTIFACT_NAME_WITH_DISTRO=$ARTIFACT_NAME_WITH_DISTRO" >> $GITHUB_ENV
echo "ARTIFACT_NAME_WITH_DISTRO=$ARTIFACT_NAME_WITH_DISTRO"
- name: Package (Fcitx5)
if: startsWith(matrix.image, 'ubuntu') || startsWith(matrix.image, 'debian') || startsWith(matrix.image, 'fedora')
run: |
rm -rf build
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCPACK_GENERATOR=${{env.CPACK_GENERATOR}} -DPACKAGE_VERSION=${{env.VERSION}} -DONLY_FCITX5=1 ..
make -j$(nproc)
make package
- name: Move Fcitx5 .deb artifact
if: startsWith(matrix.image, 'ubuntu') || startsWith(matrix.image, 'debian')
run: |
mv build/*.deb ${{env.ARTIFACT_NAME_WITH_DISTRO}}-fcitx5.deb 2>/dev/null; true
continue-on-error: true
- name: Move Fcitx5 .rpm artifact
if: startsWith(matrix.image, 'opensuse') || startsWith(matrix.image, 'fedora')
run: |
mv build/*.rpm ${{env.ARTIFACT_NAME_WITH_DISTRO}}-fcitx5.rpm 2>/dev/null; true
continue-on-error: true
- name: Package (IBus)
if: startsWith(matrix.image, 'ubuntu') || startsWith(matrix.image, 'debian') || startsWith(matrix.image, 'fedora') || startsWith(matrix.image, 'opensuse')
run: |
rm -rf build
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCPACK_GENERATOR=${{env.CPACK_GENERATOR}} -DPACKAGE_VERSION=${{env.VERSION}} -DONLY_IBUS=1 ..
make -j$(nproc)
make package
- name: Move IBus .deb artifact
if: startsWith(matrix.image, 'ubuntu') || startsWith(matrix.image, 'debian')
run: |
mv build/*.deb ${{env.ARTIFACT_NAME_WITH_DISTRO}}-ibus.deb 2>/dev/null; true
continue-on-error: true
- name: Move IBus .rpm artifact
if: startsWith(matrix.image, 'opensuse') || startsWith(matrix.image, 'fedora')
run: |
mv build/*.rpm ${{env.ARTIFACT_NAME_WITH_DISTRO}}-ibus.rpm 2>/dev/null; true
continue-on-error: true
- name: Upload Fcitx5 artifact .deb (ubuntu / debian)
if: startsWith(matrix.image, 'ubuntu') || startsWith(matrix.image, 'debian')
uses: actions/upload-artifact@v3
with:
name: ${{env.ARTIFACT_NAME_WITH_DISTRO}}-fcitx5.deb
path: ${{env.ARTIFACT_NAME_WITH_DISTRO}}-fcitx5.deb
if-no-files-found: ignore
- name: Upload Fcitx5 artifact .rpm (opensuse / fedora)
if: startsWith(matrix.image, 'opensuse') || startsWith(matrix.image, 'fedora')
uses: actions/upload-artifact@v3
with:
name: ${{env.ARTIFACT_NAME_WITH_DISTRO}}-fcitx5.rpm
path: ${{env.ARTIFACT_NAME_WITH_DISTRO}}-fcitx5.rpm
if-no-files-found: ignore
- name: Upload IBus artifact .deb (ubuntu / debian)
if: startsWith(matrix.image, 'ubuntu') || startsWith(matrix.image, 'debian')
uses: actions/upload-artifact@v3
with:
name: ${{env.ARTIFACT_NAME_WITH_DISTRO}}-ibus.deb
path: ${{env.ARTIFACT_NAME_WITH_DISTRO}}-ibus.deb
if-no-files-found: ignore
- name: Upload IBus artifact .rpm (opensuse / fedora)
if: startsWith(matrix.image, 'opensuse') || startsWith(matrix.image, 'fedora')
uses: actions/upload-artifact@v3
with:
name: ${{env.ARTIFACT_NAME_WITH_DISTRO}}-ibus.rpm
path: ${{env.ARTIFACT_NAME_WITH_DISTRO}}-ibus.rpm
if-no-files-found: ignore
create-nightly-release:
needs: build-artifact
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Download artifacts
id: download_artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Create nightly
id: create_release
uses: ncipollo/release-action@v1.12.0
with:
removeArtifacts: true
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "${{steps.download_artifacts.outputs.download-path}}/*/*"
body: ${{github.event.head_commit.message}}
prerelease: true
makeLatest: false
name: Nightly Release
tag: nightly-build
create-release:
needs: build-artifact
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Download artifacts
id: download_artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Create nightly
id: create_release
uses: ncipollo/release-action@v1.12.0
with:
removeArtifacts: false
allowUpdates: false
artifactErrorsFailBuild: true
artifacts: "${{steps.download_artifacts.outputs.download-path}}/*/*"
generateReleaseNotes: true
prerelease: false
makeLatest: true
name: ${{env.RELEASE_VERSION}}
tag: ${{github.ref}}