Skip to content

Commit e09f1d3

Browse files
Refactored github actions
1 parent 6f01e33 commit e09f1d3

File tree

4 files changed

+67
-74
lines changed

4 files changed

+67
-74
lines changed

.github/workflows/check.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: run build and checks
2+
3+
on: workflow_call
4+
5+
jobs:
6+
check:
7+
name: Build, Run and Analyze fastfetch
8+
runs-on: ubuntu-latest
9+
permissions:
10+
security-events: write
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
language: [ 'cpp' ]
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v2
18+
19+
- name: Update and install packages
20+
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libxfconf-0-dev librpm-dev libzstd-dev
21+
22+
- name: Initialize CodeQL
23+
uses: github/codeql-action/init@v1
24+
with:
25+
languages: ${{ matrix.language }}
26+
27+
- name: Configure
28+
# We reuse the build binary only for the releases.
29+
# We set tweak version to off, because it is wrong, as git tag will happen after this step. Releases don't have a tweak, so this is ok.
30+
run: cmake -DSET_TWEAK=Off .
31+
32+
- name: Build
33+
run: cmake --build . -j$(nproc)
34+
35+
- name: Run fastfetch
36+
run: ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true
37+
38+
- name: Run flashfetch
39+
run: ./flashfetch
40+
41+
- name: Run tests
42+
run: ctest
43+
44+
- name: Build deb package
45+
run: sh packaging/deb/create.sh .
46+
47+
- name: Perform CodeQL Analysis
48+
uses: github/codeql-action/analyze@v1

.github/workflows/pull_request.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: manage pull requests
2+
3+
on: pull_request
4+
5+
jobs:
6+
manage:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: run build and check
10+
uses: ./.github/workflows/check.yml

.github/workflows/push.yml

Lines changed: 5 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,18 @@
1-
name: Manage pushes and pull requests
1+
name: manage pushes
22

33
on:
44
push:
55
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
8-
9-
env:
10-
BUILD_TYPE: Release
116

127
jobs:
13-
check:
14-
name: Build, Run and Analyze fastfetch
15-
runs-on: ubuntu-latest
16-
permissions:
17-
actions: read
18-
contents: write
19-
security-events: write
20-
strategy:
21-
fail-fast: false
22-
matrix:
23-
language: [ 'cpp' ]
24-
steps:
25-
- name: Checkout repository
26-
uses: actions/checkout@v2
27-
28-
- name: Update and install packages
29-
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libxfconf-0-dev librpm-dev libzstd-dev
30-
31-
- name: Initialize CodeQL
32-
uses: github/codeql-action/init@v1
33-
with:
34-
languages: ${{ matrix.language }}
35-
36-
- name: Configure
37-
run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} .
38-
39-
- name: Build
40-
run: cmake --build . -j$(nproc)
41-
42-
- name: Run fastfetch
43-
run: ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true
44-
45-
- name: Run flashfetch
46-
run: ./flashfetch
47-
48-
- name: Run tests
49-
run: ctest
50-
51-
- name: Build deb package
52-
run: sh packaging/deb/create.sh .
53-
54-
- name: Perform CodeQL Analysis
55-
uses: github/codeql-action/analyze@v1
56-
57-
- name: Create tarball
58-
if: github.event_name == 'push'
59-
run: tar -cvf fastfetch.tar ./fastfetch -C packaging/deb ./fastfetch.deb
60-
61-
- name: Upload tarball
62-
if: github.event_name == 'push'
63-
uses: actions/upload-artifact@v3
64-
with:
65-
name: fastfetch.tar
66-
path: ./fastfetch.tar
67-
68-
deploy:
8+
manage:
699
name: Create GitHub release
7010
runs-on: ubuntu-latest
71-
needs: check
72-
if: github.event_name == 'push'
7311
permissions:
7412
contents: write
7513
steps:
76-
- name: Download tarball
77-
uses: actions/download-artifact@v3
78-
with:
79-
name: fastfetch.tar
80-
path: ./fastfetch.tar
81-
82-
- name: Extract tarball
83-
run: tar --overwrite -xvf ./fastfetch.tar/fastfetch.tar
14+
- name: run build and check
15+
uses: ./.github/workflows/check.yml
8416

8517
- name: Get fastfetch version
8618
id: get_version_fastfetch
@@ -98,4 +30,4 @@ jobs:
9830
with:
9931
tag: ${{ steps.get_version_fastfetch.outputs.release }}
10032
commit: ${{ github.sha }}
101-
artifacts: ./fastfetch,./fastfetch.deb
33+
artifacts: ./fastfetch,./packaging/deb/fastfetch.deb

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ project(fastfetch
55
LANGUAGES C
66
)
77

8+
# This is used by github actions for release builds
9+
OPTION(SET_TWEAK "Add tweak to project version" ON)
10+
811
# Track commits between version bumps for output in --version
912
# Ignored by --version-raw and github actions
10-
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
13+
if (SET_TWEAK AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
1114
execute_process(
1215
COMMAND git describe --tags
1316
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"

0 commit comments

Comments
 (0)