|
| 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 | + net: { |
| 23 | + "DynamoDbEncryption/runtimes/net/DynamoDbEncryption.csproj": { |
| 24 | + dependencies: [], |
| 25 | + assemblyInfo: [ |
| 26 | + "DynamoDbEncryption/runtimes/net/AssemblyInfo.cs" |
| 27 | + ] |
| 28 | + } |
| 29 | + }, |
| 30 | +}; |
| 31 | + |
| 32 | +/** |
| 33 | + * @type {import('semantic-release').GlobalConfig} |
| 34 | + */ |
| 35 | +module.exports = { |
| 36 | + branches: ["main"], |
| 37 | + repositoryUrl: |
| 38 | + "[email protected]:aws/aws-database-encryption-sdk-dynamodb.git", |
| 39 | + plugins: [ |
| 40 | + // Check the commits since the last release |
| 41 | + ["@semantic-release/commit-analyzer", |
| 42 | + { |
| 43 | + "preset": "conventionalcommits", |
| 44 | + "parserOpts": { |
| 45 | + "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"] |
| 46 | + }, |
| 47 | + "presetConfig": { |
| 48 | + "types": [ |
| 49 | + {"type": "feat", "section": "Features"}, |
| 50 | + {"type": "fix", "section": "Fixes"}, |
| 51 | + {"type": "chore", "section": "Maintenance"}, |
| 52 | + {"type": "docs", "section": "Maintenance"}, |
| 53 | + {"type": "revert", "section": "Fixes"}, |
| 54 | + {"type": "style", "hidden": true}, |
| 55 | + {"type": "refactor", "hidden": true}, |
| 56 | + {"type": "perf", "hidden": true}, |
| 57 | + {"type": "test", "hidden": true} |
| 58 | + ] |
| 59 | + }, |
| 60 | + "releaseRules": [ |
| 61 | + {"type": "docs", "release": "patch"}, |
| 62 | + {"type": "revert", "release": "patch"}, |
| 63 | + {"type": "chore", "release": "patch"} |
| 64 | + ] |
| 65 | + }, |
| 66 | + ], |
| 67 | + // Based on the commits generate release notes |
| 68 | + ["@semantic-release/release-notes-generator", |
| 69 | + { |
| 70 | + "preset": "conventionalcommits", |
| 71 | + "parserOpts": { |
| 72 | + "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"] |
| 73 | + }, |
| 74 | + "presetConfig": { |
| 75 | + "types": [ |
| 76 | + {"type": "feat", "section": "Features"}, |
| 77 | + {"type": "fix", "section": "Fixes"}, |
| 78 | + {"type": "chore", "section": "Maintenance"}, |
| 79 | + {"type": "docs", "section": "Maintenance"}, |
| 80 | + {"type": "revert", "section": "Fixes"}, |
| 81 | + {"type": "style", "hidden": true}, |
| 82 | + {"type": "refactor", "hidden": true}, |
| 83 | + {"type": "perf", "hidden": true}, |
| 84 | + {"type": "test", "hidden": true} |
| 85 | + ] |
| 86 | + } |
| 87 | + } |
| 88 | + ], |
| 89 | + // Update the change log with the generated release notes |
| 90 | + [ |
| 91 | + "@semantic-release/changelog", |
| 92 | + { |
| 93 | + changelogFile: "CHANGELOG.md", |
| 94 | + changelogTitle: "# Changelog", |
| 95 | + }, |
| 96 | + ], |
| 97 | + |
| 98 | + // Bump the various versions |
| 99 | + [ |
| 100 | + "semantic-release-replace-plugin", |
| 101 | + { |
| 102 | + replacements: [ |
| 103 | + // Update the version for all DotNet projects |
| 104 | + // Does not update the dependencies |
| 105 | + { |
| 106 | + files: Object.keys(Runtimes.net), |
| 107 | + from: "<Version>.*</Version>", |
| 108 | + to: "<Version>${nextRelease.version}</Version>", |
| 109 | + results: Object.keys(Runtimes.net).map(CheckResults), |
| 110 | + countMatches: true, |
| 111 | + }, |
| 112 | + // Update the AssmeblyInfo.cs file of the DotNet projects |
| 113 | + ...Object.entries(Runtimes.net).flatMap( |
| 114 | + ([file, { assemblyInfo }]) => ({ |
| 115 | + files: assemblyInfo, |
| 116 | + from: "assembly: AssemblyVersion(.*)", |
| 117 | + to: 'assembly: AssemblyVersion("${nextRelease.version}")]', |
| 118 | + results: [CheckResults(assemblyInfo)], |
| 119 | + countMatches: true, |
| 120 | + }), |
| 121 | + ), |
| 122 | + ], |
| 123 | + }, |
| 124 | + ], |
| 125 | + // Commit and push changes the changelog and versions bumps |
| 126 | + [ |
| 127 | + "@semantic-release/git", |
| 128 | + { |
| 129 | + assets: [ |
| 130 | + "CHANGELOG.md", |
| 131 | + ...Object.values(Runtimes).flatMap((r) => Object.keys(r)), |
| 132 | + ...Object.values(Runtimes.net).flatMap((r) => r.assemblyInfo), |
| 133 | + ], |
| 134 | + message: |
| 135 | + "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}", |
| 136 | + }, |
| 137 | + ], |
| 138 | + ], |
| 139 | +}; |
| 140 | + |
| 141 | +function CheckResults(file) { |
| 142 | + return { |
| 143 | + file, |
| 144 | + hasChanged: true, |
| 145 | + numMatches: 1, |
| 146 | + numReplacements: 1, |
| 147 | + }; |
| 148 | +} |
0 commit comments