-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Revert "feat: add `Predicate.getTransferTxId` helper (#1467)" This reverts commit 70233c1. * feat: implement script and workflow to unpublish old version * chore: changeset
- Loading branch information
1 parent
9352685
commit 03010f8
Showing
5 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: "Unpublish old versions" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
delete_packages: | ||
type: boolean | ||
description: Delete packages? otherwise dry-run mode will be used | ||
default: false | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
clean-npm-versions: | ||
name: Unpublish versions next, preview, master... | ||
runs-on: buildjet-4vcpu-ubuntu-2204 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: FuelLabs/github-actions/setups/node@master | ||
- uses: FuelLabs/github-actions/setups/npm@master | ||
with: | ||
npm-token: ${{ secrets.NPM_TOKEN }} | ||
- run: | | ||
node ./scripts/release-unpublish.js | ||
env: | ||
DELETE_PACKAGES: ${{ github.event.inputs.delete_packages}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
}, | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
"dan": "tsx ./scripts/release-unpublish.ts", | ||
"dev": "nodemon --config nodemon.config.json -x 'pnpm build:packages'", | ||
"build": "turbo run build", | ||
"build:packages": "turbo run build --filter=!docs", | ||
|
@@ -49,6 +50,7 @@ | |
"@changesets/get-github-info": "^0.5.2", | ||
"@fuel-ts/forc": "workspace:*", | ||
"@fuel-ts/fuel-core": "workspace:*", | ||
"@fuel-ts/versions": "workspace:^", | ||
"@internal/tsup": "workspace:*", | ||
"@jest/types": "^29.5.0", | ||
"@types/jest": "^29.5.0", | ||
|
@@ -57,6 +59,7 @@ | |
"@types/web": "^0.0.65", | ||
"@typescript-eslint/eslint-plugin": "^6.9.0", | ||
"@typescript-eslint/parser": "^6.9.0", | ||
"compare-versions": "^6.1.0", | ||
"conventional-changelog-angular": "^5.0.13", | ||
"dotenv": "^9.0.2", | ||
"eslint": "^8.52.0", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { versions } from '@fuel-ts/versions'; | ||
import { exec } from 'child_process'; | ||
import { compare } from 'compare-versions'; | ||
import { readFileSync, readdirSync } from 'fs'; | ||
import { join } from 'path'; | ||
|
||
const DELETE_TAGS = /next|pr/; | ||
const { FUELS: CURRENT_VERSION } = versions; | ||
const DELETE_PACKAGES = process.env.DELETE_PACKAGES === 'true'; | ||
const dryRun = DELETE_PACKAGES ? '' : '--dry-run'; | ||
|
||
const { log, error } = console; | ||
|
||
const getPublicPackages = () => { | ||
const packagesDir = join(__dirname, '../packages'); | ||
const packages = readdirSync(packagesDir, { withFileTypes: true }); | ||
const packagesNames = packages.map((p) => { | ||
try { | ||
const packageContent = readFileSync(join(packagesDir, p.name, 'package.json'), 'utf8'); | ||
const packageJson = JSON.parse(packageContent.toString()); | ||
return packageJson.private ? null : packageJson.name; | ||
} catch (err) { | ||
return null; | ||
} | ||
}); | ||
return packagesNames.filter((p) => !!p); | ||
}; | ||
|
||
const main = async () => { | ||
const packages = getPublicPackages(); | ||
await packages.map(async (packageName) => { | ||
log(`📦 Fetching ${packageName} versions`); | ||
const { versions: packageVersions } = await fetch( | ||
`https://registry.npmjs.org/${packageName}` | ||
).then((resp) => resp.json()); | ||
|
||
const versionsToDelete = Object.keys(packageVersions).filter( | ||
(packageVersion) => | ||
packageVersion.search(DELETE_TAGS) > -1 && !compare(packageVersion, CURRENT_VERSION, '>=') | ||
); | ||
log('The following versions will be deleted:'); | ||
log(versionsToDelete.map((v) => ` - ${v}`).join('\n')); | ||
versionsToDelete.map(async (versionToDelete) => { | ||
const { stderr } = await exec(`npm unpublish ${packageName}@${versionToDelete} ${dryRun}`); | ||
if (stderr) { | ||
log(`❌ Error ${packageName}@${versionToDelete} not deleted!\n`); | ||
} else { | ||
log(`✅ Package ${packageName}@${versionToDelete} deleted!\n`); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
main().catch((err) => { | ||
error(err); | ||
process.exit(1); | ||
}); |