From 44efdc0af9950e40a8e6a98743f8c7479eb9b9dc Mon Sep 17 00:00:00 2001 From: Nara Kasbergen Date: Wed, 13 Dec 2023 12:35:44 +0100 Subject: [PATCH] chore: safer handling of Go module deprecation --- src/deprecate-packages.ts | 5 +++-- test/__snapshots__/index.test.ts.snap | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/deprecate-packages.ts b/src/deprecate-packages.ts index 25b7e305..639905d1 100644 --- a/src/deprecate-packages.ts +++ b/src/deprecate-packages.ts @@ -32,10 +32,11 @@ export class DeprecatePackages { const deprecationStep: JobStep = { name: "Mark the Go module as deprecated", - run: `find 'dist/go' -mindepth 2 -maxdepth 3 -type f -name 'go.mod' | xargs sed -i '1s|^|${deprecationMessageForGo} \n|'`, + run: `find '.repo/dist/go' -mindepth 2 -maxdepth 4 -type f -name 'go.mod' | xargs sed -i '1s|^|${deprecationMessageForGo} \n|'`, + continueOnError: true, // @TODO remove this once we confirm it to be working }; if (isDeprecated) { - packageInfo.publishToGo?.prePublishSteps?.push(deprecationStep); + packageInfo.publishToGo?.prePublishSteps?.splice(-1, 0, deprecationStep); } const releaseWorkflow = project.github?.tryFindWorkflow("release"); diff --git a/test/__snapshots__/index.test.ts.snap b/test/__snapshots__/index.test.ts.snap index 1bffd9eb..803da6ce 100644 --- a/test/__snapshots__/index.test.ts.snap +++ b/test/__snapshots__/index.test.ts.snap @@ -1035,16 +1035,17 @@ jobs: continue-on-error: true - name: Copy the README file to the parent directory run: cp .repo/dist/go/*/README.md .repo/dist/go/README.md - - name: Collect go Artifact - run: mv .repo/dist dist - name: Mark the Go module as deprecated run: |- - find 'dist/go' -mindepth 2 -maxdepth 3 -type f -name 'go.mod' | xargs sed -i '1s|^|// Deprecated: HashiCorp is no longer publishing new versions of the prebuilt provider for random. + find '.repo/dist/go' -mindepth 2 -maxdepth 4 -type f -name 'go.mod' | xargs sed -i '1s|^|// Deprecated: HashiCorp is no longer publishing new versions of the prebuilt provider for random. // Previously-published versions of this prebuilt provider will still continue to be available as installable Go modules, // but these will not be compatible with newer versions of CDK for Terraform and are not eligible for commercial support. // You can continue to use the random provider in your CDK for Terraform projects with newer versions of CDKTF, // but you will need to generate the bindings locally. See https://cdk.tf/imports for details. |' + continue-on-error: true + - name: Collect go Artifact + run: mv .repo/dist dist - name: Release env: GIT_USER_NAME: CDK for Terraform Team