diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 711b19a..8e043a5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,6 +4,7 @@ on: push: branches: - main + permissions: contents: write # we need this to be able to push tags @@ -16,6 +17,8 @@ jobs: uses: actions/checkout@v4 with: ssh-key: ${{ secrets.PUSH_KEY }} + fetch-tags: true + fetch-depth: 0 - name: Read and validate VERSION id: version @@ -32,6 +35,7 @@ jobs: if: contains(env.version, '-dev') run: | echo "Skipping development version release: ${{ env.version }}" + echo "SKIP=true" >> $GITHUB_ENV exit 0 - name: Check if VERSION is already tagged @@ -39,10 +43,13 @@ jobs: run: | if git rev-parse "refs/tags/${{ env.version }}" >/dev/null 2>&1; then echo "Tag ${{ env.version }} already exists. Skipping release." + echo "SKIP=true" >> $GITHUB_ENV exit 0 fi + echo "Tag ${{ env.version }} doesn't exists. Proceeding with release." - name: Create Git tag + if: ${{ env.SKIP != 'true' }} run: | AUTHOR_NAME=$(git log -1 --pretty=format:'%an') AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae') @@ -58,6 +65,7 @@ jobs: git push origin "${{ env.version }}" - name: Create GitHub release + if: ${{ env.SKIP != 'true' }} uses: softprops/action-gh-release@v2 with: tag_name: ${{ env.version }} @@ -69,6 +77,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Push dev VERSION + if: ${{ env.SKIP != 'true' }} run: | echo "${{ env.version }}-dev" > VERSION git config user.name "${{ env.AUTHOR_NAME }}"