Skip to content

Commit

Permalink
Update gradle.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
irsdl committed Sep 18, 2023
1 parent 5597e03 commit fb65ed7
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
pull_request:
branches:
- main
- early-adapter

jobs:
build:
Expand All @@ -36,6 +35,32 @@ jobs:
with:
path: ./releases/*.jar
name: Downloadable Extension File
- name: Get previous tag for the branch
id: get_previous_tag
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
PREFIX="main_"
else
PREFIX="early_adapter_"
fi
PREVIOUS_TAG=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/git/refs/tags \
| jq -r ".[] | select(.ref | startswith(\"refs/tags/${PREFIX}\")) | .ref" \
| sort -V | tail -n 1 | sed "s|refs/tags/||")
# Check if we found a tag
if [[ -z "$PREVIOUS_TAG" ]]; then
echo "No previous tag found for prefix ${PREFIX}."
echo "PREVIOUS_TAG=" >> $GITHUB_ENV
else
echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> $GITHUB_ENV
fi
- name: Delete the previous tag
if: env.PREVIOUS_TAG != ''
run: |
curl -X DELETE \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/git/refs/tags/${{ env.PREVIOUS_TAG }}"
- name: Extract version
id: get_version
run: |
Expand All @@ -49,12 +74,6 @@ jobs:
else
echo "RELEASE_TAG=early_adapter_${VERSION}_by_github" >> $GITHUB_ENV
fi
- name: Delete the tag
run: |
TAG_TO_DELETE=$RELEASE_TAG
curl -X DELETE \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$TAG_TO_DELETE"
- name: Release
uses: irsdl/release-action@v1.12.0
with:
Expand Down

0 comments on commit fb65ed7

Please sign in to comment.