From ec588156afaad39f41886d96ebfbb17653216482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9lcio=20Franco?= Date: Fri, 22 Mar 2024 14:53:17 -0400 Subject: [PATCH] chore: remove npm publish (#1165) Make `@fuel-wallet/connections` and `@fuel-wallet/types` private packages. --- .changeset/slimy-windows-prove.md | 7 +++ .github/setup-forc/action.yml | 26 ---------- ...elease-npm.yaml => release-changeset.yaml} | 33 +++--------- .github/workflows/release-npm-latest.yaml | 33 ------------ .github/workflows/release-npm-preview.yaml | 51 ------------------- .github/workflows/update-sdk-cron.yaml | 4 ++ .github/workflows/update-sdk-manual.yaml | 4 ++ biome.json | 1 + packages/connections/package.json | 1 + packages/types/package.json | 1 + scripts/unpublish.js | 18 ++++--- 11 files changed, 35 insertions(+), 144 deletions(-) create mode 100644 .changeset/slimy-windows-prove.md delete mode 100644 .github/setup-forc/action.yml rename .github/workflows/{release-npm.yaml => release-changeset.yaml} (72%) delete mode 100644 .github/workflows/release-npm-latest.yaml delete mode 100644 .github/workflows/release-npm-preview.yaml diff --git a/.changeset/slimy-windows-prove.md b/.changeset/slimy-windows-prove.md new file mode 100644 index 0000000000..f9377fa111 --- /dev/null +++ b/.changeset/slimy-windows-prove.md @@ -0,0 +1,7 @@ +--- +"@fuel-wallet/connections": patch +"@fuel-wallet/types": patch +--- + +ci: make connections and types packages private +we don't need to use publish them anymore because it's going to be used only by the CRX \ No newline at end of file diff --git a/.github/setup-forc/action.yml b/.github/setup-forc/action.yml deleted file mode 100644 index 9966a26568..0000000000 --- a/.github/setup-forc/action.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: 'Setup Forc' - -inputs: - rust-version: - description: "Rust version" - default: 1.73.0 - forc-version: - description: "Forc version" - default: 0.46.0 - fuel-core-version: - description: "Fuel core version" - default: 0.20.7 - -runs: - using: 'composite' - steps: - - name: Install Rust Toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ inputs.rust-version }} - # selecting a toolchain either by action or manual `rustup` calls should happen - # before the cache plugin, as it uses the current rustc version as its cache key - override: true - - - uses: Swatinem/rust-cache@v1 diff --git a/.github/workflows/release-npm.yaml b/.github/workflows/release-changeset.yaml similarity index 72% rename from .github/workflows/release-npm.yaml rename to .github/workflows/release-changeset.yaml index c5563b6ff8..3aa8514880 100644 --- a/.github/workflows/release-npm.yaml +++ b/.github/workflows/release-changeset.yaml @@ -21,10 +21,10 @@ jobs: with: # need this to get full git-history/clone in order to build changelogs and check changesets fetch-depth: 0 + # workaround to ensure force pushes to changeset branch use REPO_TOKEN owner's account + # see https://github.com/changesets/action/issues/70 + persist-credentials: false - uses: FuelLabs/github-actions/setups/node@master - - uses: FuelLabs/github-actions/setups/npm@master - with: - npm-token: ${{ secrets.NPM_TOKEN }} - name: Bump and Collect Version run: | @@ -39,13 +39,6 @@ jobs: git config --global user.name "${{ github.actor }}" git config --global user.email "${{ github.actor }}@users.noreply.github.com" - - name: Build Libs - run: pnpm build:libs - env: - ## increase node.js m memory limit for building - ## with sourcemaps - NODE_OPTIONS: "--max-old-space-size=4096" - - name: Build Fuel Wallet run: pnpm build:crx env: @@ -62,11 +55,10 @@ jobs: APP_VERSION_POSTFIX: "-development" NODE_OPTIONS: "--max-old-space-size=4096" - - name: Create Release Pull Request or Publish to NPM + - name: Create Release Pull Request id: changesets uses: FuelLabs/changesets-action@main with: - publish: pnpm changeset publish --tag rc commit: "ci(changesets): versioning packages" title: "ci(changesets): versioning packages" createGithubReleases: aggregate @@ -74,20 +66,9 @@ jobs: githubTagName: v${{ env.BUILD_VERSION }} env: GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - - name: Release to @master tag - if: steps.changesets.outputs.published != 'true' - run: | - git checkout master - pnpm changeset version --snapshot master - pnpm changeset publish --tag master - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Upload aritifacts to Sentry - if: steps.changesets.outputs.published == 'true' + - name: Upload artifacts to Sentry + if: !steps.changesets.outputs.pullRequestNumber run: | pnpm sentry-cli sourcemaps inject --release ${{ env.BUILD_VERSION }} ./dist-crx pnpm sentry-cli sourcemaps upload --release ${{ env.BUILD_VERSION }} ./dist-crx @@ -98,7 +79,7 @@ jobs: working-directory: ./packages/app - name: Attach Fuel Wallet to release - if: steps.changesets.outputs.published == 'true' + if: !steps.changesets.outputs.pullRequestNumber uses: softprops/action-gh-release@v1 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-npm-latest.yaml b/.github/workflows/release-npm-latest.yaml deleted file mode 100644 index 7b2272ca5f..0000000000 --- a/.github/workflows/release-npm-latest.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: "Release latest" - -on: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - BUILD_VERSION: "" - -jobs: - release-npm-latest: - name: Tag packages as latest - runs-on: buildjet-4vcpu-ubuntu-2204 - steps: - - uses: actions/checkout@v3 - with: - # need this to get full git-history/clone in order to build changelogs and check changesets - fetch-depth: 0 - - uses: FuelLabs/github-actions/setups/node@master - - uses: FuelLabs/github-actions/setups/npm@master - with: - npm-token: ${{ secrets.NPM_TOKEN }} - - - name: Collect current version - run: | - echo "BUILD_VERSION=$(pnpm -s packages:version)" >> $GITHUB_ENV - - - name: Change tag to latest - run: | - npm dist-tag add @fuel-wallet/types@${{ env.BUILD_VERSION }} latest diff --git a/.github/workflows/release-npm-preview.yaml b/.github/workflows/release-npm-preview.yaml deleted file mode 100644 index 43a2575d4c..0000000000 --- a/.github/workflows/release-npm-preview.yaml +++ /dev/null @@ -1,51 +0,0 @@ -name: Release to @preview tag on npm - -on: - workflow_dispatch: - -env: - BUILD_VERSION: "" - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - release-changesets: - name: Release to @preview tag on npm - runs-on: buildjet-4vcpu-ubuntu-2204 - permissions: - pull-requests: write - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: FuelLabs/github-actions/setups/node@master - - uses: FuelLabs/github-actions/setups/npm@master - with: - npm-token: ${{ secrets.NPM_TOKEN }} - - - name: Build Libs - run: pnpm build:libs - env: - ## increase node.js m memory limit for building - ## with sourcemaps - NODE_OPTIONS: "--max-old-space-size=4096" - - - name: Release to @preview tag on npm - id: release - run: | - pnpm changeset version --snapshot preview - changetsets=$(pnpm changeset publish --tag preview) - echo "BUILD_VERSION=$(pnpm -s packages:version)" >> $GITHUB_ENV - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Comment release package name to PR - uses: mshick/add-pr-comment@v2 - with: - message: | - This PR is published in NPM with version **${{ env.BUILD_VERSION }}** - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-sdk-cron.yaml b/.github/workflows/update-sdk-cron.yaml index d15e5461f9..28fa63f2d9 100644 --- a/.github/workflows/update-sdk-cron.yaml +++ b/.github/workflows/update-sdk-cron.yaml @@ -22,6 +22,10 @@ jobs: steps: - uses: actions/checkout@v3 + with: + # workaround to ensure force pushes to changeset branch use REPO_TOKEN owner's account + # see https://github.com/changesets/action/issues/70 + persist-credentials: false - uses: FuelLabs/github-actions/setups/node@master - name: Checking updates diff --git a/.github/workflows/update-sdk-manual.yaml b/.github/workflows/update-sdk-manual.yaml index a53a7c4de3..861bd0d5ae 100644 --- a/.github/workflows/update-sdk-manual.yaml +++ b/.github/workflows/update-sdk-manual.yaml @@ -32,6 +32,10 @@ jobs: steps: - uses: actions/checkout@v3 + with: + # workaround to ensure force pushes to changeset branch use REPO_TOKEN owner's account + # see https://github.com/changesets/action/issues/70 + persist-credentials: false - uses: FuelLabs/github-actions/setups/node@master - name: Checking updates diff --git a/biome.json b/biome.json index 59257a4be5..f04cc50283 100644 --- a/biome.json +++ b/biome.json @@ -40,6 +40,7 @@ }, "files": { "ignore": [ + ".changeset", ".vscode", "**/scripts", "**/node_modules", diff --git a/packages/connections/package.json b/packages/connections/package.json index 139f2c56b0..7e4f21cbfe 100644 --- a/packages/connections/package.json +++ b/packages/connections/package.json @@ -1,5 +1,6 @@ { "name": "@fuel-wallet/connections", + "private": true, "description": "Fuel Wallet Connections for CRX.", "version": "0.16.1", "license": "Apache-2.0", diff --git a/packages/types/package.json b/packages/types/package.json index 67fe825c9a..f7207d126d 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,5 +1,6 @@ { "name": "@fuel-wallet/types", + "private": true, "version": "0.16.1", "license": "Apache-2.0", "main": "src/index.ts", diff --git a/scripts/unpublish.js b/scripts/unpublish.js index bafbbf7d06..fdb40b16ec 100644 --- a/scripts/unpublish.js +++ b/scripts/unpublish.js @@ -5,27 +5,29 @@ const { compare } = require('compare-versions'); const exec = util.promisify(require('node:child_process').exec); const { version } = require('../packages/app/package.json'); -const DELETE_TAGS = /next|preview/; +const DELETE_TAGS = /next|preview|master|rc/; const CURRENT_VERSION = version; const DELETE_PACKAGES = process.env.DELETE_PACKAGES === 'true'; const dryRun = DELETE_PACKAGES ? '' : '--dry-run'; async function getPublicPackages() { - const packages = await readdir(join(__dirname, '../packages'), { + const base = join(__dirname, '../packages'); + const packages = await readdir(base, { withFileTypes: true, }); + const packagesNames = await Promise.all( packages.map(async (p) => { try { const packageContent = await readFile( - join(p.path, p.name, 'package.json'), + join(base, p.name, 'package.json'), 'utf8' ); - const package = JSON.parse(packageContent.toString()); + const pkg = JSON.parse(packageContent.toString()); - if (package.private) return null; - return package.name; - } catch (err) { + if (pkg.private) return null; + return pkg.name; + } catch (_err) { return null; } }) @@ -34,7 +36,7 @@ async function getPublicPackages() { } async function main() { - console.log(`Get public packages`); + console.log('Get public packages'); const packages = await getPublicPackages(); for (const packageName of packages) {