diff --git a/.github/workflows/on-commit.yml b/.github/workflows/on-commit.yml index c55f04a..5b1b6f9 100644 --- a/.github/workflows/on-commit.yml +++ b/.github/workflows/on-commit.yml @@ -5,6 +5,7 @@ on: push: jobs: build: + name: "Test dev and final release creation" runs-on: ubuntu-latest steps: - name: Checkout repository @@ -40,7 +41,10 @@ jobs: run: | ls -lrt cd create-bosh-release-action-test-boshrelease + echo "Display create-bosh-release-action-test-boshrelease git repo status:" git status + echo "List existing tags:" + git tag --list #echo "Cleanup generated files" #git clean -fdx cd .. diff --git a/README.md b/README.md index 1295557..ba80e93 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,14 @@ default: 0 Name of the generated release. +### `version` + +version of the generated bosh release + +### `need_gh_release` + +Do we need to create a GitHub release associated to this bosh release + ## Example usage ``` @@ -46,3 +54,5 @@ env: AWS_BOSH_ACCES_KEY_ID: ${{ secrets.AWS_BOSH_ACCES_KEY_ID }} AWS_BOSH_SECRET_ACCES_KEY: ${{ secrets.AWS_BOSH_SECRET_ACCES_KEY }} ``` + +See [GitHub action for extra samples](./.github/workflows/on-commit.yml) diff --git a/action.yml b/action.yml index 5ff5f38..c481702 100644 --- a/action.yml +++ b/action.yml @@ -33,6 +33,8 @@ outputs: description: "generated bosh release filename" version: description: "version of the generated bosh release" + need_gh_release: + description: "Do we need to create a github release associated to this bosh release" runs: using: "docker" diff --git a/entrypoint.sh b/entrypoint.sh index e4d29fa..cac7eff 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -61,6 +61,10 @@ git config --global --add safe.directory /github/workspace echo "*** Git global config ***" git --no-pager config --global --list +# remove existing release if any, and prepare a commit that will be amended next +# 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}") if [ "${release}" == "true" ]; then # remove existing release if any if [ -f releases/"${name}"/"${name}"-"${version}".yml ]; then @@ -104,10 +108,10 @@ if [ "${release}" == "true" ]; then git tag -a -m "cutting release ${version}" ${version} $PUSH_OPTIONS git pull --rebase ${remote_repo} -# if [ "${INPUT_OVERRIDE_EXISTING}" == "true" ] && git rev-parse "$version" >/dev/null 2>&1; then -# # Delete any existing release with same tag. Ignore push failure if no tag exists. -# git push --delete ${remote_repo} ${version} -# fi + if [[ "${INPUT_OVERRIDE_EXISTING}" == "true" ]]; then + # Delete any existing release with same tag. Ignore push failure if no tag exists. + ! git push --delete ${remote_repo} ${version} + fi git push ${remote_repo} HEAD:${INPUT_TARGET_BRANCH} --follow-tags # Push branch and tag fi @@ -123,4 +127,5 @@ chmod 644 ${name}-${version}.tgz # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files echo "file=${name}-${version}.tgz" >> $GITHUB_OUTPUT echo "version=${version}" >> $GITHUB_OUTPUT +echo "need_gh_release=${NEED_GITHUB_RELEASE}" >> $GITHUB_OUTPUT