Skip to content

Commit 0c7a34d

Browse files
committed
fixed db offline when unclear release (#17) and provenance failing
1 parent 863a47a commit 0c7a34d

2 files changed

Lines changed: 42 additions & 30 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ jobs:
6363

6464
- name: Publish to npm
6565
if: ${{ github.event.inputs.skip_npm != 'true' }}
66+
# Uses Trusted Publishing via OIDC - no token needed
67+
# Configure at: npmjs.com → Package Settings → Publishing access → Trusted publishers
6668
run: pnpm publish --provenance --access public --no-git-checks
67-
env:
68-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6969

7070
- name: Index and prepare mappings
7171
env:

src/cli/manage.ts

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -701,43 +701,55 @@ async function getRemoteVersion(dbConfig: OptionalDb): Promise<RemoteInfo | null
701701
`https://api.github.com/repos/${CONFIG.repoOwner}/${CONFIG.repoName}/releases`
702702
)) as GitHubRelease[];
703703

704-
// Find the latest release matching the tag prefix
705-
const release = releases.find((r) => r.tag_name.startsWith(dbConfig.tagPrefix));
704+
// Iterate through releases to find the first one that:
705+
// 1. Matches the tag prefix
706+
// 2. Contains the required database asset
707+
// This handles cases where the latest release failed and has no assets
708+
for (const release of releases) {
709+
if (!release.tag_name.startsWith(dbConfig.tagPrefix)) {
710+
continue;
711+
}
706712

707-
if (!release) return null;
713+
// Find assets
714+
const dbAsset = release.assets.find((a) => a.name === dbConfig.fileName);
708715

709-
// Extract version from tag (e.g., examples-v0.1.0 -> 0.1.0)
710-
let version = release.tag_name.replace(dbConfig.tagPrefix, '');
716+
// Skip releases that don't have the required database asset
717+
if (!dbAsset) {
718+
continue;
719+
}
711720

712-
// Find assets
713-
const dbAsset = release.assets.find((a) => a.name === dbConfig.fileName);
714-
const manifestAsset = release.assets.find((a) => a.name === dbConfig.manifestName);
721+
const manifestAsset = release.assets.find((a) => a.name === dbConfig.manifestName);
715722

716-
if (!dbAsset) return null;
723+
// Extract version from tag (e.g., examples-v0.1.0 -> 0.1.0)
724+
let version = release.tag_name.replace(dbConfig.tagPrefix, '');
717725

718-
// If manifest exists, try to get the real version from it
719-
// This handles cases where DB version differs from Release tag
720-
if (manifestAsset) {
721-
try {
722-
const manifest = (await fetchJson(manifestAsset.browser_download_url)) as {
723-
version: string;
724-
};
725-
if (manifest && manifest.version) {
726-
version = manifest.version;
726+
// If manifest exists, try to get the real version from it
727+
// This handles cases where DB version differs from Release tag
728+
if (manifestAsset) {
729+
try {
730+
const manifest = (await fetchJson(manifestAsset.browser_download_url)) as {
731+
version: string;
732+
};
733+
if (manifest && manifest.version) {
734+
version = manifest.version;
735+
}
736+
} catch {
737+
// Fallback to tag version if manifest fetch fails
727738
}
728-
} catch {
729-
// Fallback to tag version if manifest fetch fails
730739
}
740+
741+
return {
742+
version,
743+
releaseId: release.id,
744+
downloadUrl: dbAsset.browser_download_url,
745+
manifestUrl: manifestAsset ? manifestAsset.browser_download_url : null,
746+
size: dbAsset.size,
747+
publishedAt: release.published_at,
748+
};
731749
}
732750

733-
return {
734-
version,
735-
releaseId: release.id,
736-
downloadUrl: dbAsset.browser_download_url,
737-
manifestUrl: manifestAsset ? manifestAsset.browser_download_url : null,
738-
size: dbAsset.size,
739-
publishedAt: release.published_at,
740-
};
751+
// No release found with the required assets
752+
return null;
741753
} catch {
742754
return null;
743755
}

0 commit comments

Comments
 (0)