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

Fix release workflow and some CI improvements #350

Merged
merged 12 commits into from
Nov 4, 2024
11 changes: 7 additions & 4 deletions .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
# For testing purposes only static libraries are built to reduce run time.
# In release workflow all combinations are build.
options: [
{container: dockcross/linux-x64, target: linux-x64},
{container: dockcross/linux-x86, target: linux-x86},
{container: dockcross/linux-armv6-lts, target: linux-armv6},
]
library: ${{ fromJSON(inputs.libraries) }}
type: [shared, static]
type: [static]

container:
image: ${{ matrix.options.container }}
Expand All @@ -150,7 +152,7 @@ jobs:
run: |
GITHUB_WORKSPACE=$(pwd)

if [ "${{ matrix.type }}" = "shared" ]; then
if [ "${{ matrix.type }}" == "shared" ]; then
BUILD_SHARED_LIBS=ON
else
BUILD_SHARED_LIBS=OFF
Expand All @@ -172,14 +174,15 @@ jobs:
path: artifacts/${{ matrix.library }}_${{ matrix.type }}_${{ matrix.options.target }}.zip

python:
needs: [build]
needs: [tests, examples]
uses: ./.github/workflows/ci_wheels.yml
secrets: inherit
with:
os: ubuntu-22.04

rust:
runs-on: ${{ matrix.os }}
needs: [build]
needs: [tests, examples]

strategy:
fail-fast: false
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/ci_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
type: [shared, static]
# For testing purposes only static libraries are built to reduce run time.
# In release workflow all combinations are build.
type: [static]
arch: [arm64, x86_64]

steps:
Expand All @@ -55,7 +57,7 @@ jobs:
- name: Compile SimpleBLE
run: |

if [ "${{ matrix.type }}" = "shared" ]; then
if [ "${{ matrix.type }}" == "shared" ]; then
BUILD_SHARED_LIBS=ON
else
BUILD_SHARED_LIBS=OFF
Expand All @@ -75,14 +77,15 @@ jobs:
path: artifacts/simpleble_${{ matrix.type }}_macos-${{ matrix.arch }}.zip

python:
needs: [build]
needs: [tests, examples]
uses: ./.github/workflows/ci_wheels.yml
secrets: inherit
with:
os: macos-12

rust:
runs-on: ${{ matrix.os }}
needs: [build]
needs: [tests, examples]

strategy:
fail-fast: false
Expand Down
89 changes: 36 additions & 53 deletions .github/workflows/ci_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
# (For example when pushing a commit to an open pull request)
# See: https://github.com/fkirc/skip-duplicate-actions?tab=readme-ov-file#skip-concurrent-workflow-runs
pre_job:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
Expand All @@ -27,13 +27,21 @@ jobs:
with:
concurrent_skipping: 'same_content_newer'
skip_after_successful_duplicate: 'true'
- name: Clone Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Perform version check
run: |
./scripts/check_version.sh

# This job detects changes in the diff and set some ouput variables accordingly.
# It is use to conditionaly run different jobs and steps of the pipeline
changes:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
permissions:
pull-requests: read
outputs:
Expand All @@ -44,7 +52,7 @@ jobs:
python: ${{ steps.filter.outputs.python }}
rust: ${{ steps.filter.outputs.rust }}
docs: ${{ steps.filter.outputs.docs }}
ci: ${{ steps.filter.outputs.ci }}
miscs: ${{ steps.filter.outputs.miscs }}
changes: ${{ steps.filter.outputs.changes }}
steps:
- name: Clone Repository
Expand All @@ -55,49 +63,43 @@ jobs:
with:
list-files: shell
filters: |
ci: &ci
miscs:
- '.github/workflows/**'
- '.github/actions/**'
common: &common
- 'examples/simpleble/**'
- 'cmake/**'
common: &common
- 'simpleble/include/**'
- 'simpleble/src/builders/**'
- 'simpleble/src/external/**'
- 'simpleble/src/frontends/**'
- 'simpleble/src/backends/common/**'
- 'external/**'
- 'cmake/**'
windows: &windows
- *ci
- *common
- 'simpleble/src/backends/windows/**'
linux: &linux
- *ci
- *common
- 'simpleble/src/backends/linux/**'
- 'simpledbus/**'
- 'examples/simpledbus/**'
- 'simplebluez/**'
- 'examples/simplebluez/**'
macos: &macos
- *ci
- *common
- 'simpleble/src/backends/macos/**'
python:
- *ci
- 'simpleble/src/backends/plain/**'
- 'simpleble/src/frontends/**'
- 'simplepyble/**'
- 'setup.py'
rust:
- *ci
- *linux
- *macos
- 'simplersble/**'
- 'Cargo.lock'
- 'Cargo.toml'
docs:
- *ci
- 'docs/**'
- '**/*.md'
- '**/*.rst'
Expand All @@ -110,7 +112,7 @@ jobs:
libraries:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
permissions:
pull-requests: read
outputs:
Expand Down Expand Up @@ -151,14 +153,18 @@ jobs:
needs: [pre_job, changes]
if: |
needs.pre_job.outputs.should_skip != 'true' &&
(needs.changes.outputs.windows == 'true' || github.ref == 'refs/heads/main')
(needs.changes.outputs.windows == 'true' ||
needs.changes.outputs.miscs == 'true' ||
github.ref == 'refs/heads/main')
uses: ./.github/workflows/ci_windows.yml

linux:
needs: [pre_job, changes, libraries]
if: |
needs.pre_job.outputs.should_skip != 'true' &&
(needs.changes.outputs.linux == 'true' || github.ref == 'refs/heads/main')
(needs.changes.outputs.linux == 'true' ||
needs.changes.outputs.miscs == 'true' ||
github.ref == 'refs/heads/main')
uses: ./.github/workflows/ci_linux.yml
with:
libraries: ${{ needs.libraries.outputs.values }}
Expand All @@ -167,7 +173,9 @@ jobs:
needs: [pre_job, changes]
if: |
needs.pre_job.outputs.should_skip != 'true' &&
(needs.changes.outputs.macos == 'true' || github.ref == 'refs/heads/main')
(needs.changes.outputs.macos == 'true' ||
needs.changes.outputs.miscs == 'true' ||
github.ref == 'refs/heads/main')
uses: ./.github/workflows/ci_macos.yml

python:
Expand All @@ -176,46 +184,21 @@ jobs:
needs.pre_job.outputs.should_skip != 'true' &&
(needs.changes.outputs.python == 'true' || github.ref == 'refs/heads/main')
uses: ./.github/workflows/ci_python.yml
secrets: inherit

release-python:
runs-on: ubuntu-22.04
needs: [pre_job, changes, windows, linux, macos, python]
# Note that Python is released on every commit in main branch with relevant
# changes (python, linux, windows, or macos filters). While cpp binaries are
# only published on manual releases.
if: |
needs.pre_job.outputs.should_skip != 'true' &&
needs.changes.outputs.python == 'true' &&
(needs.changes.outputs.python == 'true' ||
needs.changes.outputs.windows == 'true' ||
needs.changes.outputs.linux == 'true' ||
needs.changes.outputs.macos == 'true') &&
github.ref == 'refs/heads/main'
steps:

- name: "Download Python Source Dist"
uses: actions/download-artifact@v4
with:
name: 'simplepyble'
path: 'sdist'

- name: Check packages
run: |
pip3 install twine
twine check sdist/simplepyble*.tar.gz

- name: Publish packages
run: twine upload --skip-existing sdist/simplepyble*.tar.gz --verbose
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

- name: "Download Python Wheels"
uses: actions/download-artifact@v4
with:
pattern: 'simpleble-wheels-*'
path: 'wheels'
merge-multiple: true

- name: Check Packages
run: twine check wheels/*.whl

- name: Publish packages to PyPi
run: twine upload --skip-existing wheels/*.whl --verbose
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

uses: ./.github/workflows/ci_python_publish.yml
with:
tag: ${{ github.ref }}
secrets: inherit
Loading
Loading