Skip to content

Publish

Publish #37

Workflow file for this run

name: Publish
on:
push:
branches: [main]
paths:
- "opencode-plugin/**"
- "hooks/**"
- "native/**"
- "package.json"
workflow_dispatch:
concurrency:
group: npm-publish
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: "24"
- name: Verify package files exist
run: |
test -f opencode-plugin/louder.js || (echo "Missing opencode-plugin/louder.js" && exit 1)
test -f hooks/louder-hook.js || (echo "Missing hooks/louder-hook.js" && exit 1)
test -f native/HapticEngine || (echo "Missing native/HapticEngine" && exit 1)
- name: Check if version changed
id: version
run: |
LOCAL_VERSION=$(node -p "require('./package.json').version")
NPM_VERSION=$(npm view @feelso/louder version 2>/dev/null || echo "0.0.0")
echo "local=$LOCAL_VERSION" >> "$GITHUB_OUTPUT"
echo "npm=$NPM_VERSION" >> "$GITHUB_OUTPUT"
if [ "$LOCAL_VERSION" != "$NPM_VERSION" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Publish to npm (OIDC trusted publishing)
if: steps.version.outputs.changed == 'true'
run: |
npm config set registry https://registry.npmjs.org/
echo "ACTIONS_ID_TOKEN_REQUEST_URL: ${ACTIONS_ID_TOKEN_REQUEST_URL:+set}"
npm publish --access public
- name: Create git tag
if: steps.version.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ steps.version.outputs.local }}" -m "Release v${{ steps.version.outputs.local }}"
git push origin "v${{ steps.version.outputs.local }}"
- name: Skip publish (version unchanged)
if: steps.version.outputs.changed == 'false'
run: echo "Version ${{ steps.version.outputs.local }} already published. Bump version in package.json to trigger a new release."