Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ name: Publish Package
on:
workflow_dispatch:
push:
tags:
- "v*"
- "[0-9]*"
branches:
- main

permissions:
contents: read
contents: write
id-token: write

concurrency:
group: publish
cancel-in-progress: false

jobs:
publish:
runs-on: ubuntu-latest
Expand All @@ -19,27 +22,54 @@ jobs:
- name: Checkout
uses: actions/checkout@v6

- name: Check for unpublished version
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
NAME=$(node -p "require('./package.json').name")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if npm view "$NAME@$VERSION" version >/dev/null 2>&1; then
echo "$NAME@$VERSION is already on npm; skipping release."
echo "publish=false" >> "$GITHUB_OUTPUT"
else
echo "publish=true" >> "$GITHUB_OUTPUT"
fi

- name: Set up Bun
if: steps.version.outputs.publish == 'true'
uses: oven-sh/setup-bun@v2

- name: Install dependencies
if: steps.version.outputs.publish == 'true'
run: bun install --frozen-lockfile

- name: Test
if: steps.version.outputs.publish == 'true'
run: bun test

- name: Typecheck
if: steps.version.outputs.publish == 'true'
run: bun run typecheck

- name: Pack dry run
if: steps.version.outputs.publish == 'true'
run: bun pm pack --dry-run

- name: Set up Node for npm publishing
if: steps.version.outputs.publish == 'true'
uses: actions/setup-node@v6
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
package-manager-cache: false

- name: Publish to npm
if: steps.version.outputs.publish == 'true'
run: npm publish

- name: Tag and create GitHub release
if: steps.version.outputs.publish == 'true'
env:
GH_TOKEN: ${{ github.token }}
TAG: v${{ steps.version.outputs.version }}
run: gh release create "$TAG" --target "$GITHUB_SHA" --title "$TAG" --generate-notes
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mta-js",
"version": "2.4.0",
"version": "2.5.0",
"description": "A TypeScript client for MTA realtime feeds and the hosted MTA API.",
"license": "MIT",
"repository": {
Expand Down
Loading