Skip to content

Commit cd7f853

Browse files
committed
Add a github action
After `git push --tags`, a new deb and rpm will be published in github release. [AUR](https://aur.archlinux.org/packages/g3kb-switch) will be updated, if AUR_SSH_PRIVATE_KEY have been added to github secret
1 parent 662d7cb commit cd7f853

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: github-actions
5+
directory: /
6+
schedule:
7+
interval: monthly
8+
- package-ecosystem: gitsubmodule
9+
directory: /
10+
schedule:
11+
interval: monthly

.github/workflows/main.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
"on":
3+
push:
4+
paths-ignore:
5+
- "**.md"
6+
pull_request:
7+
paths-ignore:
8+
- "**.md"
9+
workflow_dispatch:
10+
11+
# https://github.com/softprops/action-gh-release/issues/236
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get -y update
23+
sudo apt-get -y install rpm
24+
- name: Build
25+
run: |
26+
cmake -Bbuild
27+
cmake --build build
28+
cmake --build build
29+
# TODO: disable ctest because we haven't add any test
30+
# ctest --test-dir build
31+
cd build
32+
cpack -G DEB
33+
cpack -G RPM
34+
# TODO: disable codecov because we disable ctest
35+
# - uses: codecov/codecov-action@v3
36+
# with:
37+
# gcov: true
38+
- uses: actions/upload-artifact@v3
39+
if: "! startsWith(github.ref, 'refs/tags/')"
40+
with:
41+
path: |
42+
build/*.deb
43+
build/*.rpm
44+
- uses: softprops/action-gh-release@v1
45+
if: startsWith(github.ref, 'refs/tags/')
46+
with:
47+
files: |
48+
build/*.deb
49+
build/*.rpm
50+
51+
deploy-aur:
52+
needs: build
53+
runs-on: ubuntu-latest
54+
if: startsWith(github.ref, 'refs/tags/')
55+
steps:
56+
- uses: Freed-Wu/update-aur-package@v1.0.11
57+
with:
58+
package_name: g3kb-switch
59+
ssh_private_key: ${{secrets.AUR_SSH_PRIVATE_KEY}}

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.20)
22

33
SET(name g3kb-switch)
44
SET(HOMEPAGE_URL https://github.com/lyokha/g3kb-switch)
5+
# get version from git tag in github action
6+
STRING(REGEX MATCH [[[0-9](\.[0-9])*]] VERSION "$ENV{GITHUB_REF_NAME}")
7+
IF(NOT VERSION)
8+
# a fallback
9+
SET(VERSION 0.0.0.0)
10+
ENDIF()
511
PROJECT(${name}
612
LANGUAGES C
713
HOMEPAGE_URL ${HOMEPAGE_URL}
814
DESCRIPTION "CLI keyboard layout switcher for Gnome 3 and 4x"
9-
VERSION 1.3)
15+
VERSION ${VERSION})
1016
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
1117

1218
INCLUDE(GNUInstallDirs)

0 commit comments

Comments
 (0)