diff --git a/.github/workflows/packages.yaml b/.github/workflows/packages.yaml index 110beba98..a071f1c80 100644 --- a/.github/workflows/packages.yaml +++ b/.github/workflows/packages.yaml @@ -6,152 +6,89 @@ on: release: types: [released, prereleased] workflow_dispatch: + jobs: - deb: - runs-on: ubuntu-18.04 + binary: + strategy: + matrix: + include: + - {pkg: "deb", os: "ubuntu-18.04", asset: "dvc_${{ github.event.release.tag_name }}_amd64.deb"} + - {pkg: "rpm", os: "ubuntu-18.04", asset: "dvc-${{ github.event.release.tag_name }}-1.x86_64.rpm"} + - {pkg: "osxpkg", os: "macos-10.15", asset: "dvc-${{ github.event.release.tag_name }}.pkg"} + - {pkg: "exe", os: "windows-2019", asset: "dvc-${{ github.event.release.tag_name }}.exe"} + + name: ${{ matrix.pkg }} + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Set up Python 3.9 uses: actions/setup-python@v4 with: python-version: 3.9 + cache: pip + cache-dependency-path: | + setup.cfg + scripts/build-requirements.txt + - name: Set up Ruby 2.6 uses: ruby/setup-ruby@v1 with: ruby-version: '2.6' + - name: Install deps run: | + pip install -U wheel pip setuptools pip install .[all] pip install -r scripts/build-requirements.txt gem install --no-document fpm - - name: Build deb - run: python scripts/build.py deb - - name: Publish deb - if: github.event_name == 'release' - uses: actions/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: scripts/fpm/dvc_${{ github.event.release.tag_name }}_amd64.deb - asset_name: dvc_${{ github.event.release.tag_name }}_amd64.deb - asset_content_type: binary/octet-stream - rpm: - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - name: Set up Ruby 2.4 - uses: actions/setup-ruby@v1.1.3 - with: - ruby-version: 2.4 - - name: Install deps - run: | - pip install .[all] - pip install -r scripts/build-requirements.txt - gem install --no-document fpm - - name: Build rpm - run: python scripts/build.py rpm - - name: Publish rpm - if: github.event_name == 'release' - uses: actions/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: scripts/fpm/dvc-${{ github.event.release.tag_name }}-1.x86_64.rpm - asset_name: dvc-${{ github.event.release.tag_name }}-1.x86_64.rpm - asset_content_type: binary/octet-stream - osxpkg: - runs-on: macos-10.15 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - name: Set up Ruby 2.4 - uses: actions/setup-ruby@v1.1.3 - with: - ruby-version: 2.4 - - name: Install deps - run: | - # available lxml (webdav dependency) wheels are built with an old - # SDK, which breaks osxpkg notarization. Building from scratch - # instead. - pip install .[all] --no-binary lxml - pip install -r scripts/build-requirements.txt - gem install --no-document fpm - - name: Build - run: python scripts/build.py osxpkg - - name: Publish - if: github.event_name == 'release' - uses: actions/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: scripts/fpm/dvc-${{ github.event.release.tag_name }}.pkg - asset_name: dvc-${{ github.event.release.tag_name }}.pkg - asset_content_type: binary/octet-stream - exe: - runs-on: windows-2019 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - name: Install deps - run: | - pip install .[all] - pip install -r scripts/build-requirements.txt + - name: Pull images - run: | - dvc pull - - name: Build - run: python scripts\build.py exe - shell: cmd - - name: Publish + run: dvc pull + + - name: Build ${{ matrix.pkg }} + run: python scripts/build.py ${{ matrix.pkg }} + + - name: Publish ${{ matrix.pkg }} if: github.event_name == 'release' + uses: actions/upload-release-asset@v1.0.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: actions/upload-release-asset@v1.0.2 with: upload_url: ${{ github.event.release.upload_url }} - asset_path: scripts/innosetup/dvc-${{ github.event.release.tag_name }}.exe - asset_name: dvc-${{ github.event.release.tag_name }}.exe + asset_path: scripts/${{ matrix.pkg == 'exe' && 'innosetup' || 'fpm' }}/${{ matrix.asset }} + asset_name: ${{ matrix.asset }} asset_content_type: binary/octet-stream + pip: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Set up Python 3.8 uses: actions/setup-python@v4 with: python-version: 3.8 + cache: pip + cache-dependency-path: setup.cfg + - name: Install - run: pip install ".[all,tests]" + run: | + pip install -U wheel pip build setuptools + pip install ".[all,tests]" + - name: Build packages run: | pip install -U pip ./scripts/build_package.sh + - name: Publish packages to PyPI if: github.event_name == 'release' - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.PYPI_TOKEN }} diff --git a/scripts/build.py b/scripts/build.py index d4aaa81f8..a53738d72 100644 --- a/scripts/build.py +++ b/scripts/build.py @@ -1,5 +1,5 @@ import argparse -import importlib +import importlib.util import pathlib import textwrap from subprocess import STDOUT, check_call