From 3e788ce513eb449dc79eb09d3faf89da6439131d Mon Sep 17 00:00:00 2001 From: doum1004 Date: Fri, 10 Apr 2026 01:39:23 -0400 Subject: [PATCH] Add CI, publish workflow, funding, and changelog - CI: runs tests on push/PR to main - Publish: manual workflow for version bump, npm + GitHub Packages publish, changelog, GitHub Release - Funding: Ko-fi link - CHANGELOG.md: marker for automated entries --- .github/FUNDING.yml | 1 + .github/workflows/ci.yml | 27 +++++ .github/workflows/publish.yml | 195 ++++++++++++++++++++++++++++++++++ CHANGELOG.md | 3 + 4 files changed, 226 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yml create mode 100644 CHANGELOG.md diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..bae6551 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +ko_fi: doum1004 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..589e538 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + name: Test + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Run tests + run: bun test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..0d7276c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,195 @@ +name: Publish to npm + +on: + workflow_dispatch: + inputs: + bump: + description: "Version bump type" + required: true + default: patch + type: choice + options: + - patch + - minor + - major + note: + description: "Release note (optional — shown at the top of the GitHub Release and CHANGELOG)" + required: false + default: "" + +permissions: + contents: write + id-token: write + packages: write + +concurrency: + group: publish + cancel-in-progress: false + +jobs: + publish: + name: Test → Build → Publish + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + packages: write + + steps: + # ── 1. Checkout ───────────────────────────────────────────────── + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + # ── 2. Set up Bun ─────────────────────────────────────────────── + - name: Set up Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + # ── 3. Install dependencies ───────────────────────────────────── + - name: Install dependencies + run: bun install --frozen-lockfile + + # ── 4. Run tests ──────────────────────────────────────────────── + - name: Run tests + run: bun test + + # ── 5. Bump version ───────────────────────────────────────────── + - name: Bump version (${{ inputs.bump }}) + id: bump + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + NEW_VERSION=$(npm version ${{ inputs.bump }} --no-git-tag-version) + echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" + echo "Bumped to ${NEW_VERSION}" + + # ── 6. Build ──────────────────────────────────────────────────── + - name: Build + run: bun run build + + # ── 7a. Publish to npm ────────────────────────────────────────── + - name: Set up Node (for npm publish) + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + + - name: Publish to npm + run: npm publish --access public --provenance + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + # ── 7b. Publish to GitHub Packages ────────────────────────────── + - name: Set up Node (for GitHub Packages) + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://npm.pkg.github.com + scope: '@doum1004' + + - name: Publish to GitHub Packages + run: | + npm pkg set name='@doum1004/llmwiki-cli' + npm publish --access public + npm pkg set name='llmwiki-cli' + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # ── 8. Build changelog entry and update CHANGELOG.md ──────────── + - name: Update CHANGELOG.md + id: changelog + run: | + VERSION=${{ steps.bump.outputs.new_version }} + DATE=$(date -u +%Y-%m-%d) + NOTE="${{ inputs.note }}" + + PREV_TAG=$(git tag --sort=-version:refname | grep -v "^${VERSION}$" | head -1) + + if [ -z "$PREV_TAG" ]; then + LOG=$(git log --pretty=format:"- %s (%h)" HEAD) + else + LOG=$(git log --pretty=format:"- %s (%h)" "${PREV_TAG}..HEAD") + fi + + { + echo "log<> "$GITHUB_OUTPUT" + + ENTRY_FILE=$(mktemp) + { + echo "## ${VERSION} — ${DATE}" + echo "" + if [ -n "$NOTE" ]; then + echo "> ${NOTE}" + echo "" + fi + echo "### Changes" + echo "" + echo "$LOG" + echo "" + if [ -n "$PREV_TAG" ]; then + REPO_URL=$(git remote get-url origin \ + | sed 's/\.git$//' \ + | sed 's|git@github\.com:|https://github.com/|') + echo "**Full diff:** [${PREV_TAG}...${VERSION}](${REPO_URL}/compare/${PREV_TAG}...${VERSION})" + fi + echo "" + echo "---" + echo "" + } > "$ENTRY_FILE" + + MARKER="" + awk -v entry_file="$ENTRY_FILE" -v marker="$MARKER" ' + $0 == marker { + print + print "" + while ((getline line < entry_file) > 0) print line + next + } + { print } + ' CHANGELOG.md > CHANGELOG.md.tmp + + mv CHANGELOG.md.tmp CHANGELOG.md + rm -f "$ENTRY_FILE" + + # ── 9. Commit version bump + CHANGELOG + push tag ──────────────── + - name: Commit and push + run: | + VERSION=${{ steps.bump.outputs.new_version }} + + git add package.json CHANGELOG.md + git commit -m "chore: release ${VERSION}" + git tag "${VERSION}" + git push origin HEAD:${{ github.ref_name }} --follow-tags + + # ── 10. Create GitHub Release ──────────────────────────────────── + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.bump.outputs.new_version }} + name: ${{ steps.bump.outputs.new_version }} + body: | + ${{ inputs.note && format('> {0}', inputs.note) || '' }} + + ## What's changed + ${{ steps.changelog.outputs.log || '_No commits found._' }} + + ## Install + ```sh + npm install -g llmwiki-cli + # or + npx llmwiki-cli --help + ``` + + **Full diff:** ${{ steps.changelog.outputs.prev_tag && format('[{0}...{1}](../../compare/{0}...{2})', steps.changelog.outputs.prev_tag, steps.bump.outputs.new_version, steps.bump.outputs.new_version) || '_first release_' }} + draft: false + prerelease: false diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6049ec6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog + +