Skip to content

Commit fb3b5c2

Browse files
fix: publish Photon OpenAPI packages and preserve reusable responses (#1)
1 parent 8bc8634 commit fb3b5c2

14 files changed

Lines changed: 195 additions & 332 deletions

.github/workflows/changelog-preview.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/package-artifacts.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 22 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,34 @@
1-
name: Publish
1+
name: Publish GitHub Package
2+
23
on:
3-
issues:
4-
types: [labeled]
4+
workflow_dispatch:
55

66
permissions:
7-
actions: read
8-
contents: write
9-
issues: write
10-
id-token: write
7+
contents: read
8+
packages: write
9+
10+
concurrency:
11+
group: publish-hono-openapi
12+
cancel-in-progress: false
1113

1214
jobs:
1315
publish:
14-
if: >-
15-
github.event.label.name == 'accepted' &&
16-
github.event.issue.state == 'open'
16+
if: github.repository == 'photon-hq/hono-openapi' && github.ref == 'refs/heads/main'
1717
runs-on: ubuntu-latest
18-
name: Publish release
19-
timeout-minutes: 15
2018
steps:
21-
- name: Generate GitHub App token
22-
id: token
23-
uses: actions/create-github-app-token@v2
24-
with:
25-
app-id: ${{ vars.CRAFT_APP_ID }}
26-
private-key: ${{ secrets.CRAFT_APP_PRIVATE_KEY }}
27-
28-
- name: Parse version from issue title
29-
id: release
30-
env:
31-
ISSUE_TITLE: ${{ github.event.issue.title }}
32-
run: |
33-
set -euo pipefail
34-
# Title: "publish: <owner>/<repo>@<version>"
35-
version="${ISSUE_TITLE##*@}"
36-
if [[ -z "$version" ]]; then
37-
echo "::error::Could not parse version from title: $ISSUE_TITLE"
38-
exit 1
39-
fi
40-
echo "version=$version" >> "$GITHUB_OUTPUT"
41-
echo "branch=release/$version" >> "$GITHUB_OUTPUT"
42-
43-
- uses: actions/checkout@v4
44-
with:
45-
ref: release/${{ steps.release.outputs.version }}
46-
token: ${{ steps.token.outputs.token }}
47-
fetch-depth: 0
48-
49-
- uses: pnpm/action-setup@v4
50-
51-
- uses: actions/setup-node@v4
19+
- uses: actions/checkout@v7
20+
- uses: pnpm/action-setup@v6
21+
- uses: actions/setup-node@v6
5222
with:
5323
node-version: 24
54-
registry-url: "https://registry.npmjs.org"
55-
56-
- name: Set git user
57-
run: |
58-
git config user.name "github-actions[bot]"
59-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
60-
61-
- name: Ensure npm supports trusted publishing
62-
run: npm install -g npm@latest
63-
64-
- name: Install Craft
65-
run: |
66-
CRAFT_URL=$(curl -fsSL https://api.github.com/repos/getsentry/craft/releases/latest \
67-
| jq -r '.assets[] | select(.name == "craft") | .browser_download_url')
68-
sudo curl -fsSL -o /usr/local/bin/craft "$CRAFT_URL"
69-
sudo chmod +x /usr/local/bin/craft
70-
71-
- name: Wait for package artifacts on release branch
24+
cache: pnpm
25+
registry-url: https://npm.pkg.github.com
26+
scope: '@photon-hq'
27+
- run: pnpm install --frozen-lockfile
7228
env:
73-
GH_TOKEN: ${{ steps.token.outputs.token }}
74-
run: |
75-
set -euo pipefail
76-
branch="${{ steps.release.outputs.branch }}"
77-
echo "Waiting for Package Artifacts on $branch..."
78-
run_id=$(gh run list --workflow "Package Artifacts" --branch "$branch" \
79-
--json databaseId --jq '.[0].databaseId')
80-
if [[ -z "$run_id" || "$run_id" == "null" ]]; then
81-
echo "::error::No Package Artifacts run found for branch $branch"
82-
exit 1
83-
fi
84-
gh run watch "$run_id" --exit-status
85-
86-
- name: Publish with Craft
87-
run: craft publish "${{ steps.release.outputs.version }}" --no-input --no-status-check
88-
env:
89-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90-
GITHUB_API_TOKEN: ${{ steps.token.outputs.token }}
91-
92-
- name: Close issue on success
93-
if: success()
94-
env:
95-
GH_TOKEN: ${{ steps.token.outputs.token }}
96-
run: |
97-
gh issue close "${{ github.event.issue.number }}" \
98-
--comment "Published **v${{ steps.release.outputs.version }}** successfully.
99-
[Workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
100-
101-
- name: Handle failure
102-
if: failure()
29+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
- run: pnpm test --run
31+
- run: pnpm build
32+
- run: pnpm publish --tag latest --no-git-checks
10333
env:
104-
GH_TOKEN: ${{ steps.token.outputs.token }}
105-
run: |
106-
gh issue comment "${{ github.event.issue.number }}" \
107-
--body "Publish failed. See [run logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
108-
gh issue edit "${{ github.event.issue.number }}" --remove-label accepted
34+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-preview.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
name: CI Tests
2-
on: [push, pull_request]
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
packages: read
311

412
jobs:
5-
test:
13+
verify:
614
runs-on: ubuntu-latest
7-
815
steps:
9-
- uses: actions/checkout@v5
10-
11-
- name: Use Node.js 22.x
12-
uses: actions/setup-node@v5
16+
- uses: actions/checkout@v7
17+
- uses: pnpm/action-setup@v6
18+
- uses: actions/setup-node@v6
1319
with:
14-
node-version: 22.x
15-
package-manager-cache: false
16-
17-
- name: Install PNPM
18-
uses: pnpm/action-setup@v4
19-
20-
- name: Install dependencies
21-
run: pnpm install
22-
23-
- name: Run tests
24-
run: pnpm test
20+
node-version: 24
21+
cache: pnpm
22+
registry-url: https://npm.pkg.github.com
23+
scope: '@photon-hq'
24+
- run: pnpm install --frozen-lockfile
25+
env:
26+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
- run: pnpm test --run
28+
- run: pnpm build
29+
- run: pnpm pack

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@photon-hq:registry=https://npm.pkg.github.com

PHOTON.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Photon package
2+
3+
`@photon-hq/hono-openapi` is published to GitHub Packages.
4+
5+
Version `1.3.1-photon.1` uses upstream commit
6+
`ce39f12976028681f752c98cc0e7108db5cc96c0` and pins
7+
`@photon-hq/standard-openapi@0.2.9-photon.1` as a runtime dependency. That converter
8+
includes the upstream fix for recursive definitions that otherwise produce
9+
dangling `#/components/schemas/*` references.
10+
11+
The Photon patch resolves response schemas into copies. Upstream mutates shared
12+
route metadata and documentation responses, which can discard components when
13+
generating another document from the same endpoint. The regression tests cover
14+
repeated generation and separate apps sharing route or component responses.
15+
16+
To publish a new version, update `package.json` and the lockfile, merge to `main`,
17+
then run the **Publish GitHub Package** workflow. Versions are immutable;
18+
increment the `-photon.N` suffix for Photon changes to the same upstream version.
19+
The workflow publishes with its repository's `GITHUB_TOKEN`.
20+
21+
Keep the upstream MIT license and compare the response-copy patch when syncing
22+
upstream or switching consumers back to the upstream package.

0 commit comments

Comments
 (0)