From 765e07caf99d28d6bc66f4e5e224f5b265a6bfcb Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Wed, 6 Dec 2023 14:54:22 -0300 Subject: [PATCH 01/28] Revert "feat: add `Predicate.getTransferTxId` helper (#1467)" This reverts commit 70233c1e579e607bdc2714b9b8039ea0eaac40a9. --- ...nd-and-spend-funds-from-predicates.test.ts | 21 ++----------- .../send-and-spend-funds-from-predicates.md | 6 ---- packages/predicate/package.json | 1 - packages/predicate/src/predicate.ts | 30 +------------------ packages/wallet/src/account.ts | 30 ++++--------------- pnpm-lock.yaml | 7 +++-- 6 files changed, 12 insertions(+), 83 deletions(-) diff --git a/apps/docs-snippets/src/guide/predicates/send-and-spend-funds-from-predicates.test.ts b/apps/docs-snippets/src/guide/predicates/send-and-spend-funds-from-predicates.test.ts index 6fcddf6adde..0f7ce1ae338 100644 --- a/apps/docs-snippets/src/guide/predicates/send-and-spend-funds-from-predicates.test.ts +++ b/apps/docs-snippets/src/guide/predicates/send-and-spend-funds-from-predicates.test.ts @@ -9,10 +9,7 @@ import { BaseAssetId, } from 'fuels'; -import { - DocSnippetProjectsEnum, - getDocsSnippetsForcProject, -} from '../../../test/fixtures/forc-projects'; +import { DocSnippetProjectsEnum, getDocsSnippetsForcProject } from '../../../test/fixtures/forc-projects'; import { getTestWallet } from '../../utils'; describe(__filename, () => { @@ -53,22 +50,11 @@ describe(__filename, () => { predicate.setData(inputAddress); // #endregion send-and-spend-funds-from-predicates-4 + // #region send-and-spend-funds-from-predicates-5 const receiverWallet = WalletUnlocked.generate({ provider, }); - // #region send-and-spend-funds-from-predicates-8 - const txId = await predicate.getTransferTxId( - receiverWallet.address, - amountToPredicate - 150_000, - BaseAssetId, - { - gasPrice, - } - ); - // #endregion send-and-spend-funds-from-predicates-8 - - // #region send-and-spend-funds-from-predicates-5 const tx2 = await predicate.transfer( receiverWallet.address, amountToPredicate - 150_000, @@ -80,9 +66,6 @@ describe(__filename, () => { await tx2.waitForResult(); // #endregion send-and-spend-funds-from-predicates-5 - const txIdFromExecutedTx = tx2.id; - - expect(txId).toEqual(txIdFromExecutedTx); }); it('should fail when trying to spend predicates entire amount', async () => { diff --git a/apps/docs/src/guide/predicates/send-and-spend-funds-from-predicates.md b/apps/docs/src/guide/predicates/send-and-spend-funds-from-predicates.md index 68c8695edd3..337b0d79d8c 100644 --- a/apps/docs/src/guide/predicates/send-and-spend-funds-from-predicates.md +++ b/apps/docs/src/guide/predicates/send-and-spend-funds-from-predicates.md @@ -38,12 +38,6 @@ Note the method transfer has two parameters: the recipient's address and the int Once the predicate resolves with a return value `true` based on its predefined condition, our predicate successfully spends its funds by means of a transfer to a desired wallet. ---- - -You can also use the `getTransferTxId` helper to obtain the transaction ID of the transfer beforehand, without actually executing it. - -<<< @/../../docs-snippets/src/guide/predicates/send-and-spend-funds-from-predicates.test.ts#send-and-spend-funds-from-predicates-8{ts:line-numbers} - ## Spending Entire Predicate Held Amount Trying to forward the entire amount held by the predicate results in an error because no funds are left to cover the transaction fees. Attempting this will result in an error message like: diff --git a/packages/predicate/package.json b/packages/predicate/package.json index 15e7bf94815..a45badd0f87 100644 --- a/packages/predicate/package.json +++ b/packages/predicate/package.json @@ -28,7 +28,6 @@ "@fuel-ts/abi-coder": "workspace:*", "@fuel-ts/address": "workspace:*", "@fuel-ts/interfaces": "workspace:*", - "@fuel-ts/math": "workspace:*", "@fuel-ts/merkle": "workspace:*", "@fuel-ts/providers": "workspace:*", "@fuel-ts/transactions": "workspace:*", diff --git a/packages/predicate/src/predicate.ts b/packages/predicate/src/predicate.ts index 673337bc402..7449097e079 100644 --- a/packages/predicate/src/predicate.ts +++ b/packages/predicate/src/predicate.ts @@ -7,11 +7,8 @@ import { calculateVmTxMemory, } from '@fuel-ts/abi-coder'; import { Address } from '@fuel-ts/address'; -import { BaseAssetId } from '@fuel-ts/address/configs'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { hashTransaction } from '@fuel-ts/hasher'; -import type { AbstractAddress, AbstractPredicate } from '@fuel-ts/interfaces'; -import type { BigNumberish } from '@fuel-ts/math'; +import type { AbstractPredicate } from '@fuel-ts/interfaces'; import type { CallResult, Provider, @@ -20,7 +17,6 @@ import type { } from '@fuel-ts/providers'; import { transactionRequestify } from '@fuel-ts/providers'; import { ByteArrayCoder, InputType } from '@fuel-ts/transactions'; -import type { TxParamsType } from '@fuel-ts/wallet'; import { Account } from '@fuel-ts/wallet'; import type { BytesLike } from 'ethers'; import { getBytesCopy, hexlify } from 'ethers'; @@ -96,30 +92,6 @@ export class Predicate extends Account implements Abs return super.sendTransaction(transactionRequest); } - /** - * Returns the transaction ID for a transfer transaction, without sending it. - * - * @param destination - The address of the destination. - * @param amount - The amount of coins to transfer. - * @param assetId - The asset ID of the coins to transfer. - * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity). - * @returns A promise that resolves to the transaction ID. - */ - async getTransferTxId( - /** Address of the destination */ - destination: AbstractAddress, - /** Amount of coins */ - amount: BigNumberish, - /** Asset ID of coins */ - assetId: BytesLike = BaseAssetId, - /** Tx Params */ - txParams: TxParamsType = {} - ): Promise { - const request = await super.prepareTransferTxRequest(destination, amount, assetId, txParams); - const populatedRequest = this.populateTransactionPredicateData(request); - return hashTransaction(populatedRequest, this.provider.getChainId()); - } - /** * Simulates a transaction with the populated predicate data. * diff --git a/packages/wallet/src/account.ts b/packages/wallet/src/account.ts index 18bbedbc512..12695799a6b 100644 --- a/packages/wallet/src/account.ts +++ b/packages/wallet/src/account.ts @@ -32,7 +32,7 @@ import { formatScriptDataForTransferringToContract, } from './utils'; -export type TxParamsType = Pick; +type TxParamsType = Pick; /** * `Account` provides an abstraction for interacting with accounts or wallets on the network. @@ -239,36 +239,16 @@ export class Account extends AbstractAccount { /** Tx Params */ txParams: TxParamsType = {} ): Promise { - const request = await this.prepareTransferTxRequest(destination, amount, assetId, txParams); - return this.sendTransaction(request); - } - - /** - * A helper that prepares a transaction request for calculating the transaction ID. - * - * @param destination - The address of the destination. - * @param amount - The amount of coins to transfer. - * @param assetId - The asset ID of the coins to transfer. - * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity). - * @returns A promise that resolves to the prepared transaction request. - */ - protected async prepareTransferTxRequest( - /** Address of the destination */ - destination: AbstractAddress, - /** Amount of coins */ - amount: BigNumberish, - /** Asset ID of coins */ - assetId: BytesLike = BaseAssetId, - /** Tx Params */ - txParams: TxParamsType = {} - ): Promise { const { maxGasPerTx } = this.provider.getGasConfig(); const params: TxParamsType = { gasLimit: maxGasPerTx, ...txParams }; const request = new ScriptTransactionRequest(params); request.addCoinOutput(destination, amount, assetId); + const { maxFee, requiredQuantities } = await this.provider.getTransactionCost(request); + await this.fund(request, requiredQuantities, maxFee); - return request; + + return this.sendTransaction(request); } /** diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 088ad532f3f..39b72e6804e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -870,9 +870,6 @@ importers: '@fuel-ts/interfaces': specifier: workspace:* version: link:../interfaces - '@fuel-ts/math': - specifier: workspace:* - version: link:../math '@fuel-ts/merkle': specifier: workspace:* version: link:../merkle @@ -894,6 +891,10 @@ importers: ethers: specifier: ^6.7.1 version: 6.7.1 + devDependencies: + '@fuel-ts/math': + specifier: workspace:* + version: link:../math packages/program: dependencies: From 6fd519718c0544f089750c13325774b018093411 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 8 Dec 2023 17:31:20 -0300 Subject: [PATCH 02/28] chore: add rc workflow --- .github/workflows/rc-release.yaml | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/rc-release.yaml diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml new file mode 100644 index 00000000000..337362cba83 --- /dev/null +++ b/.github/workflows/rc-release.yaml @@ -0,0 +1,50 @@ +name: Release to @pr- tag on npm +on: + pull_request: + branches: + - rc/* + workflow_dispatch: + +jobs: + release-pr: + name: "Release RC to npm" + runs-on: ubuntu-latest + permissions: write-all + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + + - name: CI Setup + uses: ./.github/actions/ci-setup + + - name: Ensure NPM access + run: npm whoami + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Build + run: pnpm build + + - name: Release to @${{ github.head_ref }} tag on npm + id: release + run: | + pnpm changeset:next + git add .changeset/fuel-labs-ci.md + pnpm changeset version --snapshot pr-${{ env.RC_NAME }} + changetsets=$(pnpm changeset publish --tag pr-${{ env.RC_NAME }}) + published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-pr-${{ env.RC_NAME }}-\d+' | head -1) + echo "published_version=$published_version" >> $GITHUB_OUTPUT + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RC_NAME: ${{ github.head_ref }} + + - uses: mshick/add-pr-comment@v2 + with: + message: | + This RC is published in NPM with version **${{ steps.release.outputs.published_version }}** + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b9767222b53b998178d39a4203298bbce39326f9 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 8 Dec 2023 17:31:41 -0300 Subject: [PATCH 03/28] chore: changeset --- .changeset/flat-dodos-crash.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changeset/flat-dodos-crash.md diff --git a/.changeset/flat-dodos-crash.md b/.changeset/flat-dodos-crash.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/flat-dodos-crash.md @@ -0,0 +1,2 @@ +--- +--- From 763bebdcb10fe35e480073a45d138cd9c876b9fd Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 8 Dec 2023 17:33:40 -0300 Subject: [PATCH 04/28] chore: change rc workflow name --- .github/workflows/rc-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 337362cba83..97d636ec5cd 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -1,4 +1,4 @@ -name: Release to @pr- tag on npm +name: Release to @rc tag on npm on: pull_request: branches: From 6db0f2f557f16afacb80472113bbbe544e90b972 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 8 Dec 2023 17:36:15 -0300 Subject: [PATCH 05/28] chore: fix rc version --- .github/workflows/rc-release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 97d636ec5cd..67a59411308 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -34,8 +34,8 @@ jobs: pnpm changeset:next git add .changeset/fuel-labs-ci.md pnpm changeset version --snapshot pr-${{ env.RC_NAME }} - changetsets=$(pnpm changeset publish --tag pr-${{ env.RC_NAME }}) - published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-pr-${{ env.RC_NAME }}-\d+' | head -1) + changetsets=$(pnpm changeset publish --tag ${{ env.RC_NAME }}) + published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-${{ env.RC_NAME }}-\d+' | head -1) echo "published_version=$published_version" >> $GITHUB_OUTPUT env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 7331613aa07ae4aeb1cb7755afc6153eae6dbc20 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 8 Dec 2023 17:42:04 -0300 Subject: [PATCH 06/28] chore: remove workflow dispatch for rc worjflow --- .github/workflows/rc-release.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 67a59411308..3a009a4f809 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -3,7 +3,6 @@ on: pull_request: branches: - rc/* - workflow_dispatch: jobs: release-pr: From 9c6a59bfc13ec577cb0d9bccd2e8d07990c93587 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 8 Dec 2023 17:56:57 -0300 Subject: [PATCH 07/28] chore: add correct rc naming --- .github/workflows/rc-release.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 3a009a4f809..8b810ff133a 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -4,6 +4,9 @@ on: branches: - rc/* +env: + RC_NAME: ${{ github.head_ref }} + jobs: release-pr: name: "Release RC to npm" @@ -27,7 +30,12 @@ jobs: - name: Build run: pnpm build - - name: Release to @${{ github.head_ref }} tag on npm + - name: Write RC version + run: | + RC_NAME=${GITHUB_REF_NAME#rc//} + echo "RC_NAME=$RC_NAME" >> $GITHUB_ENV + + - name: Release to @${{ env.RC_NAME }} tag on npm id: release run: | pnpm changeset:next @@ -39,7 +47,7 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RC_NAME: ${{ github.head_ref }} + RC_NAME: ${{ env.RC_NAME }} - uses: mshick/add-pr-comment@v2 with: From 6ec1c2e2d375804b6744148ccdf78315b6ee086d Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 8 Dec 2023 18:01:42 -0300 Subject: [PATCH 08/28] chore: use correct branch filtering --- .github/workflows/rc-release.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 8b810ff133a..132da577cf6 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -1,8 +1,9 @@ name: Release to @rc tag on npm + on: pull_request: branches: - - rc/* + - 'rc/*' env: RC_NAME: ${{ github.head_ref }} From f38ddf2c00b6df487901e16cf089e26525e4451d Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 8 Dec 2023 18:03:16 -0300 Subject: [PATCH 09/28] chore: linting --- .github/workflows/rc-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 132da577cf6..455ff6162aa 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -3,7 +3,7 @@ name: Release to @rc tag on npm on: pull_request: branches: - - 'rc/*' + - "rc/*" env: RC_NAME: ${{ github.head_ref }} From 82ede8926a038f8d5a3e7827826ffc06da7af358 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 8 Dec 2023 18:15:22 -0300 Subject: [PATCH 10/28] chore: alter branch name env --- .github/workflows/rc-release.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 455ff6162aa..82864be90ba 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -6,7 +6,7 @@ on: - "rc/*" env: - RC_NAME: ${{ github.head_ref }} + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} jobs: release-pr: @@ -36,7 +36,7 @@ jobs: RC_NAME=${GITHUB_REF_NAME#rc//} echo "RC_NAME=$RC_NAME" >> $GITHUB_ENV - - name: Release to @${{ env.RC_NAME }} tag on npm + - name: Release to @${{ env.BRANCH_NAME }} tag on npm id: release run: | pnpm changeset:next @@ -48,7 +48,7 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RC_NAME: ${{ env.RC_NAME }} + RC_NAME: ${{ env.BRANCH_NAME }} - uses: mshick/add-pr-comment@v2 with: From afac09190b4c7cbdb5027b5d561549efc96d26f2 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 8 Dec 2023 18:22:39 -0300 Subject: [PATCH 11/28] chore: change pull request to push --- .github/workflows/rc-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 82864be90ba..7645384cde7 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -1,7 +1,7 @@ name: Release to @rc tag on npm on: - pull_request: + push: branches: - "rc/*" From f2f35d5de140d60eb1442dc0881caebf060b8346 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 14:27:40 +0000 Subject: [PATCH 12/28] feat: set correct rc versiuon in worflow --- .github/workflows/rc-release.yaml | 36 ++++++++++++++++--------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 7645384cde7..3d93d6b8072 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -1,12 +1,13 @@ name: Release to @rc tag on npm -on: - push: - branches: - - "rc/*" +# TODO: Implement when PR complete +# on: +# push: +# branches: +# - "rc/*" -env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} +on: + pull_request: jobs: release-pr: @@ -31,28 +32,29 @@ jobs: - name: Build run: pnpm build - - name: Write RC version - run: | - RC_NAME=${GITHUB_REF_NAME#rc//} - echo "RC_NAME=$RC_NAME" >> $GITHUB_ENV + - name: Replace head ref + uses: frabert/replace-string-action@v2 + id: new_head_ref + with: + string: "${{ github.head_ref }}" + pattern: "/" + replace-with: "-" - - name: Release to @${{ env.BRANCH_NAME }} tag on npm + - name: Release to @${{ steps.new_head_ref.outputs.replaced }} tag on npm id: release run: | pnpm changeset:next git add .changeset/fuel-labs-ci.md - pnpm changeset version --snapshot pr-${{ env.RC_NAME }} - changetsets=$(pnpm changeset publish --tag ${{ env.RC_NAME }}) - published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-${{ env.RC_NAME }}-\d+' | head -1) - echo "published_version=$published_version" >> $GITHUB_OUTPUT + pnpm changeset version --snapshot ${{ steps.new_head_ref.outputs.replaced }} + changetsets=$(pnpm changeset publish --tag ${{ steps.new_head_ref.outputs.replaced }}) + echo "published_version=$changetsets" >> $GITHUB_OUTPUT env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RC_NAME: ${{ env.BRANCH_NAME }} - uses: mshick/add-pr-comment@v2 with: message: | - This RC is published in NPM with version **${{ steps.release.outputs.published_version }}** + This RC is published in NPM with version **${{ steps.new_head_ref.outputs.replaced }}** env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a0a953e1fdf5452c77689f2c09e9880a5fba6141 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 14:30:48 +0000 Subject: [PATCH 13/28] feat: add echo rc verison --- .github/workflows/rc-release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 3d93d6b8072..52ab6039b6e 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -43,6 +43,7 @@ jobs: - name: Release to @${{ steps.new_head_ref.outputs.replaced }} tag on npm id: release run: | + echo "RC Version: ${{ steps.new_head_ref.outputs.replaced }}" pnpm changeset:next git add .changeset/fuel-labs-ci.md pnpm changeset version --snapshot ${{ steps.new_head_ref.outputs.replaced }} From 116e2398581a5c1b6fb8f9ee4035fe0d1b20175b Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 15:31:54 +0000 Subject: [PATCH 14/28] chore: test ci --- .github/workflows/rc-release.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 52ab6039b6e..50257f6f0d7 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -45,10 +45,6 @@ jobs: run: | echo "RC Version: ${{ steps.new_head_ref.outputs.replaced }}" pnpm changeset:next - git add .changeset/fuel-labs-ci.md - pnpm changeset version --snapshot ${{ steps.new_head_ref.outputs.replaced }} - changetsets=$(pnpm changeset publish --tag ${{ steps.new_head_ref.outputs.replaced }}) - echo "published_version=$changetsets" >> $GITHUB_OUTPUT env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From cae799314b6acc655ad2f7d29304922e0b79e5d3 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 15:34:46 +0000 Subject: [PATCH 15/28] chore: test ci --- .github/workflows/rc-release.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 50257f6f0d7..14a67d3738b 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -45,6 +45,8 @@ jobs: run: | echo "RC Version: ${{ steps.new_head_ref.outputs.replaced }}" pnpm changeset:next + git add .changeset/fuel-labs-ci.md + pnpm changeset version --snapshot ${{ steps.new_head_ref.outputs.replaced }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e4761e2e691e794649a7184a1b8a14cbb79d927b Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 15:44:14 +0000 Subject: [PATCH 16/28] chore: echo changesets --- .github/workflows/rc-release.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 14a67d3738b..c46616888d9 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -47,6 +47,8 @@ jobs: pnpm changeset:next git add .changeset/fuel-labs-ci.md pnpm changeset version --snapshot ${{ steps.new_head_ref.outputs.replaced }} + changesets=$(pnpm changeset publish --tag ${{ steps.new_head_ref.outputs.replaced }}) + echo "changesets: $changesets" env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b4d6ea5134827b14b7fea37eb2535c309547dc37 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 15:50:16 +0000 Subject: [PATCH 17/28] chore: use env in rc changeset --- .github/workflows/rc-release.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index c46616888d9..1ecd0829d2a 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -43,15 +43,16 @@ jobs: - name: Release to @${{ steps.new_head_ref.outputs.replaced }} tag on npm id: release run: | - echo "RC Version: ${{ steps.new_head_ref.outputs.replaced }}" + echo "RC Version: ${{ env.RC_NAME }}" pnpm changeset:next git add .changeset/fuel-labs-ci.md - pnpm changeset version --snapshot ${{ steps.new_head_ref.outputs.replaced }} - changesets=$(pnpm changeset publish --tag ${{ steps.new_head_ref.outputs.replaced }}) + pnpm changeset version --snapshot ${{ env.RC_NAME }} + changesets=$(pnpm changeset publish --tag ${{ env.RC_NAME }}) echo "changesets: $changesets" env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RC_NAME: ${{ steps.new_head_ref.outputs.replaced }} - uses: mshick/add-pr-comment@v2 with: From d7c4196c550837abc518967c36df79ea51637c13 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 16:15:35 +0000 Subject: [PATCH 18/28] test dan release --- .github/workflows/rc-release.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 1ecd0829d2a..fdc7773fed2 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -46,9 +46,10 @@ jobs: echo "RC Version: ${{ env.RC_NAME }}" pnpm changeset:next git add .changeset/fuel-labs-ci.md - pnpm changeset version --snapshot ${{ env.RC_NAME }} - changesets=$(pnpm changeset publish --tag ${{ env.RC_NAME }}) - echo "changesets: $changesets" + pnpm changeset version --snapshot dan + changesets=$(pnpm changeset publish --tag dan + published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+dan-\d+' | head -1) + echo "published_version=$published_version" >> $GITHUB_OUTPUT env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0de979e791715298054ba17b03d3ef6cdee545b4 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 16:20:06 +0000 Subject: [PATCH 19/28] chore: enable pr release --- .github/workflows/pr-release.yaml | 2 +- .github/workflows/rc-release.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-release.yaml b/.github/workflows/pr-release.yaml index 9b48fc2352a..a562c283fdc 100644 --- a/.github/workflows/pr-release.yaml +++ b/.github/workflows/pr-release.yaml @@ -8,7 +8,7 @@ jobs: name: "Release PR to npm" runs-on: ubuntu-latest # comment out if:false to enable release PR to npm - if: false + if: true permissions: write-all steps: - name: Checkout diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index fdc7773fed2..1a3693b654b 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -47,7 +47,7 @@ jobs: pnpm changeset:next git add .changeset/fuel-labs-ci.md pnpm changeset version --snapshot dan - changesets=$(pnpm changeset publish --tag dan + changetsets=$(pnpm changeset publish --tag dan published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+dan-\d+' | head -1) echo "published_version=$published_version" >> $GITHUB_OUTPUT env: From 139c86b09bb9af79305eb8bbaff07745bed81636 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 16:24:59 +0000 Subject: [PATCH 20/28] chore: copy pr relase --- .github/workflows/pr-release.yaml | 2 +- .github/workflows/rc-release.yaml | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr-release.yaml b/.github/workflows/pr-release.yaml index a562c283fdc..9b48fc2352a 100644 --- a/.github/workflows/pr-release.yaml +++ b/.github/workflows/pr-release.yaml @@ -8,7 +8,7 @@ jobs: name: "Release PR to npm" runs-on: ubuntu-latest # comment out if:false to enable release PR to npm - if: true + if: false permissions: write-all steps: - name: Checkout diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 1a3693b654b..9f640f3816d 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -1,4 +1,4 @@ -name: Release to @rc tag on npm +name: Release to @rc- tag on npm # TODO: Implement when PR complete # on: @@ -43,17 +43,16 @@ jobs: - name: Release to @${{ steps.new_head_ref.outputs.replaced }} tag on npm id: release run: | - echo "RC Version: ${{ env.RC_NAME }}" pnpm changeset:next git add .changeset/fuel-labs-ci.md - pnpm changeset version --snapshot dan - changetsets=$(pnpm changeset publish --tag dan - published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+dan-\d+' | head -1) + pnpm changeset version --snapshot pr-${{ env.PR_NUMBER }} + changetsets=$(pnpm changeset publish --tag pr-${{ env.PR_NUMBER }}) + published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-pr-${{ env.PR_NUMBER }}-\d+' | head -1) echo "published_version=$published_version" >> $GITHUB_OUTPUT env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RC_NAME: ${{ steps.new_head_ref.outputs.replaced }} + PR_NUMBER: ${{ github.event.pull_request.number }} - uses: mshick/add-pr-comment@v2 with: From da9b159e23ec3ec14b36a34e572e7eadd2bd7415 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 16:37:10 +0000 Subject: [PATCH 21/28] try rc nam,e --- .github/workflows/rc-release.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 9f640f3816d..e2fb2a4320a 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -45,14 +45,15 @@ jobs: run: | pnpm changeset:next git add .changeset/fuel-labs-ci.md - pnpm changeset version --snapshot pr-${{ env.PR_NUMBER }} - changetsets=$(pnpm changeset publish --tag pr-${{ env.PR_NUMBER }}) - published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-pr-${{ env.PR_NUMBER }}-\d+' | head -1) + pnpm changeset version --snapshot pr-${{ env.RC_NAME }} + changetsets=$(pnpm changeset publish --tag pr-${{ env.RC_NAME }}) + published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-pr-${{ env.RC_NAME }}-\d+' | head -1) echo "published_version=$published_version" >> $GITHUB_OUTPUT env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} + RC_NAME: ${{ steps.new_head_ref.outputs.replaced }} - uses: mshick/add-pr-comment@v2 with: From 576448ab714ae0fbc570b94555d617d38a37a2c7 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 16:41:19 +0000 Subject: [PATCH 22/28] use salamander --- .github/workflows/rc-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index e2fb2a4320a..c6106b69f27 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -53,7 +53,7 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} - RC_NAME: ${{ steps.new_head_ref.outputs.replaced }} + RC_NAME: salamander - uses: mshick/add-pr-comment@v2 with: From f77737a4701afb66197b02e4d0a7cd1f5ceb630d Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 16:51:41 +0000 Subject: [PATCH 23/28] chore: use rc name --- .github/workflows/rc-release.yaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index c6106b69f27..e31dc576dde 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -34,30 +34,31 @@ jobs: - name: Replace head ref uses: frabert/replace-string-action@v2 - id: new_head_ref + id: new_ref with: - string: "${{ github.head_ref }}" + string: ${{ github.ref }} pattern: "/" replace-with: "-" - - name: Release to @${{ steps.new_head_ref.outputs.replaced }} tag on npm + - name: Release to @${{ steps.new_ref.outputs.replaced }} tag on npm id: release run: | + echo "${{ steps.new_ref.outputs.replaced }}}}" pnpm changeset:next git add .changeset/fuel-labs-ci.md - pnpm changeset version --snapshot pr-${{ env.RC_NAME }} - changetsets=$(pnpm changeset publish --tag pr-${{ env.RC_NAME }}) - published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-pr-${{ env.RC_NAME }}-\d+' | head -1) + pnpm changeset version --snapshot rc-${{ env.RC_NAME }} + changetsets=$(pnpm changeset publish --tag rc-${{ env.RC_NAME }}) + published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-rc-${{ env.RC_NAME }}-\d+' | head -1) echo "published_version=$published_version" >> $GITHUB_OUTPUT env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} - RC_NAME: salamander + RC_NAME: ${{ steps.new_ref.outputs.replaced }} - uses: mshick/add-pr-comment@v2 with: message: | - This RC is published in NPM with version **${{ steps.new_head_ref.outputs.replaced }}** + This RC is published in NPM with version **${{ steps.new_ref.outputs.replaced }}** env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d8660a27e66878000a4e69eaaaa7db7c081d5e0e Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 16:57:55 +0000 Subject: [PATCH 24/28] use: salamander --- .github/workflows/rc-release.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index e31dc576dde..57c31ae8c0b 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -34,16 +34,16 @@ jobs: - name: Replace head ref uses: frabert/replace-string-action@v2 - id: new_ref + id: rc_name with: string: ${{ github.ref }} - pattern: "/" - replace-with: "-" + pattern: "rc/" + replace-with: "" - - name: Release to @${{ steps.new_ref.outputs.replaced }} tag on npm + - name: Release to @${{ steps.rc_name.outputs.replaced }} tag on npm id: release run: | - echo "${{ steps.new_ref.outputs.replaced }}}}" + echo "${{ steps.rc_name.outputs.replaced }}" pnpm changeset:next git add .changeset/fuel-labs-ci.md pnpm changeset version --snapshot rc-${{ env.RC_NAME }} @@ -54,11 +54,11 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} - RC_NAME: ${{ steps.new_ref.outputs.replaced }} + RC_NAME: ${{ steps.rc_name.outputs.replaced }} - uses: mshick/add-pr-comment@v2 with: message: | - This RC is published in NPM with version **${{ steps.new_ref.outputs.replaced }}** + This RC is published in NPM with version **rc-${{ steps.rc_name.outputs.replaced }}** env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 5d7c931bdc4a7907dcac17b05990d1d563de59d5 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 17:07:44 +0000 Subject: [PATCH 25/28] chore: test salamander --- .github/workflows/rc-release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 57c31ae8c0b..75daf9dd8c9 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -32,7 +32,7 @@ jobs: - name: Build run: pnpm build - - name: Replace head ref + - name: Get RC name uses: frabert/replace-string-action@v2 id: rc_name with: @@ -54,7 +54,7 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} - RC_NAME: ${{ steps.rc_name.outputs.replaced }} + RC_NAME: salamander - uses: mshick/add-pr-comment@v2 with: From 5060fc7a27152c2e17733bfb2434ac16c5a75c4a Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 14 Dec 2023 17:14:10 +0000 Subject: [PATCH 26/28] chore: fix workflow trigger --- .github/workflows/rc-release.yaml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 75daf9dd8c9..acb4ecc4278 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -1,13 +1,9 @@ name: Release to @rc- tag on npm -# TODO: Implement when PR complete -# on: -# push: -# branches: -# - "rc/*" - on: - pull_request: + push: + branches: + - "rc/*" jobs: release-pr: @@ -54,7 +50,7 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} - RC_NAME: salamander + RC_NAME: ${{ steps.rc_name.outputs.replaced }} - uses: mshick/add-pr-comment@v2 with: From aa93de7fac90d1605e1903b7422d0938257c3bc1 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 15 Dec 2023 09:57:25 +0000 Subject: [PATCH 27/28] chore: remove env rc name --- .github/workflows/rc-release.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index acb4ecc4278..6cdc7d2891b 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -42,15 +42,13 @@ jobs: echo "${{ steps.rc_name.outputs.replaced }}" pnpm changeset:next git add .changeset/fuel-labs-ci.md - pnpm changeset version --snapshot rc-${{ env.RC_NAME }} - changetsets=$(pnpm changeset publish --tag rc-${{ env.RC_NAME }}) - published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-rc-${{ env.RC_NAME }}-\d+' | head -1) + pnpm changeset version --snapshot rc-${{ steps.rc_name.outputs.replaced }} + changetsets=$(pnpm changeset publish --tag rc-${{ steps.rc_name.outputs.replaced }}) + published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-rc-${{ steps.rc_name.outputs.replaced }}-\d+' | head -1) echo "published_version=$published_version" >> $GITHUB_OUTPUT env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} - RC_NAME: ${{ steps.rc_name.outputs.replaced }} - uses: mshick/add-pr-comment@v2 with: From 608ad9b8e20cef1699d1dc55f6880fb6f4644f0c Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 15 Dec 2023 12:34:39 +0000 Subject: [PATCH 28/28] chore: update rc suffix --- .github/workflows/rc-release.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 6cdc7d2891b..7d41d291a39 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -34,7 +34,7 @@ jobs: with: string: ${{ github.ref }} pattern: "rc/" - replace-with: "" + replace-with: "rc-" - name: Release to @${{ steps.rc_name.outputs.replaced }} tag on npm id: release @@ -42,9 +42,9 @@ jobs: echo "${{ steps.rc_name.outputs.replaced }}" pnpm changeset:next git add .changeset/fuel-labs-ci.md - pnpm changeset version --snapshot rc-${{ steps.rc_name.outputs.replaced }} - changetsets=$(pnpm changeset publish --tag rc-${{ steps.rc_name.outputs.replaced }}) - published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-rc-${{ steps.rc_name.outputs.replaced }}-\d+' | head -1) + pnpm changeset version --snapshot ${{ steps.rc_name.outputs.replaced }} + changetsets=$(pnpm changeset publish --tag ${{ steps.rc_name.outputs.replaced }}) + published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-${{ steps.rc_name.outputs.replaced }}-\d+' | head -1) echo "published_version=$published_version" >> $GITHUB_OUTPUT env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} @@ -53,6 +53,6 @@ jobs: - uses: mshick/add-pr-comment@v2 with: message: | - This RC is published in NPM with version **rc-${{ steps.rc_name.outputs.replaced }}** + This RC is published in NPM with version **${{ steps.rc_name.outputs.replaced }}** env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}