name: Auto-Release jBase on: workflow_dispatch: push: branches: - main paths: - 'package.json' jobs: build-and-release: runs-on: ubuntu-latest steps: - name: 📥 Code checkout uses: actions/checkout@v4 - name: ⚙️ Node.js setup uses: actions/setup-node@v4 with: node-version: '20' - name: 📦 Dependencies & Build run: | npm ci npm run build - name: 🗜️ zip dist-Ordner run: zip -r jbase-dist.zip dist/ - name: 🏷️ Read the version from package.json id: get_version run: | VERSION=$(node -p "require('./package.json').version") TAG_NAME="v.$VERSION" echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT echo "Detected version: $TAG_NAME" - name: 📝 Extract the latest changelog id: get_changelog run: | CHANGELOG=$(node -e " const fs = require('fs'); try { const content = fs.readFileSync('CHANGELOG.md', 'utf8'); const regex = /## \[\d+\.\d+\.\d+\].*/g; const matches = [...content.matchAll(regex)]; if (matches.length > 0) { const lastMatchIndex = matches[matches.length - 1].index; const latestEntry = content.substring(lastMatchIndex).trim(); console.log(latestEntry); } else { console.log('No matching entry was found in the format ## [x.x.x].'); } } catch(e) { console.log('CHANGELOG.md not found or parsing error.'); } ") EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) echo "CHANGELOG<<$EOF" >> $GITHUB_OUTPUT echo "$CHANGELOG" >> $GITHUB_OUTPUT echo "$EOF" >> $GITHUB_OUTPUT - name: 🚀 Create a Forgejo release & upload assets uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.get_version.outputs.TAG_NAME }} name: ${{ steps.get_version.outputs.TAG_NAME }} body: ${{ steps.get_changelog.outputs.CHANGELOG }} files: | jbase-dist.zip dist/jbase.min.js dist/jbase.min.js.map env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}