Skip to content

Commit e803421

Browse files
authored
chore: add release workflow and update exports
2 parents 94e46e2 + ac00f09 commit e803421

7 files changed

Lines changed: 169 additions & 12 deletions

File tree

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
semver:
7+
description: "The semver to use"
8+
required: true
9+
default: "auto"
10+
type: choice
11+
options:
12+
- auto
13+
- patch
14+
- minor
15+
- major
16+
- prerelease
17+
- prepatch
18+
- preminor
19+
- premajor
20+
pull_request:
21+
types: [closed]
22+
23+
jobs:
24+
release:
25+
if: >-
26+
${{
27+
(
28+
startsWith(github.event.inputs.semver, 'pre') ||
29+
github.ref == format(
30+
'refs/heads/{0}',
31+
github.event.repository.default_branch
32+
)
33+
) &&
34+
(
35+
github.event_name != 'pull_request' ||
36+
github.event.pull_request.user.login == 'optic-release-automation[bot]'
37+
)
38+
}}
39+
runs-on: ubuntu-latest
40+
permissions:
41+
contents: write
42+
issues: write
43+
pull-requests: write
44+
id-token: write
45+
steps:
46+
- uses: nearform-actions/optic-release-automation-action@9e3518763346efacba15d729d0faaa4cbd8fdd52 # v4.12.3
47+
with:
48+
commit-message: "Release {version}"
49+
sync-semver-tags: false
50+
access: "public"
51+
# This prefix is added before the prerelease number, e.g. `v3.0.0-pre.0`
52+
prerelease-prefix: "pre"
53+
semver: ${{ github.event.inputs.semver }}
54+
# Prereleases are published under the `next` npm dist-tag
55+
npm-tag: ${{ startsWith(github.event.inputs.semver, 'pre') && 'next' || 'latest' }}
56+
# Don't notify linked issues
57+
notify-linked-issues: false
58+
publish-mode: oidc
59+
build-command: |
60+
npm ci

package-lock.json

Lines changed: 78 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@comapeo/map-server",
3-
"version": "1.0.0",
3+
"version": "1.0.0-pre.0",
44
"type": "module",
55
"exports": {
66
".": {
@@ -13,10 +13,11 @@
1313
"test:js": "vitest run",
1414
"test:lint": "eslint",
1515
"test:types": "tsc --noEmit",
16+
"test:publint": "npm run build && publint",
1617
"format": "prettier --write .",
17-
"prepare": "husky",
18-
"prepack": "tsc -p tsconfig.npm.json",
19-
"postinstall": "patch-package"
18+
"prepare": "husky && patch-package",
19+
"build": "tsc -p tsconfig.npm.json",
20+
"prepack": "run-s test build"
2021
},
2122
"keywords": [],
2223
"author": "",
@@ -40,6 +41,7 @@
4041
"npm-run-all2": "^7.0.2",
4142
"patch-package": "^8.0.1",
4243
"prettier": "^3.7.4",
44+
"publint": "^0.3.17",
4345
"type-fest": "^5.3.1",
4446
"typescript": "^5.9.3",
4547
"typescript-eslint": "^8.53.1",

src/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ import { fetchAPI } from './lib/fetch-api.js'
1616
import { RootRouter } from './routes/root.js'
1717
import type { FetchContext } from './types.js'
1818

19+
export { errors } from './lib/errors.js'
20+
21+
export type {
22+
MapInfo,
23+
MapShareState,
24+
MapShareStateUpdate,
25+
DownloadStateUpdate,
26+
} from './types.js'
27+
export type { DownloadState } from './lib/download-request.js'
28+
export type {
29+
MapShareCreateParams,
30+
MapShareDeclineParams,
31+
} from './routes/map-shares.js'
32+
export type { DownloadCreateParams } from './routes/downloads.js'
33+
1934
export type ServerOptions = {
2035
defaultOnlineStyleUrl: string | URL
2136
customMapPath: string | URL

src/lib/download-request.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ import { Agent as SecretStreamAgent } from 'secret-stream-http'
22
import z32 from 'z32'
33

44
import { TypedEventTarget } from '../lib/event-target.js'
5-
import type { DownloadCreateRequest } from '../routes/downloads.js'
5+
import type { DownloadCreateParams } from '../routes/downloads.js'
66
import { type DownloadStateUpdate } from '../types.js'
77
import { StatusError } from './errors.js'
88
import { errors, jsonError } from './errors.js'
99
import { secretStreamFetch } from './secret-stream-fetch.js'
1010
import { StateUpdateEvent } from './state-update-event.js'
1111
import { addTrailingSlash, generateId, getErrorCode, noop } from './utils.js'
1212

13-
type DownloadRequestState = DownloadStateUpdate &
14-
Omit<DownloadCreateRequest, 'mapShareUrls'> & { downloadId: string }
13+
export type DownloadState = DownloadStateUpdate &
14+
Omit<DownloadCreateParams, 'mapShareUrls'> & { downloadId: string }
1515

1616
export class DownloadRequest extends TypedEventTarget<
1717
InstanceType<typeof StateUpdateEvent<DownloadStateUpdate>>
1818
> {
19-
#state: DownloadRequestState
19+
#state: DownloadState
2020
#abortController = new AbortController()
2121
#transform = new TransformStream({
2222
transform: (chunk, controller) => {
@@ -34,7 +34,7 @@ export class DownloadRequest extends TypedEventTarget<
3434

3535
constructor(
3636
stream: WritableStream<Uint8Array>,
37-
{ mapShareUrls, ...rest }: DownloadCreateRequest,
37+
{ mapShareUrls, ...rest }: DownloadCreateParams,
3838
keyPair: { publicKey: Uint8Array; secretKey: Uint8Array },
3939
) {
4040
super()

src/routes/downloads.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const DownloadCreateRequest = T.Object({
2626
estimatedSizeBytes: EstimatedSizeBytes,
2727
})
2828

29-
export type DownloadCreateRequest = Static<typeof DownloadCreateRequest>
29+
export type DownloadCreateParams = Static<typeof DownloadCreateRequest>
3030

3131
export function DownloadsRouter(
3232
{ base }: { base: string },

src/routes/map-shares.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const MapShareCreateRequest = T.Object({
3030
receiverDeviceId: T.String({ minLength: 1 }),
3131
})
3232

33+
export type MapShareCreateParams = Static<typeof MapShareCreateRequest>
34+
3335
const LocalMapShareDeclineRequest = T.Object({
3436
reason: MapShareDeclineReason,
3537
mapShareUrls: MapShareUrls,
@@ -39,6 +41,8 @@ const LocalMapShareDeclineRequest = T.Object({
3941
}),
4042
})
4143

44+
export type MapShareDeclineParams = Static<typeof LocalMapShareDeclineRequest>
45+
4246
const RemoteMapShareDeclineRequest = T.Object({
4347
reason: MapShareDeclineReason,
4448
})

0 commit comments

Comments
 (0)