Skip to content

Commit

Permalink
ensure we push changes (commits and tags) on a new release, even with…
Browse files Browse the repository at this point in the history
…out blobs change
  • Loading branch information
o-orand committed Jan 17, 2024
1 parent 28a29fc commit 8ebbdc4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/on-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
token: ${{ secrets.CREATE_BOSH_RELEASE_ACTION_TEST_BOSHRELEASE_GIT_TOKEN }}
target_branch: main
dir: final-release-creation-test
tag_name: "v0.2.0"
tag_name: "v0.3.0"
override_existing: "true"
debug: 1
- name: Generated final files status - override
Expand All @@ -60,21 +60,24 @@ jobs:
echo "Display final-release-creation-test(create-bosh-release-action-test-boshrelease) git repo status:"
git status
echo "Checking tgz"
ls -l create-bosh-release-action-test-boshrelease-0.2.0.tgz
ls -l create-bosh-release-action-test-boshrelease-0.3.0.tgz
echo "List existing tags:"
git tag --list
echo "Ensure tag exist
git tag --list|grep -E "^v0.2.0$"
echo "Ensure tag exist v0.3.0"
git tag --list|grep -E "^v0.3.0$"
cd ..
- name: Get Next Version
id: semver-final-release
run: |
cd create-bosh-release-action-test-boshrelease
latest_tag=$(git describe --tags --abbrev=0)
major_minor=$(echo $latest_tag|cut -d'.' -f1-2)
patch=$(echo $latest_tag|cut -d'.' -f3)
next_patch=$((patch + 1))
echo "nextVersion=${major_minor}.$next_patch" >> "$GITHUB_ENV"
cd create-bosh-release-action-test-boshrelease
latest_tag=$(git describe --tags --abbrev=0)
echo "latest tag found: $latest_tag"
major_minor=$(echo $latest_tag|cut -d'.' -f1-2)
patch=$(echo $latest_tag|cut -d'.' -f3)
next_patch=$((patch + 1))
nextVersion=${major_minor}.$next_patch
echo "nextVersion: $nextVersion"
echo "nextVersion=$nextVersion" >> "$GITHUB_OUTPUT"
cd ..
- name: Test final release creation new tag
id: test_final_new_release
Expand All @@ -84,12 +87,12 @@ jobs:
token: ${{ secrets.CREATE_BOSH_RELEASE_ACTION_TEST_BOSHRELEASE_GIT_TOKEN }}
target_branch: main
dir: final-release-creation-test
tag_name: "${{ steps.semver-final-release.env.nextVersion }}"
tag_name: "${{ steps.semver-final-release.outputs.nextVersion }}"
override_existing: "false"
debug: 1
- name: Generated final files status - new
env:
NEXT_VERSION: "${{ steps.semver-final-release.env.nextVersion }}"
NEXT_VERSION: "${{ steps.semver-final-release.outputs.nextVersion }}"
run: |
ls -lrt
cd final-release-creation-test
Expand Down
6 changes: 4 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ git --no-pager config --global --list
# Having a single amended commit makes it easier to inspect last commit
# See https://superuser.com/a/360986/299481 for details of the bash array syntax
NEXT_GIT_COMMIT_FLAGS=(-m "cutting release ${version}")
FIRST_FINAL_RELEASE="false"
if [ "${release}" == "true" ]; then
# remove existing release if any
if [ -f releases/"${name}"/"${name}"-"${version}".yml ]; then
Expand All @@ -78,6 +79,8 @@ if [ "${release}" == "true" ]; then
git add releases/${name}/${name}-${version}.yml releases/${name}/index.yml
git commit -a "${NEXT_GIT_COMMIT_FLAGS[@]}"
NEXT_GIT_COMMIT_FLAGS=(--amend -m "cutting release ${version} overriding existing one")
else
FIRST_FINAL_RELEASE="true"
fi
fi

Expand Down Expand Up @@ -114,12 +117,11 @@ if [ "${release}" == "true" ]; then

echo "Inspecting staged files to skip commit and push if there is no blob changes in the release"
git show HEAD ${RELEASE_FILE_NAME}
if ! git show HEAD ${RELEASE_FILE_NAME} | grep sha1 ; then
if [[ $FIRST_FINAL_RELEASE == false ]] && ! git show HEAD ${RELEASE_FILE_NAME} | grep sha1 ; then
echo "No sha1 found in diff in ${RELEASE_FILE_NAME}. No blob were modified. Skipping the git push"
ls -al ${RELEASE_FILE_NAME}
cat ${RELEASE_FILE_NAME}
NEED_GITHUB_RELEASE="false"

else
echo "pushing changes to git repository"
# Override any existing tag with same version. This may happen if only part of the renovate PRs were merged
Expand Down

0 comments on commit 8ebbdc4

Please sign in to comment.