Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Auto publishing packages to package managers #20

Closed
agdimech opened this issue Mar 10, 2022 · 1 comment
Closed

[FEAT] Auto publishing packages to package managers #20

agdimech opened this issue Mar 10, 2022 · 1 comment
Labels

Comments

@agdimech
Copy link
Contributor

Being able to publish designated libs to package managers would be very useful.

For instance, if I had a monorepo as such:

A
 |- B (py)
 |- C (java)
 |- D (ts)
 |- E (ts)

If I wanted to say publish packages B, C and D to CodeArtifact we should support the following config on the PDKPipeline:

interface PublishConfig {
  packagesToPublish?: string[];
}

interface CodeArtifactPublishConfig extends PublishConfig {
   codeArtifactArn?: string; // If this is set, all other options are ignored
   authTokenSecretArn?: string; // defaults to a generated secret with the token pre-initialized
   authTokenRotation?: boolean; // defaults to true
   domainName: string;
   domainOwner?: string; //defaults to pipeline account
   repositoryName: string;
}

new pdk_pipeline.PDKPipeline(this, 'ApplicationPipeline', {
      primarySynthDirectory: 'packages/infra/cdk.out',
      repositoryName: 'monorepo',
      publishAssetsInParallel: false,
      crossAccountKeys: true,
      synth: {},
      publishConfig: {
          codeArtifactPublishConfig: {
              domainName: '<domain>',
              repositoryName: '<repo-name>',
              packagesToPublish: ['B', 'C', 'D']
          },
      }
    });

In this instance, the Pipeline is configured to publish artifacts to a a new CodeArtifact. In terms of how this would work, a high level algorithm is as follows:

  1. Scan the repo based on the packagesToPublish to identify candidate packages for publishing. (Not sure if we should fail silently or loudly if a package is listed for publishing which is not supported i.e: GO)
  2. Generate a .versionrc file in the root with a list of bumpFiles.
  3. bump the versions by using standard-version. We will need to potentially write custom updates for languages like python or java as we will need to update pom.xml and *.toml
  4. build all packages so that a dist dir is created in each package
  5. unbump all packages that were previously bumped
  6. run git diff --ignore-space-at-eol --exit-code (this makes sure src is identical to how it was before we bumped)
  7. Use npx publlib to publish each package

This can later be extended to have MavenPublishConfig, PyPiPublishConfig, etc.

@github-actions
Copy link

This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant