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
This commit is contained in:
Jacob Bolda 2024-08-18 05:54:59 -05:00 committed by GitHub
parent 23a912bb84
commit ee0b53fbe2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 95 deletions

View File

@ -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 '<details>\n<summary><em><h4>Cargo Publish</h4></em></summary>\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</details>\n'",
"dryRunCommand": true,
"pipe": true
},
{
"command": "npm pack",
"dryRunCommand": true
}
],
"publish": [
"sleep 15s",
{
"command": "echo '<details>\n<summary><em><h4>PNPM Publish</h4></em></summary>\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": {

View File

@ -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')
}
})
})