-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (88 loc) · 3.07 KB
/
ci.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
name: CI/CD Pipeline for Gitload
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/
~/.config/
key: ${{ runner.os }}-cache-${{ hashFiles('.github/workflows/ci.yml') }}
restore-keys: |
${{ runner.os }}-cache-
- name: Set up environment
run: |
sudo apt-get update
sudo apt-get install -y build-essential
- name: Update version
id: update_version
run: |
# Path to the control file
CONTROL_FILE="DEBIAN/control"
# Extract the current version
CURRENT_VERSION=$(grep -m1 '^Version:' "$CONTROL_FILE" | awk '{print $2}')
# Split the version into major, minor, and patch
IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION"
# Increment the patch version
VERSION_PARTS[2]=$((VERSION_PARTS[2] + 1))
# Join the version parts back together
NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
# Update the control file with the new version
sed -i "s/^Version: .*/Version: $NEW_VERSION/" "$CONTROL_FILE"
echo "Updated version: $NEW_VERSION"
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Commit changes
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_TOKEN }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add DEBIAN/control
git commit -m "Update version in DEBIAN/control"
git push origin main
- name: Build Debian package
run: |
cd ${GITHUB_WORKSPACE}
cd ..
dpkg-deb --build gitload
mv gitload.deb gitload_${{ env.NEW_VERSION }}.deb
- name: Move .deb files
run: |
mv ../*.deb ./
- name: Upload Debian package as artifact
uses: actions/upload-artifact@v4
with:
name: gitload-package
path: ./*.deb
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: gitload-package
- name: Extract version from .deb filename
id: extract_version
run: |
DEB_FILE=$(ls *.deb)
VERSION=$(echo $DEB_FILE | grep -oP '(?<=_)[^_]+(?=\.deb)')
echo "EXTRACTED_VERSION=$VERSION" >> $GITHUB_ENV
echo "Extracted version: $VERSION"
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: "./*.deb"
tag_name: "v${{ env.EXTRACTED_VERSION }}"
name: "Release v${{ env.EXTRACTED_VERSION }}"
body: "Automatically generated release from GitHub Actions CI/CD pipeline"
draft: false
prerelease: false