diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml deleted file mode 100755 index 167d70e..0000000 --- a/.github/workflows/python-test.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Python test - -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: - build: - 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 - - name: Create Release Bundle - if: startsWith(github.ref, 'refs/tags/') - run: | - ./build.sh - - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - fail_on_unmatched_files: true - generate_release_notes: true - files: | - dist/*.tar.gz diff --git a/.github/workflows/test_and_release.yml b/.github/workflows/test_and_release.yml new file mode 100755 index 0000000..4f29edd --- /dev/null +++ b/.github/workflows/test_and_release.yml @@ -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 "action@github.com" + 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 diff --git a/.gitignore b/.gitignore index 82f9275..cef5098 100644 --- a/.gitignore +++ b/.gitignore @@ -37,7 +37,6 @@ pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports -htmlcov/ .tox/ .nox/ .coverage diff --git a/README.md b/README.md index c5861ee..8ca4f06 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build.sh b/build.sh index aef768b..4382df5 100755 --- a/build.sh +++ b/build.sh @@ -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 ./* \ No newline at end of file +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" diff --git a/debian/DEBIAN/control b/debian/DEBIAN/control new file mode 100644 index 0000000..99152b5 --- /dev/null +++ b/debian/DEBIAN/control @@ -0,0 +1,7 @@ +Package: packaging-tools +Version: 1.5.0 +Architecture: all +Maintainer: Ferenc Nandor Janky & Attila Gombos +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