Skip to content

Commit

Permalink
RPMs.
Browse files Browse the repository at this point in the history
  • Loading branch information
emeryberger committed Oct 27, 2024
1 parent 8d29886 commit 5ffc1de
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
33 changes: 31 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
include:
- os: ubuntu-latest
binary_name: sqlwrite-linux.deb
- os: ubuntu-latest
binary_name: sqlwrite-linux.rpm
- os: macos-latest
binary_name: sqlwrite-mac.pkg

Expand All @@ -26,15 +28,19 @@ jobs:
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt-get update
sudo apt-get install -y make curl libcurl4-openssl-dev dpkg-dev
sudo apt-get install -y make curl libcurl4-openssl-dev dpkg-dev rpm
fi
- name: Build with Make
run: make

- name: Package as .deb on Linux
if: matrix.os == 'ubuntu-latest'
run: make linux-package
run: make deb-package

- name: Package as .rpm on Linux
if: matrix.os == 'ubuntu-latest'
run: make rpm-package

- name: Package as .pkg on macOS
if: matrix.os == 'macos-latest'
Expand All @@ -47,6 +53,13 @@ jobs:
name: sqlwrite-linux.deb
path: sqlwrite-linux.deb

- name: Upload Linux .rpm as artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: sqlwrite-linux.rpm
path: sqlwrite-linux.rpm

- name: Upload macOS pkg as artifact
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v3
Expand All @@ -68,6 +81,12 @@ jobs:
name: sqlwrite-linux.deb
path: .

- name: Download Linux .rpm artifact
uses: actions/download-artifact@v3
with:
name: sqlwrite-linux.rpm
path: .

- name: Download macOS pkg artifact
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -101,6 +120,16 @@ jobs:
asset_name: sqlwrite-linux.deb
asset_content_type: application/vnd.debian.binary-package

- name: Upload Linux .rpm to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./sqlwrite-linux.rpm
asset_name: sqlwrite-linux.rpm
asset_content_type: application/x-rpm

- name: Upload macOS pkg to release
uses: actions/upload-release-asset@v1
env:
Expand Down
32 changes: 31 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ pkg: sqlwrite-bin
endif

# Packaging for Linux systems
linux-package: sqlwrite-bin

linux-package: deb-package rpm-package

deb-package: sqlwrite-bin
# Create the package directory structure
mkdir -p pkg_root/usr/local/bin
mkdir -p pkg_root/usr/local/lib
Expand All @@ -71,6 +74,33 @@ linux-package: sqlwrite-bin
echo "Description: Sqlwrite command-line tool" >> pkg_root/DEBIAN/control
dpkg-deb --build pkg_root sqlwrite-linux.deb

rpm-package:
mkdir -p rpm_root/usr/local/bin
mkdir -p rpm_root/usr/local/lib
cp sqlwrite-bin rpm_root/usr/local/bin
cp $(LIBFILE) rpm_root/usr/local/lib
cp $(SQLITE_LIB) rpm_root/usr/local/lib

mkdir -p rpm_root/BUILD rpm_root/RPMS rpm_root/SOURCES rpm_root/SPECS rpm_root/SRPMS
mkdir -p rpm_root/SPECS
echo "%define _topdir $(shell pwd)/rpm_root" > rpm_root/SPECS/sqlwrite.spec
echo "Name: sqlwrite" >> rpm_root/SPECS/sqlwrite.spec
echo "Version: 1.0" >> rpm_root/SPECS/sqlwrite.spec
echo "Release: 1" >> rpm_root/SPECS/sqlwrite.spec
echo "Summary: Sqlwrite command-line tool" >> rpm_root/SPECS/sqlwrite.spec
echo "License: Apache-2.0" >> rpm_root/SPECS/sqlwrite.spec
echo "Group: Development/Tools" >> rpm_root/SPECS/sqlwrite.spec
echo "BuildArch: $(shell uname -m)" >> rpm_root/SPECS/sqlwrite.spec
echo "%description" >> rpm_root/SPECS/sqlwrite.spec
echo "Sqlwrite command-line tool for SQL tasks." >> rpm_root/SPECS/sqlwrite.spec
echo "%files" >> rpm_root/SPECS/sqlwrite.spec
echo "/usr/local/bin/sqlwrite-bin" >> rpm_root/SPECS/sqlwrite.spec
echo "/usr/local/lib/$(LIBFILE)" >> rpm_root/SPECS/sqlwrite.spec
echo "/usr/local/lib/$(SQLITE_LIB)" >> rpm_root/SPECS/sqlwrite.spec

rpmbuild -bb rpm_root/SPECS/sqlwrite.spec --buildroot $(shell pwd)/rpm_root
cp rpm_root/RPMS/*/sqlwrite-1.0-1.*.rpm sqlwrite-linux.rpm


clean:
rm -rf sqlwrite-mac.pkg sqlwrite-linux.deb sqlwrite-bin $(LIBFILE) $(SQLITE_LIB)
Expand Down

0 comments on commit 5ffc1de

Please sign in to comment.