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

Use release published GitHub Action event instead of tag push #114

Merged
merged 1 commit into from
Nov 28, 2024
Merged
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
27 changes: 16 additions & 11 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ on:
branches:
- main
- release
tags:
- '**'
pull_request:
release:
types: [published]

jobs:
build_prepare:
name: Prepare build
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.version.outputs.version }}
channel: ${{ steps.version.outputs.channel }}
steps:
- name: Checkout build repository
uses: actions/checkout@v4
Expand All @@ -39,9 +38,13 @@ jobs:
fi
elif [ "${{ github.event_name }}" == "pull_request" ]; then
version="${calver_date}+pr${version%%/*}"
elif [ "${{ github.event_name }}" == "release" ]; then
# Use tag name for release version
version="${{ github.event.release.tag_name }}"
fi
echo "Building version $version"
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Checkout submodules
working-directory: ./connectedhomeip/
run: scripts/checkout_submodules.py --shallow --platform linux
Expand Down Expand Up @@ -72,10 +75,9 @@ jobs:
build_linux_build_container:
name: Build Linux container for Python wheels
runs-on: ubuntu-22.04

permissions:
contents: read
packages: write # Required for pushing containers to the registry
packages: write # Required for pushing containers to the registry

outputs:
container_image: ${{ steps.set_container_tag.outputs.container_image }}
Expand All @@ -92,6 +94,7 @@ jobs:
build_needed=false
tag="${{ github.ref_name }}"

# Set tag based on base branch (use base branch for the release or pull request)
if [ "${{ github.event_name }}" == "push" ]; then
if git diff --name-only ${{ github.event.before }} HEAD | grep -E '^Dockerfile'; then
echo "Dockerfile or related files changed; building container."
Expand All @@ -113,6 +116,8 @@ jobs:
tag="${{ github.base_ref }}"
fi
fi
elif [ "${{ github.event_name }}" == "release" ]; then
tag="${{ github.event.release.target_commitish }}"
fi

echo "Using container with tag: ${tag}"
Expand Down Expand Up @@ -157,7 +162,7 @@ jobs:

runs-on: ${{ matrix.arch.runner }}
permissions:
contents: write # for actions/upload-release-asset to upload release asset
contents: write # Required for uploading artifacts and assets

defaults:
run:
Expand Down Expand Up @@ -187,7 +192,7 @@ jobs:
run: |
scripts/build/gn_gen.sh --args=" \
chip_project_config_include_dirs=[\"//..\"] \
chip_crypto=\"boringssl\"
chip_crypto=\"boringssl\" \
enable_rtti=true \
chip_config_memory_debug_checks=false \
chip_config_memory_debug_dmalloc=false \
Expand All @@ -213,11 +218,11 @@ jobs:
path: ./connectedhomeip/out/controller/python/*.whl
- name: Upload wheels as release assets
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
with:
files: ./connectedhomeip/out/controller/python/*.whl
- name: Upload wheels to PyPI
if: startsWith(github.ref, 'refs/tags/')
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN_PYPI }}
Expand Down Expand Up @@ -307,11 +312,11 @@ jobs:
path: ./connectedhomeip/out/controller/python/*.whl
- name: Upload wheels as release assets
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
with:
files: connectedhomeip/out/controller/python/*.whl
- name: Upload wheels to PyPI
if: startsWith(github.ref, 'refs/tags/')
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN_PYPI }}
Expand Down