diff --git a/.github/workflows/build_assets.yml b/.github/workflows/build_assets.yml new file mode 100644 index 00000000..07ca8a4b --- /dev/null +++ b/.github/workflows/build_assets.yml @@ -0,0 +1,85 @@ +name: Build Compiled Assets + +on: + workflow_call: + inputs: + release: + type: boolean + default: false + description: "Attach artifacts to a release" + +jobs: + build_assets: + name: Build packages + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + include: + - os: macos-latest + env: + CFLAGS: '-arch arm64 -arch x86_64' + TARGET: macos + CMD_REQS: > + mkdir -p pip-packages && cd pip-packages && pip wheel --no-cache-dir -r ../requirements.txt && cd .. + pip install --no-deps --no-index --find-links=pip-packages pip-packages/* + CMD_BUILD: > + STATICCODECOV_LIB_PATH=$(find build/ -maxdepth 1 -type d -name 'lib.*' -print -quit | xargs -I {} sh -c "find {} -type f -name 'staticcodecov*' -print -quit | sed 's|^./||'") && + pyinstaller --add-binary ${STATICCODECOV_LIB_PATH}:. --hidden-import staticcodecov_languages -F codecov_cli/main.py && + mv dist/main dist/codecovcli_macos && + lipo -archs dist/codecovcli_macos | grep -v 'x86_64 arm65' >> /dev/null && exit 1 + OUT_FILE_NAME: codecovcli_macos + ASSET_MIME: application/octet-stream + - os: ubuntu-20.04 + TARGET: ubuntu + CMD_REQS: > + pip install -r requirements.txt + CMD_BUILD: > + STATICCODECOV_LIB_PATH=$(find build/ -maxdepth 1 -type d -name 'lib.*' -print -quit | xargs -I {} sh -c "find {} -type f -name 'staticcodecov*' -print -quit | sed 's|^./||'") && + pyinstaller --add-binary ${STATICCODECOV_LIB_PATH}:. --hidden-import staticcodecov_languages -F codecov_cli/main.py && + cp ./dist/main ./dist/codecovcli_linux + OUT_FILE_NAME: codecovcli_linux + ASSET_MIME: application/octet-stream + - os: windows-latest + TARGET: windows + CMD_REQS: > + pip install -r requirements.txt + CMD_BUILD: > + pyinstaller --add-binary "build\lib.win-amd64-cpython-310\staticcodecov_languages.cp310-win_amd64.pyd;." --hidden-import staticcodecov_languages -F codecov_cli\main.py && + Copy-Item -Path ".\dist\main.exe" -Destination ".\dist\codecovcli_windows.exe" + OUT_FILE_NAME: codecovcli_windows.exe + ASSET_MIME: application/vnd.microsoft.portable-executable + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: "3.11" + - name: Install dependencies + run: | + ${{matrix.CMD_REQS}} + python setup.py build + - name: Install pyinstaller + run: pip install pyinstaller + - name: Build with pyinstaller for ${{matrix.TARGET}} + run: ${{matrix.CMD_BUILD}} + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.3 + if: inputs.release == false + with: + path: ./dist/${{ matrix.OUT_FILE_NAME }} + - name: Upload Release Asset + if: inputs.release == true + id: upload-release-asset + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./dist/${{ matrix.OUT_FILE_NAME }} + asset_name: ${{ matrix.OUT_FILE_NAME }} + tag: ${{ github.ref }} + overwrite: true + + + diff --git a/.github/workflows/build_for_pypi.yml b/.github/workflows/build_for_pypi.yml new file mode 100644 index 00000000..05d9793e --- /dev/null +++ b/.github/workflows/build_for_pypi.yml @@ -0,0 +1,41 @@ +name: Build and Optionally Publish to PyPi + +on: + workflow_call: + inputs: + publish: + type: boolean + default: false + description: "Publish to PyPi" + +jobs: + build_for_pypi: + runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: Install dependencies + run: | + pip install -r requirements.txt + python setup.py build + python setup.py develop + - name: Build distributions for different platforms + run: | + pip install wheel + python setup.py sdist bdist_wheel --plat-name=manylinux2014_x86_64 + python setup.py bdist_wheel --plat-name=macosx-12.6-x86_64 + python setup.py bdist_wheel --plat-name=win_amd64 + - name: Publish package to PyPi + if: inputs.publish == true + uses: pypa/gh-action-pypi-publish@release/v1 + + + diff --git a/.github/workflows/build_main.yml b/.github/workflows/build_main.yml new file mode 100644 index 00000000..a5b4a713 --- /dev/null +++ b/.github/workflows/build_main.yml @@ -0,0 +1,18 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Build + +on: + push: + branches: + - main + - feature/main-builds + +jobs: + build_and_publish_to_pipy: + uses: ./.github/workflows/build_for_pypi.yml + secrets: inherit + build_assets: + uses: ./.github/workflows/build_assets.yml + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/push_flow.yml b/.github/workflows/ci.yml similarity index 89% rename from .github/workflows/push_flow.yml rename to .github/workflows/ci.yml index 9f2eaba9..d6006669 100644 --- a/.github/workflows/push_flow.yml +++ b/.github/workflows/ci.yml @@ -1,15 +1,19 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Build-Test-Upload +name: CLI CI -on: [push] # Run on any push event +on: + pull_request: + push: + branches: + - main jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - name: Install dependencies @@ -26,6 +30,10 @@ jobs: codecov-startup: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 2 - uses: actions/setup-python@v3 - name: Install CLI run: | @@ -49,7 +57,7 @@ jobs: - python-version: "3.9" - python-version: "3.8" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true fetch-depth: 2 @@ -66,7 +74,7 @@ jobs: - name: Test with pytest run: | pytest --cov - - name: Dogfooding codecov-cli. Use codecov-cli to upload to codecov (new upload endpoint) + - name: Dogfooding codecov-cli run: | codecovcli do-upload --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} @@ -74,6 +82,10 @@ jobs: runs-on: ubuntu-latest needs: codecov-startup steps: + - uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 2 - uses: actions/setup-python@v3 - name: Install CLI run: | @@ -90,7 +102,7 @@ jobs: runs-on: ubuntu-latest needs: static-analysis steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true fetch-depth: 0 diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 1ba580cd..d8c78774 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -10,7 +10,7 @@ jobs: create-release: name: Tag Release ${{ github.head_ref }} if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') && github.repository_owner == 'codecov' }} - uses: codecov/gha-workflows/.github/workflows/create-release.yml@v1.2.1 + uses: codecov/gha-workflows/.github/workflows/create-release.yml@v1.2.2 secrets: inherit release: diff --git a/.github/workflows/create_release_pr.yml b/.github/workflows/create_release_pr.yml index a765b8c4..a962be85 100644 --- a/.github/workflows/create_release_pr.yml +++ b/.github/workflows/create_release_pr.yml @@ -9,6 +9,41 @@ on: jobs: create-release-pr: - name: Create PR for Release ${{ github.event.inputs.versionName }} - uses: codecov/gha-workflows/.github/workflows/create-release-pr.yml@v1.2.1 - secrets: inherit \ No newline at end of file + name: Create PR + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Import GPG key + id: import-gpg + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.RELEASER_GPG_PRIVATE_KEY }} + git_user_signingkey: true + git_commit_gpgsign: true + git_config_global: true + + - name: Create release branch + run: git checkout -b release/${{ github.event.inputs.versionName }} + + - name: Update version and push + id: make-commit + run: | + sed -i 's/version="[0-9]\.[0-9]\.[0-9]"/version="${{ github.event.inputs.versionName }}"/g' setup.py + git add setup.py + git commit -S --message "Prepare release ${{ github.event.inputs.versionName }}" + echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + git push origin release/${{ github.event.inputs.versionName }} + + - name: Create pull request into main + uses: thomaseizinger/create-pull-request@1.3.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + head: release/${{ github.event.inputs.versionName }} + base: main + title: Release ${{ github.event.inputs.versionName }} + reviewers: ${{ github.event.issue.user.login }} + body: | + Release PR for ${{ github.event.inputs.versionName }} + I've updated the version name and committed: ${{ steps.make-commit.outputs.commit }}. \ No newline at end of file diff --git a/.github/workflows/release_flow.yml b/.github/workflows/release_flow.yml index 64d65638..ad6891c8 100644 --- a/.github/workflows/release_flow.yml +++ b/.github/workflows/release_flow.yml @@ -1,110 +1,34 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Build-and-Release +name: Build and Publish CLI Release on: workflow_call: release: - types: created + types: + - created jobs: - build_and_publish_to_pipy: - runs-on: ubuntu-latest + build_and_publish_to_pypi: permissions: id-token: write # This is required for requesting the JWT contents: read # This is required for actions/checkout - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Set up Python 3.11 - uses: actions/setup-python@v4 - with: - python-version: "3.11" - - name: Install dependencies - run: | - pip install -r requirements.txt - python setup.py build - python setup.py develop - - name: Build distributions for different platforms - run: | - pip install wheel - python setup.py sdist bdist_wheel --plat-name=manylinux2014_x86_64 - python setup.py bdist_wheel --plat-name=macosx-12.6-x86_64 - python setup.py bdist_wheel --plat-name=win_amd64 - - name: Publish package to PyPi - uses: pypa/gh-action-pypi-publish@release/v1 + uses: ./.github/workflows/build_for_pypi.yml + with: + publish: true + secrets: inherit buildassets: name: Build packages - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - include: - - os: macos-latest - env: - CFLAGS: '-arch arm64 -arch x86_64' - TARGET: macos - CMD_REQS: > - mkdir -p pip-packages && cd pip-packages && pip wheel --no-cache-dir -r ../requirements.txt && cd .. - pip install --no-deps --no-index --find-links=pip-packages pip-packages/* - CMD_BUILD: > - STATICCODECOV_LIB_PATH=$(find build/ -maxdepth 1 -type d -name 'lib.*' -print -quit | xargs -I {} sh -c "find {} -type f -name 'staticcodecov*' -print -quit | sed 's|^./||'") && - pyinstaller --add-binary ${STATICCODECOV_LIB_PATH}:. --hidden-import staticcodecov_languages -F codecov_cli/main.py && - mv dist/main dist/codecovcli_macos && - lipo -archs dist/codecovcli_macos | grep -v 'x86_64 arm65' >> /dev/null && exit 1 - OUT_FILE_NAME: codecovcli_macos - ASSET_MIME: application/octet-stream - - os: ubuntu-20.04 - TARGET: ubuntu - CMD_REQS: > - pip install -r requirements.txt - CMD_BUILD: > - STATICCODECOV_LIB_PATH=$(find build/ -maxdepth 1 -type d -name 'lib.*' -print -quit | xargs -I {} sh -c "find {} -type f -name 'staticcodecov*' -print -quit | sed 's|^./||'") && - pyinstaller --add-binary ${STATICCODECOV_LIB_PATH}:. --hidden-import staticcodecov_languages -F codecov_cli/main.py && - cp ./dist/main ./dist/codecovcli_linux - OUT_FILE_NAME: codecovcli_linux - ASSET_MIME: application/octet-stream - - os: windows-latest - TARGET: windows - CMD_REQS: > - pip install -r requirements.txt - CMD_BUILD: > - pyinstaller --add-binary "build\lib.win-amd64-cpython-310\staticcodecov_languages.cp310-win_amd64.pyd;." --hidden-import staticcodecov_languages -F codecov_cli\main.py && - Copy-Item -Path ".\dist\main.exe" -Destination ".\dist\codecovcli_windows.exe" - OUT_FILE_NAME: codecovcli_windows.exe - ASSET_MIME: application/vnd.microsoft.portable-executable - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Set up Python 3.11 - uses: actions/setup-python@v3 - with: - python-version: "3.11" - - name: Install dependencies - run: | - ${{matrix.CMD_REQS}} - python setup.py build - - name: Install pyinstaller - run: pip install pyinstaller - - name: Build with pyinstaller for ${{matrix.TARGET}} - run: ${{matrix.CMD_BUILD}} - - name: Upload Release Asset - id: upload-release-asset - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ./dist/${{ matrix.OUT_FILE_NAME }} - asset_name: ${{ matrix.OUT_FILE_NAME }} - tag: ${{ github.ref }} - overwrite: true + uses: ./.github/workflows/build_assets.yml + with: + release: true + secrets: inherit publish_release: name: Publish release - needs: [buildassets, build_and_publish_to_pipy] + needs: [buildassets, build_and_publish_to_pypi] runs-on: ubuntu-latest permissions: contents: 'read' diff --git a/codecov_cli/__init__.py b/codecov_cli/__init__.py index 66811369..9063141a 100644 --- a/codecov_cli/__init__.py +++ b/codecov_cli/__init__.py @@ -1,4 +1,3 @@ import importlib.metadata - -__version__ = importlib.metadata.version('codecov-cli') +__version__ = importlib.metadata.version("codecov-cli") diff --git a/setup.py b/setup.py index 6d2ff51a..7c05c4fd 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ -from platform import system from os import path +from platform import system from setuptools import Extension, find_packages, setup @@ -10,7 +10,7 @@ setup( name="codecov-cli", - version='0.3.7', + version="0.4.1", packages=find_packages(exclude=["contrib", "docs", "tests*"]), description="Codecov Command Line Interface", long_description=long_description,