diff --git a/.github/workflows/CreateRelease.yml b/.github/workflows/CreateRelease.yml index c8460e6..9e62a72 100644 --- a/.github/workflows/CreateRelease.yml +++ b/.github/workflows/CreateRelease.yml @@ -54,14 +54,25 @@ jobs: - name: Check if version changed id: check_version run: | - if [ "${{ env.VERSION }}" == "${{ env.PREVIOUS_TAG }}" ]; then - echo "Version has not changed. No release will be created." - exit 1 + # Check if the version already exists as a tag + if git rev-parse "refs/tags/${{ env.VERSION }}" >/dev/null 2>&1; then + echo "skip_release=true" >> $GITHUB_OUTPUT + echo "Version ${{ env.VERSION }} already exists as a tag. No release will be created." + exit 0 fi + + # Compare current version with previous tag + if [ "${{ env.VERSION }}" == "${{ env.PREVIOUS_TAG }}" ]; then + echo "skip_release=true" >> $GITHUB_OUTPUT + echo "Version has not changed. No release will be created." + exit 0 + fi + echo "skip_release=false" >> $GITHUB_OUTPUT shell: bash - name: Generate release notes id: generate_notes + if: steps.check_version.outputs.skip_release == 'false' run: | echo "Generating release notes from ${{ env.PREVIOUS_TAG }} to HEAD..." repo_url=$(git config --get remote.origin.url) @@ -73,23 +84,26 @@ jobs: shell: bash - name: Set Git user + if: steps.check_version.outputs.skip_release == 'false' run: | git config --local user.name "GitHub Actions" git config --local user.email "actions@github.com" shell: bash - - name: Create temporary branch - id: create_temp_branch - run: | - git checkout --orphan release/v${{ env.VERSION }} - git reset - rm -f .gitignore - git add README.md package.json LICENSE dist/ src/ tsconfig.json - git commit -m "Prepare files for release ${{ env.VERSION }}" - shell: bash + # - name: Create temporary branch + # id: create_temp_branch + # if: steps.check_version.outputs.skip_release == 'false' + # run: | + # git checkout --orphan release/v${{ env.VERSION }} + # git reset + # rm -f .gitignore + # git add README.md package.json LICENSE dist/ src/ tsconfig.json + # git commit -m "Prepare files for release ${{ env.VERSION }}" + # shell: bash - name: Create and push tag id: create_tag + if: steps.check_version.outputs.skip_release == 'false' run: | git tag ${{ env.VERSION }} git push origin ${{ env.VERSION }} @@ -98,6 +112,7 @@ jobs: shell: bash - name: Release + if: steps.check_version.outputs.skip_release == 'false' uses: softprops/action-gh-release@v2 with: tag_name: ${{ env.VERSION }} diff --git a/package.json b/package.json index 53e7338..55ee01d 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "main": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": { + "prepare": "npm run build", "build": "npm run build:tsc", "build:tsc": "tsc", "lint": "eslint --ext .ts .",