diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml new file mode 100644 index 0000000..3f4f18a --- /dev/null +++ b/.github/workflows/create_release.yml @@ -0,0 +1,55 @@ +name: Check and Create Release + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + check-release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '22' + + - name: Get package.json version + id: get_version + run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV + + - name: Get latest release version + id: get_release + run: | + curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name' > latest_release.txt + + - name: Compare versions + id: compare_versions + run: | + LATEST_TAG="$(cat latest_release.txt 2>/dev/null || echo "")" + if [ "$LATEST_TAG" = "null" ]; then + LATEST_TAG="" + fi + NORMALIZED_LATEST="${LATEST_TAG#v}" + NORMALIZED_LATEST="${NORMALIZED_LATEST#V}" + if [ "$NORMALIZED_LATEST" != "$PACKAGE_VERSION" ]; then + echo "Version mismatch" + echo "create_release=true" >> $GITHUB_ENV + else + echo "Version matches" + echo "create_release=false" >> $GITHUB_ENV + fi + + - name: Create new release + if: env.create_release == 'true' + run: | + TAG_NAME="v$PACKAGE_VERSION" + gh release create "$TAG_NAME" \ + --generate-notes \ + -t "$TAG_NAME" + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} diff --git a/cwd-admin/package.json b/cwd-admin/package.json index 49d22c6..337035b 100644 --- a/cwd-admin/package.json +++ b/cwd-admin/package.json @@ -1,7 +1,6 @@ { "name": "cwd-admin", - "version": "0.0.2", - "private": true, + "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", diff --git a/cwd-api/package.json b/cwd-api/package.json index d033827..435e354 100644 --- a/cwd-api/package.json +++ b/cwd-api/package.json @@ -1,7 +1,6 @@ { "name": "cwd-api", - "version": "0.0.2", - "private": true, + "version": "0.0.0", "scripts": { "deploy": "wrangler deploy", "dev": "wrangler dev", diff --git a/cwd-api/src/index.ts b/cwd-api/src/index.ts index c2185f9..119662a 100644 --- a/cwd-api/src/index.ts +++ b/cwd-api/src/index.ts @@ -8,7 +8,7 @@ import { saveEmailNotificationSettings } from './utils/email'; import { loadFeatureSettings } from './utils/featureSettings'; -import packageJson from '../package.json'; +import packageJson from '../../package.json'; import { getComments } from './api/public/getComments'; import { postComment } from './api/public/postComment'; diff --git a/docs/widget/package.json b/docs/widget/package.json index a217700..44b580c 100644 --- a/docs/widget/package.json +++ b/docs/widget/package.json @@ -1,7 +1,6 @@ { "name": "widget", - "version": "0.0.2", - "private": true, + "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", diff --git a/package.json b/package.json new file mode 100644 index 0000000..0611071 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "cwd", + "version": "0.0.1", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "https://github.com/anghunk/cwd" + }, + "homepage": "https://cwd.js.org", + "author": { + "name": "anghunk" + }, + "bugs": { + "url": "https://github.com/anghunk/cwd/issues" + } +}