diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b3b8d15..dad74b3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,14 +21,30 @@ jobs: uses: actions/setup-node@v4 with: node-version: "22" + registry-url: "https://registry.npmjs.org" - name: Install dependencies run: npm ci - name: Create Release Pull Request or Publish + id: changesets uses: changesets/action@v1 with: publish: npm run release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Set up Node.js for GitHub Packages publishing + if: steps.changesets.outputs.published == 'true' + uses: actions/setup-node@v4 + with: + node-version: "22" + registry-url: "https://npm.pkg.github.com" + scope: "@aokiapp" + + - name: Publish to GitHub Packages + if: steps.changesets.outputs.published == 'true' + run: npm run build && npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 58447bb..5b8eec7 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,35 @@ Tag-Length-Value (TLV) parser and builder library with schema support. Provides ## Installation +### From npm + ```bash npm install @aokiapp/tlv ``` +### From GitHub Packages + +**Note**: GitHub Packages requires authentication even for public packages. + +First, authenticate with GitHub: + +```bash +npm login --registry=https://npm.pkg.github.com +``` + +Then install: + +```bash +npm install @aokiapp/tlv --registry=https://npm.pkg.github.com +``` + +Or configure your `.npmrc`: + +``` +@aokiapp:registry=https://npm.pkg.github.com +//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN +``` + ## Quick Start ### Basic TLV Parsing @@ -527,12 +552,19 @@ npm run format # Prettier ### Release +This library is automatically published to both npm and GitHub Packages via GitHub Actions. + ```bash npm run changelog # Create changeset npm run version # Update version -npm run publish # Publish to npm +npm run publish # Publish manually (for testing, otherwise use GitHub Actions) ``` +When changes are pushed to the `main` branch with a changeset, the GitHub Actions workflow will: + +1. Create a release PR or publish to npm +2. Automatically publish to GitHub Packages if npm publish succeeds + ## Project Structure ``` diff --git a/vitest.config.js b/vitest.config.js index 038978e..edc0479 100644 --- a/vitest.config.js +++ b/vitest.config.js @@ -29,12 +29,7 @@ export default defineConfig({ provider: "istanbul", reporter: ["text", "text-summary"], include: ["src/**/*.ts"], - exclude: [ - "tests/**", - "examples/**", - ".changeset/**", - "**/*.d.ts", - ], + exclude: ["tests/**", "examples/**", ".changeset/**", "**/*.d.ts"], }, }, });