Skip to content

Commit

Permalink
ci: 👷 add change detection for job conditional execution; fix get-lat…
Browse files Browse the repository at this point in the history
…est-tag script
  • Loading branch information
Xminent committed Dec 11, 2023
1 parent a960d58 commit 460ba0c
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,32 @@ env:
TAG_SUFFIX: ${{ github.ref == 'refs/heads/dev' && '-dev' || '' }}

jobs:
changes:
runs-on: ubuntu-22.04
outputs:
build: ${{ steps.filter.outputs.src }}
ci: ${{ steps.filter.outputs.ci }}

steps:
- name: Checkout
if: github.event_name == 'push'
uses: actions/checkout@v3

- uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ github.event.pull_request.base.sha || github.sha }}
filters: |
src:
- '**/*.cpp'
- '**/*.hpp'
- '**/CMakeLists.txt'
ci:
- '.github/workflows/ci.yml'
build:
needs: changes
strategy:
fail-fast: true
fail-fast: false
matrix:
config:
- {
Expand All @@ -51,6 +74,7 @@ jobs:

name: build-${{ matrix.config.os }}-${{ matrix.config.arch }}
runs-on: ${{ matrix.config.os }}
if: needs.changes.outputs.build == 'true'

steps:
- name: Checkout
Expand Down Expand Up @@ -110,10 +134,14 @@ jobs:
- name: Get Latest Tag
id: latest-tag
run: |
if [[ ${{ github.ref }} == 'refs/heads/dev' ]]; then
latest_tag=$(git tag -l | grep "\-dev" | sort -V | tail -n 1)
if [[ "${{ github.ref }}" == 'refs/heads/dev' ]]; then
latest_tag=$(git tag -l | grep "\-dev" | sort -V | tail -n 1 || true)
else
latest_tag=$(git tag -l | grep -v "\-dev" | sort -V | tail -n 1)
latest_tag=$(git tag -l | grep -v "\-dev" | sort -V | tail -n 1 || true)
fi
if [[ -z $latest_tag ]]; then
latest_tag=""
fi
echo "::set-output name=tag::$latest_tag"
Expand Down

0 comments on commit 460ba0c

Please sign in to comment.