Skip to content

Commit

Permalink
chore: simplify git diff check in workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nohehf committed Sep 26, 2024
1 parent bf84932 commit d56ebf5
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,21 @@ jobs:

- name: Check for changes
id: git_diff
run: |
if git diff-index --quiet HEAD --; then
echo "diff_exists=false" >> $GITHUB_OUTPUT
else
echo "diff_exists=true" >> $GITHUB_OUTPUT
fi
run: git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT

- name: Lint, build, test before release
if: steps.git_diff.outputs.diff_exists == 'true'
if: steps.git_diff.outputs.changes == 'true'
run: make lint build test

- name: Get latest tag
if: steps.git_diff.outputs.diff_exists == 'true'
if: steps.git_diff.outputs.changes == 'true'
id: get_tag
run: |
LATEST_TAG=$(make get-version)
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
- name: Calculate new tag
if: steps.git_diff.outputs.diff_exists == 'true'
if: steps.git_diff.outputs.changes == 'true'
id: new_tag
env:
LATEST_TAG: ${{ steps.get_tag.outputs.latest_tag }}
Expand All @@ -72,7 +67,7 @@ jobs:
echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
- name: Commit and push changes with new tag
if: steps.git_diff.outputs.diff_exists == 'true'
if: steps.git_diff.outputs.changes == 'true'
env:
NEW_TAG: ${{ steps.new_tag.outputs.new_tag }}
run: |
Expand All @@ -84,7 +79,7 @@ jobs:
# Release
- uses: goreleaser/goreleaser-action@v4
name: Release new patch
if: steps.git_diff.outputs.diff_exists == 'true'
if: steps.git_diff.outputs.changes == 'true'
with:
args: "release --clean"
version: latest
Expand Down

0 comments on commit d56ebf5

Please sign in to comment.