Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Debian package #12

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions .github/workflows/python-test.yml

This file was deleted.

110 changes: 110 additions & 0 deletions .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Test and Release

on:
push:
branches: main
tags: v*.*.*

pull_request:
branches: [ "main" ]
types:
- synchronize
- opened
- reopened

concurrency:
group: ${{ github.workflow }}-${{ github.sha }}
cancel-in-progress: true

jobs:
test:
name: Build and test

runs-on: ubuntu-latest

permissions:
contents: write
discussions: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Python dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-pip python3-virtualenv python3-all
pip install wheel stdeb

- name: Install fpm dependencies
run: |
sudo apt-get install -y ruby ruby-dev rubygems build-essential
sudo gem install -N fpm

- name: Install dh-virtualenv dependencies
run: |
sudo apt-get install -y debhelper devscripts equivs dh-virtualenv dh-python

- name: Verify code quality
run: |
cd python
pip install mypy flake8 pytest
mypy
flake8
pytest

release:
if: startsWith(github.ref, 'refs/tags/')
needs: test

name: Publish and release

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

- name: Set up version
run: |
VERSION_REGEX="^[0-9]+\.[0-9]+\.[0-9]+$"
if [[ "${GITHUB_REF#refs/tags/v}" =~ $VERSION_REGEX ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
else
echo "Error: Invalid version"
exit 1
fi

- name: Update version in control file
run: |
sed -i "s/^Version: .*/Version: $VERSION/" debian/DEBIAN/control

- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git diff --exit-code || git commit -am "Update version to $VERSION"

- name: Create Release Bundle
run: |
./build.sh

- name: Push changes
uses: ad-m/github-push-action@master
if: ${{ success() }}
with:
github_token: ${{ github.token }}

- name: Publish distributions
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: |
dist/*.tar.gz
dist/*.deb
if-no-files-found: error

- name: Release
uses: EffectiveRange/version-release-github-action@v1
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

[![Test and Release](https://github.com/EffectiveRange/packaging-tools/actions/workflows/test_and_release.yml/badge.svg)](https://github.com/EffectiveRange/packaging-tools/actions/workflows/test_and_release.yml)

# packaging-tools

Tools for packaging libraries and applications

## Python
Expand Down
30 changes: 20 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
#!/bin/bash
cd $(dirname $0)
#!/bin/bash -ex

SCRIPTS_DIR=$(dirname "$0")
ABSOLUTE_SCRIPTS_DIR=$(cd "$SCRIPTS_DIR" && pwd)

cd "$ABSOLUTE_SCRIPTS_DIR"
rm -rf dist
mkdir dist

IGNORE_EXT="cfg|md"

for stacks in $(find . -maxdepth 1 -type d ! -name '.*' ! -name 'dist')
find "$ABSOLUTE_SCRIPTS_DIR" -maxdepth 2 -name "pack_*" | while read -r script_path
do
for files in $(find $stacks -maxdepth 1 -type f | grep -vE "\.($IGNORE_EXT)$")
do
cp -v $files dist/
done
script_name=$(basename "$script_path")
cp -v "$script_path" "dist/$script_name"
done

cd dist
tar -cvzf packaging-tools.tar.gz ./*
tar -cvzf packaging-tools.tar.gz ./*

cd "$ABSOLUTE_SCRIPTS_DIR"
rm -rf debian/usr/local/bin
mkdir -p debian/usr/local/bin

cp -v dist/pack_* debian/usr/local/bin

VERSION="$(grep Version: debian/DEBIAN/control | cut -d' ' -f2)"

dpkg-deb -Zxz --root-owner-group --build debian "dist/packaging-tools_$VERSION-1_all.deb"
7 changes: 7 additions & 0 deletions debian/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Package: packaging-tools
Version: 1.5.0
Architecture: all
Maintainer: Ferenc Nandor Janky & Attila Gombos <[email protected]>
Homepage: www.effective-range.com
Description: Tools for packaging libraries and applications.
Depends: cmake, python3, python3-pip, python3-wheel, ruby, ruby-dev, rubygems, build-essential, debhelper, devscripts, equivs, dh-virtualenv, dh-python, python3-virtualenv, python3-all, python3-stdeb