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

chore: only create nightly release if there have been changes #157

Merged
merged 3 commits into from
Aug 15, 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
36 changes: 34 additions & 2 deletions .github/workflows/nightly-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,39 @@ permissions:
packages: write

jobs:
check-for-changes:
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check_changes.outputs.should_release }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history for all branches and tags

- name: Check for changes
id: check_changes
run: |
git fetch --tags
LAST_RELEASE=$(git tag -l --sort=-version:refname | head -n 1)
if [ -z "$LAST_RELEASE" ]; then
echo "No previous release found. Proceeding with release."
echo "should_release=true" >> $GITHUB_OUTPUT
else
# check for changes in modules/ directory
CHANGES=$(git diff --name-only $LAST_RELEASE..HEAD -- modules)
if [ -n "$CHANGES" ]; then
echo "Changes detected in modules/ since last release. Proceeding with release."
echo "should_release=true" >> $GITHUB_OUTPUT
else
echo "No changes detected in modules/ since last release. Skipping release."
echo "should_release=false" >> $GITHUB_OUTPUT
fi
fi

create-nightly-release:
needs: check-for-changes
if: needs.check-for-changes.outputs.should_release == 'true'
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.set_envars.outputs.TAG_NAME }}
Expand All @@ -29,7 +61,6 @@ jobs:
- name: Set envars
id: set_envars
run: |
# generate TAG_NAME and RELEASE_DATE envars
TODAY=$(date +'%Y-%m-%d')
echo "RELEASE_DATE=$TODAY" >> "$GITHUB_OUTPUT"
echo "TAG_NAME=nightly-$TODAY" >> "$GITHUB_OUTPUT"
Expand All @@ -47,7 +78,8 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

build-and-upload:
needs: create-nightly-release
needs: [check-for-changes, create-nightly-release]
if: needs.check-for-changes.outputs.should_release == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
Loading