Skip to content

Commit

Permalink
rework tag delete
Browse files Browse the repository at this point in the history
  • Loading branch information
o-orand committed Jan 16, 2024
1 parent ff2730a commit 18e1fbc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/on-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
jobs:
build:
name: "Test dev and final release creation"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down Expand Up @@ -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 ..
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand All @@ -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)
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 9 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit 18e1fbc

Please sign in to comment.