Merge pull request #12 from PxaMMaxP/fix/release-action

Fix/release action
This commit is contained in:
Max P.
2024-08-16 18:38:21 +02:00
committed by GitHub
2 changed files with 28 additions and 12 deletions

View File

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

View File

@@ -6,6 +6,7 @@
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"scripts": { "scripts": {
"prepare": "npm run build",
"build": "npm run build:tsc", "build": "npm run build:tsc",
"build:tsc": "tsc", "build:tsc": "tsc",
"lint": "eslint --ext .ts .", "lint": "eslint --ext .ts .",