| 
 | 1 | +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.  | 
 | 2 | +// SPDX-License-Identifier: Apache-2.0  | 
 | 3 | + | 
 | 4 | +/*  | 
 | 5 | +  First run `make setup_semantic_release` to install the required dependencies.  | 
 | 6 | +
  | 
 | 7 | +  Using this config semantic-release will search for the latest tag  | 
 | 8 | +  evaluate all commits after that tag  | 
 | 9 | +  generate release notes and a version bump.  | 
 | 10 | +  It will commit these changes, push these changes, and publish a new version tag.  | 
 | 11 | +
  | 
 | 12 | +  This file requires a `--branches` option to function.  | 
 | 13 | +  This is to facilitate point releases if needed.  | 
 | 14 | +
  | 
 | 15 | +  `npx semantic-release --branches main`  | 
 | 16 | +*/  | 
 | 17 | + | 
 | 18 | +// This project has several runtimes  | 
 | 19 | +// each one has files that need to be updated.  | 
 | 20 | +// We model all the files and the runtimes here in this structure  | 
 | 21 | +const Runtimes = {  | 
 | 22 | +  java: {  | 
 | 23 | +    "project.properties": {  | 
 | 24 | +      dependencies: [],  | 
 | 25 | +    },  | 
 | 26 | +  },  | 
 | 27 | +  net: {  | 
 | 28 | +    "DynamoDbEncryption/runtimes/net/DynamoDbEncryption.csproj": {  | 
 | 29 | +      dependencies: [],  | 
 | 30 | +      assemblyInfo: "DynamoDbEncryption/runtimes/net/AssemblyInfo.cs",  | 
 | 31 | +    }  | 
 | 32 | +  },  | 
 | 33 | +};  | 
 | 34 | + | 
 | 35 | +/**  | 
 | 36 | + * @type {import('semantic-release').GlobalConfig}  | 
 | 37 | + */  | 
 | 38 | +module.exports = {  | 
 | 39 | +  branches: ["main"],  | 
 | 40 | +  repositoryUrl:  | 
 | 41 | +    "git@github.com:aws/aws-database-encryption-sdk-dynamodb.git",  | 
 | 42 | +  plugins: [  | 
 | 43 | +    // Check the commits since the last release  | 
 | 44 | +    ["@semantic-release/commit-analyzer",  | 
 | 45 | +      {  | 
 | 46 | +        "preset": "conventionalcommits",  | 
 | 47 | +        "parserOpts": {  | 
 | 48 | +          "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"]  | 
 | 49 | +        },  | 
 | 50 | +        "presetConfig": {  | 
 | 51 | +          "types": [  | 
 | 52 | +            {"type": "feat", "section": "Features"},  | 
 | 53 | +            {"type": "fix", "section": "Fixes"},  | 
 | 54 | +            {"type": "chore", "section": "Maintenance"},  | 
 | 55 | +            {"type": "docs", "section": "Maintenance"},  | 
 | 56 | +            {"type": "revert", "section": "Fixes"},  | 
 | 57 | +            {"type": "style", "hidden": true},  | 
 | 58 | +            {"type": "refactor", "hidden": true},  | 
 | 59 | +            {"type": "perf", "hidden": true},  | 
 | 60 | +            {"type": "test", "hidden": true}  | 
 | 61 | +          ]  | 
 | 62 | +        },  | 
 | 63 | +        "releaseRules": [  | 
 | 64 | +          {"type": "docs", "release": "patch"},  | 
 | 65 | +          {"type": "revert", "release": "patch"},  | 
 | 66 | +          {"type": "chore", "release": "patch"}  | 
 | 67 | +        ]  | 
 | 68 | +      },  | 
 | 69 | +    ],  | 
 | 70 | +    // Based on the commits generate release notes  | 
 | 71 | +    ["@semantic-release/release-notes-generator",  | 
 | 72 | +      {  | 
 | 73 | +        "preset": "conventionalcommits",  | 
 | 74 | +        "parserOpts": {  | 
 | 75 | +          "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"]  | 
 | 76 | +        },  | 
 | 77 | +        "presetConfig": {  | 
 | 78 | +            "types": [  | 
 | 79 | +                {"type": "feat", "section": "Features"},  | 
 | 80 | +                {"type": "fix", "section": "Fixes"},  | 
 | 81 | +                {"type": "chore", "section": "Maintenance"},  | 
 | 82 | +                {"type": "docs", "section": "Maintenance"},  | 
 | 83 | +                {"type": "revert", "section": "Fixes"},  | 
 | 84 | +                {"type": "style", "hidden": true},  | 
 | 85 | +                {"type": "refactor", "hidden": true},  | 
 | 86 | +                {"type": "perf", "hidden": true},  | 
 | 87 | +                {"type": "test", "hidden": true}  | 
 | 88 | +            ]  | 
 | 89 | +        }  | 
 | 90 | +      }  | 
 | 91 | +    ],  | 
 | 92 | +    // Update the change log with the generated release notes  | 
 | 93 | +    [  | 
 | 94 | +      "@semantic-release/changelog",  | 
 | 95 | +      {  | 
 | 96 | +        changelogFile: "CHANGELOG.md",  | 
 | 97 | +        changelogTitle: "# Changelog",  | 
 | 98 | +      },  | 
 | 99 | +    ],  | 
 | 100 | + | 
 | 101 | +    // Bump the various versions  | 
 | 102 | +    [  | 
 | 103 | +      "semantic-release-replace-plugin",  | 
 | 104 | +      {  | 
 | 105 | +        replacements: [  | 
 | 106 | +          // Update the version for all Gradle Java projects  | 
 | 107 | +          // Does not update the dependencies  | 
 | 108 | +          {  | 
 | 109 | +            files: Object.keys(Runtimes.java),  | 
 | 110 | +            from: "projectJavaVersion=.*",  | 
 | 111 | +            to: 'projectJavaVersion=${nextRelease.version}',  | 
 | 112 | +            results: Object.keys(Runtimes.java).map(CheckResults),  | 
 | 113 | +            countMatches: true,  | 
 | 114 | +          },  | 
 | 115 | +          // Update the version for all DotNet projects  | 
 | 116 | +          // Does not update the dependencies  | 
 | 117 | +          {  | 
 | 118 | +            files: Object.keys(Runtimes.net),  | 
 | 119 | +            from: "<Version>.*</Version>",  | 
 | 120 | +            to: "<Version>${nextRelease.version}</Version>",  | 
 | 121 | +            results: Object.keys(Runtimes.net).map(CheckResults),  | 
 | 122 | +            countMatches: true,  | 
 | 123 | +          },  | 
 | 124 | +          // Update the AssmeblyInfo.cs file of the DotNet projects  | 
 | 125 | +          ...Object.entries(Runtimes.net).flatMap(  | 
 | 126 | +            ([file, { assemblyInfo }]) => ({  | 
 | 127 | +              files: assemblyInfo,  | 
 | 128 | +              from: "assembly: AssemblyVersion(.*)",  | 
 | 129 | +              to: 'assembly: AssemblyVersion("${nextRelease.version}")]',  | 
 | 130 | +              results: [CheckResults(assemblyInfo)],  | 
 | 131 | +              countMatches: true,  | 
 | 132 | +            }),  | 
 | 133 | +          ),  | 
 | 134 | +        ],  | 
 | 135 | +      },  | 
 | 136 | +    ],  | 
 | 137 | +    // Commit and push changes the changelog and versions bumps  | 
 | 138 | +    [  | 
 | 139 | +      "@semantic-release/git",  | 
 | 140 | +      {  | 
 | 141 | +        assets: [  | 
 | 142 | +          "CHANGELOG.md",  | 
 | 143 | +          ...Object.values(Runtimes).flatMap((r) => Object.keys(r)),  | 
 | 144 | +          ...Object.values(Runtimes.net).flatMap((r) => r.assemblyInfo),  | 
 | 145 | +        ],  | 
 | 146 | +        message:  | 
 | 147 | +          "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",  | 
 | 148 | +      },  | 
 | 149 | +    ],  | 
 | 150 | +  ],  | 
 | 151 | +};  | 
 | 152 | + | 
 | 153 | +function CheckResults(file) {  | 
 | 154 | +  return {  | 
 | 155 | +    file,  | 
 | 156 | +    hasChanged: true,  | 
 | 157 | +    numMatches: 1,  | 
 | 158 | +    numReplacements: 1,  | 
 | 159 | +  };  | 
 | 160 | +}  | 
0 commit comments