Skip to content

Commit f7209a7

Browse files
committed
Publish to npm as @lockdown-systems/ringrtc
1 parent a061a9d commit f7209a7

File tree

4 files changed

+44
-22
lines changed

4 files changed

+44
-22
lines changed

.github/workflows/lockdown_release.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ jobs:
120120

121121
permissions:
122122
contents: write # Needed for creating releases
123+
id-token: write # Needed for npm provenance and trusted publishing
123124

124125
steps:
125126
- uses: actions/checkout@v4
@@ -129,6 +130,10 @@ jobs:
129130
node-version-file: "src/node/.nvmrc"
130131
registry-url: "https://registry.npmjs.org/"
131132

133+
# Trusted publishing requires npm 11.5.1+
134+
- name: Update npm for trusted publishing
135+
run: npm install -g npm@latest
136+
132137
# Download all build artifacts
133138
- name: Download Linux x64 build
134139
uses: actions/download-artifact@v4
@@ -177,25 +182,24 @@ jobs:
177182
with:
178183
files: src/node/ringrtc-desktop-build-v${{ steps.version.outputs.version }}.tar.gz
179184
generate_release_notes: true
185+
fail_on_unmatched_files: true
180186

181-
# Update package.json with checksum
182-
- name: Update prebuild checksum
183-
run: |
184-
sed -i 's/"prebuildChecksum": ""/"prebuildChecksum": "${{ steps.checksum.outputs.sha256 }}"/' package.json
185-
working-directory: src/node
186-
187-
# Install and build
187+
# Install and build (skip install scripts - we already have the prebuilt binaries)
188188
- name: Install dependencies
189-
run: npm ci
189+
run: npm ci --ignore-scripts
190190
working-directory: src/node
191191

192192
- name: Build TypeScript
193193
run: npm run build
194194
working-directory: src/node
195195

196+
# Update package.json with checksum after build
197+
- name: Update prebuild checksum
198+
run: |
199+
npm pkg set config.prebuildChecksum="${{ steps.checksum.outputs.sha256 }}"
200+
working-directory: src/node
201+
196202
# Publish to npm
197203
- name: Publish to npm
198-
run: npm publish --access public
204+
run: npm publish --access public --provenance --tag audiosink
199205
working-directory: src/node
200-
env:
201-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

src/node/package-lock.json

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

src/node/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "@lockdown-systems/ringrtc",
3-
"version": "2.63.0-audiosink.2",
3+
"version": "2.63.0-audiosink.1",
44
"repository": {
55
"type": "git",
6-
"url": "https://github.com/lockdown-systems/ringrtc.git",
6+
"url": "git+https://github.com/lockdown-systems/ringrtc.git",
77
"directory": "src/node"
88
},
99
"description": "Signal Messenger voice and video calling library.",

src/node/scripts/fetch-prebuild.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ const crypto = require('crypto');
1313
const tar = require('tar');
1414
const { Transform } = require('stream');
1515
const { pipeline } = require('stream/promises');
16-
17-
const VERSION = process.env.npm_package_version;
16+
const { URL: NodeURL } = require('url');
1817

1918
let config;
19+
let VERSION;
2020

2121
// When installing from the registry, `npm` doesn't set `npm_package_config_*`
2222
// environment variables. However, unlike `yarn`, `npm` always provides a path
@@ -26,15 +26,18 @@ if (process.env.npm_package_json) {
2626
encoding: 'utf8',
2727
});
2828

29-
({ config } = JSON.parse(json));
29+
const pkg = JSON.parse(json);
30+
config = pkg.config;
31+
VERSION = pkg.version;
3032
} else {
3133
config = {
3234
prebuildUrl: process.env.npm_package_config_prebuildUrl,
3335
prebuildChecksum: process.env.npm_package_config_prebuildChecksum,
3436
};
37+
VERSION = process.env.npm_package_version;
3538
}
3639

37-
const URL = config.prebuildUrl.replace(
40+
const PREBUILD_URL = config.prebuildUrl.replace(
3841
'${npm_package_version}', // eslint-disable-line no-template-curly-in-string
3942
VERSION
4043
);
@@ -68,15 +71,30 @@ async function downloadIfNeeded() {
6871
await download();
6972
}
7073

71-
function download() {
72-
console.log(`downloading ${URL}`);
74+
function download(url = PREBUILD_URL) {
75+
console.log(`downloading ${url}`);
7376
return new Promise((resolve, reject) => {
7477
let options = {};
7578
if (process.env.HTTPS_PROXY != undefined) {
7679
options.agent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
7780
}
78-
https.get(URL, options, async res => {
81+
82+
// Parse URL if it's a string
83+
const parsedUrl = typeof url === 'string' ? new NodeURL(url) : url;
84+
85+
https.get(parsedUrl, options, async res => {
7986
try {
87+
// Handle redirects (GitHub releases use 302 redirects)
88+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
89+
console.log(`following redirect to ${res.headers.location}`);
90+
resolve(download(res.headers.location));
91+
return;
92+
}
93+
94+
if (res.statusCode !== 200) {
95+
throw new Error(`HTTP error: ${res.statusCode} ${res.statusMessage}`);
96+
}
97+
8098
const out = fs.createWriteStream(tmpFile);
8199

82100
const hash = crypto.createHash('sha256');

0 commit comments

Comments
 (0)