Skip to content

fix: remove debug logs #381

fix: remove debug logs

fix: remove debug logs #381

Workflow file for this run

name: release
on:
push:
branches:
- main
workflow_dispatch:
jobs:
release:
name: Create release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20' # Specify node version to match project requirements
- name: Get latest tag or fail
id: get-latest-tag
run: |
latest_tag=$(git for-each-ref --sort=version:refname --format '%(refname)' refs/tags/ | grep -v 'latest' | tail -1 | sed 's/^refs\/tags\///; s/^v//')
if [ -z "$latest_tag" ]; then
echo "No tags found for the commit."
exit 1
fi
echo "tag=$latest_tag" >> $GITHUB_OUTPUT
- name: Get current version
id: get-version
run: echo "version=$(node -pe "require('./package.json').version")" >> $GITHUB_ENV
- name: Install semver
run: npm install semver
- name: Check if version is higher
id: check-version
run: |
is_higher=$(node -pe "const semver = require('semver'); semver.gt('${{ env.version }}', '${{ steps.get-latest-tag.outputs.tag }}')")
if [ "$is_higher" != "true" ]; then
echo "is_higher_version=false" >> $GITHUB_ENV
echo "The version is not higher than the latest release"
exit 1
fi
echo "is_higher_version=true" >> $GITHUB_ENV
- name: Remove package-lock.json to prevent conflicts
if: env.is_higher_version == 'true'
run: |
if [ -f package-lock.json ]; then
rm package-lock.json
fi
- name: Build project
if: env.is_higher_version == 'true'
run: |
npm install --legacy-peer-deps
npm run build
- name: 🛎️ Create release
if: env.is_higher_version == 'true'
uses: softprops/action-gh-release@v2
with:
files: dist/sunsynk-power-flow-card.js
tag_name: v${{ env.version }}
name: v${{ env.version }}
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: true
- name: 🏷️ Update latest tag
if: env.is_higher_version == 'true'
uses: EndBug/latest-tag@latest