From ee0b53fbe2d09749d02e3d2db7af5edf19b2dd4e Mon Sep 17 00:00:00 2001 From: Jacob Bolda Date: Sun, 18 Aug 2024 05:54:59 -0500 Subject: [PATCH] skip pack in publish, use check fetch (#10657) * skip pack in publish, use check fetch * remove script * remove apt, exists in main pipeline * CLI doesn't need separate check * no assets for tauri-cli --- .changes/config.json | 63 +++++++++------------ .scripts/covector/package-latest-version.js | 58 ------------------- 2 files changed, 26 insertions(+), 95 deletions(-) delete mode 100644 .scripts/covector/package-latest-version.js diff --git a/.changes/config.json b/.changes/config.json index 79c302e31..2f53c8230 100644 --- a/.changes/config.json +++ b/.changes/config.json @@ -14,10 +14,13 @@ "pkgManagers": { "rust": { "version": true, - "getPublishedVersion": "node ../../.scripts/covector/package-latest-version.js cargo ${ pkgFile.pkg.package.name } ${ pkgFile.pkg.package.version }", + "getPublishedVersion": { + "use": "fetch:check", + "options": { + "url": "https://crates.io/api/v1/crates/${ pkg.pkgFile.pkg.package.name }/${ pkg.pkgFile.version }" + } + }, "prepublish": [ - "sudo apt-get update", - "sudo apt-get install -y webkit2gtk-4.1 libayatana-appindicator3-dev", "cargo install cargo-audit --features=fix", { "command": "cargo generate-lockfile", @@ -43,11 +46,6 @@ } ], "publish": [ - "sleep 15s", - { - "command": "cargo package --no-verify", - "dryRunCommand": true - }, { "command": "echo '
\n

Cargo Publish

\n\n```'", "dryRunCommand": true, @@ -64,21 +62,22 @@ "pipe": true } ], - "postpublish": [ - "git tag ${ pkg.pkg }-v${ pkgFile.versionMajor } -f", - "git tag ${ pkg.pkg }-v${ pkgFile.versionMajor }.${ pkgFile.versionMinor } -f", - "git push --tags -f" - ], - "assets": [ - { - "path": "./target/package/${ pkg.pkg }-${ pkgFile.version }.crate", - "name": "${ pkg.pkg }-${ pkgFile.version }.crate" - } - ] + "postpublish": { + "use": "fetch:check", + "options": { + "url": "https://crates.io/api/v1/crates/${ pkg.pkgFile.pkg.package.name }/${ pkg.pkgFile.version }" + }, + "retries": [5000, 5000, 5000] + } }, "javascript": { "version": true, - "getPublishedVersion": "node ../../.scripts/covector/package-latest-version.js npm ${ pkgFile.pkg.name } ${ pkgFile.pkg.version }", + "getPublishedVersion": { + "use": "fetch:check", + "options": { + "url": "https://registry.npmjs.com/${ pkg.pkgFile.pkg.name }/${ pkg.pkgFile.version }" + } + }, "prepublish": [ { "command": "pnpm i --frozen-lockfile", @@ -99,14 +98,9 @@ "command": "echo '```\n\n
\n'", "dryRunCommand": true, "pipe": true - }, - { - "command": "npm pack", - "dryRunCommand": true } ], "publish": [ - "sleep 15s", { "command": "echo '
\n

PNPM Publish

\n\n```'", "dryRunCommand": true, @@ -123,11 +117,13 @@ "pipe": true } ], - "postpublish": [ - "git tag ${ pkg.pkg }-v${ pkgFile.versionMajor } -f", - "git tag ${ pkg.pkg }-v${ pkgFile.versionMajor }.${ pkgFile.versionMinor } -f", - "git push --tags -f" - ] + "postpublish": { + "use": "fetch:check", + "options": { + "url": "https://registry.npmjs.com/${ pkg.pkgFile.pkg.name }/${ pkg.pkgFile.version }" + }, + "retries": [5000, 5000, 5000] + } } }, "packages": { @@ -253,7 +249,6 @@ "@tauri-apps/cli": { "path": "./tooling/cli/node", "manager": "javascript", - "getPublishedVersion": "node ../../../.scripts/covector/package-latest-version.js npm ${ pkgFile.pkg.name } ${ pkgFile.pkg.version }", "dependencies": ["tauri-cli"], "postversion": [ "node ../../../.scripts/covector/sync-cli-metadata.js ${ pkg.pkg } ${ release.type }", @@ -270,12 +265,6 @@ "postversion": [ "cargo check", "cargo build --manifest-path ../../core/tauri-config-schema/Cargo.toml" - ], - "assets": [ - { - "path": "${ pkg.path }/target/package/tauri-cli-${ pkgFile.version }.crate", - "name": "${ pkg.pkg }-${ pkgFile.version }.crate" - } ] }, "tauri-driver": { diff --git a/.scripts/covector/package-latest-version.js b/.scripts/covector/package-latest-version.js deleted file mode 100644 index 954645348..000000000 --- a/.scripts/covector/package-latest-version.js +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env node - -// Copyright 2019-2024 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -/* -This script is solely intended to be run as part of the `covector publish` step to -check the latest version of a crate, considering the current minor version. -*/ - -const https = require('https') - -const kind = process.argv[2] -const packageName = process.argv[3] -const packageVersion = process.argv[4] -const target = packageVersion.substring(0, packageVersion.lastIndexOf('.')) - -let url = null -switch (kind) { - case 'cargo': - url = `https://crates.io/api/v1/crates/${packageName}` - break - case 'npm': - url = `https://registry.npmjs.org/${packageName}` - break - default: - throw new Error('unexpected kind ' + kind) -} - -const options = { - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - 'User-Agent': 'tauri (https://github.com/tauri-apps/tauri)' - } -} - -https.get(url, options, (response) => { - let chunks = [] - response.on('data', function (chunk) { - chunks.push(chunk) - }) - - response.on('end', function () { - const data = JSON.parse(chunks.join('')) - if (kind === 'cargo') { - const versions = - data.versions?.filter((v) => v.num.startsWith(target)) ?? [] - console.log(versions.length ? versions[0].num : '0.0.0') - } else if (kind === 'npm') { - const versions = Object.keys(data.versions).filter((v) => - v.startsWith(target) - ) - console.log(versions[versions.length - 1] || '0.0.0') - } - }) -})