diff --git a/.github/workflows/on-commit.yml b/.github/workflows/on-commit.yml index 257e4e0..95dfc46 100644 --- a/.github/workflows/on-commit.yml +++ b/.github/workflows/on-commit.yml @@ -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 @@ -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 @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh index 1d1145c..f4782d0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 @@ -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 @@ -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