Derek Anderson cf1027d693
first commit
Signed-off-by: Derek Anderson <dmikey@users.noreply.github.com>
2025-06-26 20:03:26 -05:00

109 lines
3.0 KiB
YAML

name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version type to release'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Install SQLite
run: sudo apt-get update && sudo apt-get install -y sqlite3
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Configure git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Bump version and create tag
id: version
run: |
OLD_VERSION=$(node -p "require('./package.json').version")
npm version ${{ github.event.inputs.version }} --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "old_version=$OLD_VERSION" >> $GITHUB_OUTPUT
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
git add package.json
git commit -m "chore: bump version to $NEW_VERSION"
git tag "v$NEW_VERSION"
- name: Generate changelog
id: changelog
run: |
# Simple changelog generation
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "## Changes in v${{ steps.version.outputs.new_version }}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
git log --oneline v${{ steps.version.outputs.old_version }}..HEAD --pretty=format:"- %s" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Push changes
run: |
git push origin main
git push origin v${{ steps.version.outputs.new_version }}
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.version.outputs.new_version }}
release_name: Release v${{ steps.version.outputs.new_version }}
body: |
## sqlite-snap v${{ steps.version.outputs.new_version }}
${{ steps.changelog.outputs.CHANGELOG }}
### Installation
```bash
npm install -g sqlite-snap@${{ steps.version.outputs.new_version }}
```
### Usage
```bash
sqlite-backup create ./database.db
sqlite-backup list ./database.db
sqlite-backup cleanup ./database.db --retention-days 30
```
draft: false
prerelease: false
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}