Skip to content

Commit

Permalink
build(ci): use GITHUB_RUN_NUMBER for package versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
jolla committed Dec 27, 2024
1 parent fff70e4 commit 4eb3b15
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,32 @@ jobs:
runs-on: ubuntu-latest

steps:
# Checkout repository
# 1) Checkout repository
- name: Checkout code
uses: actions/checkout@v3

# Set up dependencies
# 2) Set up dependencies
- name: Install required packages
run: |
sudo apt-get update
sudo apt-get install -y build-essential debhelper devscripts lintian
# Generate version number
# 3) Generate version number using GITHUB_RUN_NUMBER
- name: Increment version number
id: version
run: |
# Extract the current version from changelog or default to 1.0.0
# Read the base version from changelog (if present) or default to 1.0.0
if [ -f "debian/changelog" ]; then
BASE_VERSION=$(dpkg-parsechangelog --show-field Version | cut -d'-' -f1)
else
BASE_VERSION="1.0.0"
fi
# Increment the version intelligently
# Extract major, minor, and patch numbers
# Split the base version into MAJOR and MINOR (ignore patch)
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
PATCH=$((PATCH + 1)) # Increment patch version
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
# Incorporate the GitHub Actions run number as the new patch version
NEW_VERSION="${MAJOR}.${MINOR}.${GITHUB_RUN_NUMBER}"
# Update the changelog with the new version
export DEBFULLNAME="GitHub Actions"
Expand All @@ -49,14 +49,14 @@ jobs:
# Output the new version number for later steps
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
# Build the package
# 4) Build the package
- name: Build Debian package
run: |
dpkg-buildpackage -us -uc -b -d
mkdir -p build
mv ../*.deb build/
# Upload artifact
# 5) Upload artifact
- name: Upload Debian package
uses: actions/upload-artifact@v3
with:
Expand Down

0 comments on commit 4eb3b15

Please sign in to comment.