Publish @openconduit/core #29
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 @openconduit/core | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (e.g. 1.2.1) — must match package.json' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| publish: | |
| name: Publish to GitHub Packages | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 26 | |
| registry-url: 'https://npm.pkg.github.com' | |
| scope: '@openconduit' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Type check | |
| run: npx tsc --noEmit | |
| - name: Publish | |
| id: publish | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| if [[ "$VERSION" == *"-"* ]]; then | |
| DIST_TAG=$(echo "$VERSION" | sed 's/[0-9]*\.[0-9]*\.[0-9]*-\([a-zA-Z]*\).*/\1/') | |
| npm publish --tag "$DIST_TAG" | |
| else | |
| npm publish | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.event_name == 'workflow_dispatch' && format('v{0}', inputs.version) || github.ref_name }} | |
| generate_release_notes: true | |
| prerelease: ${{ contains(steps.publish.outputs.version, '-alpha') || contains(steps.publish.outputs.version, '-beta') || contains(steps.publish.outputs.version, '-rc') }} | |
| - name: Dispatch client dependency bump | |
| # Skipped automatically when CORE_DISPATCH_TOKEN secret is not configured. | |
| # Add a fine-grained PAT with contents:write + pull-requests:write on | |
| # OpenConduit/Client as CORE_DISPATCH_TOKEN to enable automatic bump PRs. | |
| if: env.DISPATCH_TOKEN != '' | |
| env: | |
| DISPATCH_TOKEN: ${{ secrets.CORE_DISPATCH_TOKEN }} | |
| uses: actions/github-script@v8 | |
| with: | |
| github-token: ${{ secrets.CORE_DISPATCH_TOKEN }} | |
| script: | | |
| await github.rest.repos.createDispatchEvent({ | |
| owner: 'OpenConduit', | |
| repo: 'Client', | |
| event_type: 'core-published', | |
| client_payload: { version: '${{ steps.publish.outputs.version }}' } | |
| }); |