Publish #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish | |
| on: | |
| release: | |
| types: | |
| - published | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Resolve version from release tag | |
| id: release_version | |
| shell: bash | |
| run: | | |
| tag='${{ github.event.release.tag_name }}' | |
| version="${tag#hikkaku@}" | |
| version="${version#v}" | |
| if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then | |
| echo "Invalid release tag: $tag" | |
| echo "Supported examples: v1.2.3, 1.2.3, hikkaku@1.2.3" | |
| exit 1 | |
| fi | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| - name: Update package version | |
| run: node -e "const fs=require('fs');const path='packages/hikkaku/package.json';const pkg=JSON.parse(fs.readFileSync(path,'utf8'));pkg.version='${{ steps.release_version.outputs.version }}';fs.writeFileSync(path,JSON.stringify(pkg,null,2)+'\n');" | |
| - name: Build package | |
| run: bun --cwd packages/hikkaku run build | |
| - name: Publish to npm | |
| run: npm publish --provenance --access public | |
| working-directory: packages/hikkaku/dist |