Skip to content

Commit

Permalink
Skip tag creation if it's pre-created
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Nov 5, 2022
1 parent b1ee76a commit a8c2b37
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/tox-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -665,12 +665,34 @@ jobs:
with:
fetch-depth: 1
ref: ${{ github.event.inputs.release-commitish }}

- name: >-
Check if the requested tag ${{ needs.pre-setup.outputs.git-tag }}
is present and is pointing at the required commit ${{
github.event.inputs.release-commitish
}}
id: existing-remote-tag-check
run: |
REMOTE_TAGGED_COMMIT_SHA="$(
git ls-remote --tags --refs $(git remote get-url origin) '${{
needs.pre-setup.outputs.git-tag
}}' | awk '{print $1}'
)"
if [[ "${REMOTE_TAGGED_COMMIT_SHA}" == '${{
github.event.inputs.release-commitish
}}' ]]
then
echo "already-exists=true" >> "${GITHUB_OUTPUT}"
fi
- name: Setup git user as [bot]
uses: fregante/[email protected]

- name: >-
Tag the release in the local Git repo
as ${{ needs.pre-setup.outputs.git-tag }}
if: steps.existing-remote-tag-check.outputs.already-exists == 'true'
run: >-
git tag
-m '${{ needs.pre-setup.outputs.git-tag }}'
Expand All @@ -690,6 +712,7 @@ jobs:
- name: >-
Push ${{ needs.pre-setup.outputs.git-tag }} tag corresponding
to the just published release back to GitHub
if: steps.existing-remote-tag-check.outputs.already-exists == 'true'
run: >-
git push --atomic origin '${{ needs.pre-setup.outputs.git-tag }}'
Expand Down

0 comments on commit a8c2b37

Please sign in to comment.