diff --git a/.releaserc-net.cjs b/.releaserc-net.cjs new file mode 100644 index 0000000000..86feee0074 --- /dev/null +++ b/.releaserc-net.cjs @@ -0,0 +1,234 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +/* + First run `make setup_semantic_release` to install the required dependencies. + + Using this config semantic-release will search for the latest tag + evaluate all commits after that tag + generate release notes and a version bump. + It will commit these changes, push these changes, and publish a new version tag. + + This file requires a `--branches` option to function. + This is to facilitate point releases if needed. + + `npx semantic-release --branches main` +*/ + +const fs = require("fs"); + +/** + * Function to parse a simple properties file + * @param {string} filePath - Path to the properties file + * @returns {Object} Parsed properties as key-value pairs + */ +function parsePropertiesFile(filePath) { + const content = fs.readFileSync(filePath, "utf8"); + const properties = {}; + + content.split("\n").forEach((line) => { + if (line && !line.startsWith("#") && line.includes("=")) { + const [key, ...valueParts] = line.split("="); + properties[key.trim()] = valueParts.join("=").trim(); + } + }); + + return properties; +} + +// Read your project.properties file +const props = parsePropertiesFile("./project.properties"); + +// This project has several runtimes +// each one has files that need to be updated. +// We model all the files and the runtimes here in this structure +const Runtimes = { + net: { + "DynamoDbEncryption/runtimes/net/DynamoDbEncryption.csproj": { + dependencies: [], + assemblyInfo: "DynamoDbEncryption/runtimes/net/AssemblyInfo.cs", + }, + }, +}; + +/** + * @type {import('semantic-release').GlobalConfig} + */ +module.exports = { + branches: ["main"], + repositoryUrl: "git@github.com:aws/aws-database-encryption-sdk-dynamodb.git", + tagFormat: "v${version}-net", + plugins: [ + // Check the commits since the last release + [ + "@semantic-release/commit-analyzer", + { + preset: "conventionalcommits", + parserOpts: { + noteKeywords: ["DOTNET-BREAKING-CHANGE", "DOTNET-BREAKING-CHANGES"], + }, + presetConfig: { + types: [ + { type: "feat", section: "Features" }, + { type: "fix", section: "Fixes" }, + { type: "chore", section: "Maintenance" }, + { type: "docs", section: "Maintenance" }, + { type: "revert", section: "Fixes" }, + { type: "style", hidden: true }, + { type: "refactor", hidden: true }, + { type: "perf", hidden: true }, + { type: "test", hidden: true }, + ], + }, + releaseRules: [ + { type: "docs", release: "patch" }, + { type: "revert", release: "patch" }, + { type: "chore", release: "patch" }, + ], + }, + ], + // Based on the commits generate release notes + [ + "@semantic-release/release-notes-generator", + { + preset: "conventionalcommits", + parserOpts: { + noteKeywords: ["DOTNET-BREAKING-CHANGE", "DOTNET-BREAKING-CHANGES"], + }, + presetConfig: { + types: [ + { + type: "feat", + scope: "dafny", + section: "Features -- All Languages", + hidden: false, + }, + { + type: "feat", + scope: "dotnet", + section: "Features -- DotNet", + hidden: false, + }, + { + type: "fix", + scope: "dafny", + section: "Fixes -- All Languages", + hidden: false, + }, + { + type: "fix", + scope: "dotnet", + section: "Fixes -- DotNet", + hidden: false, + }, + { + type: "chore", + scope: "dafny", + section: "Maintenance -- All Languages", + hidden: false, + }, + { + type: "chore", + scope: "dotnet", + section: "Maintenance -- DotNet", + hidden: false, + }, + { + type: "docs", + scope: "dafny", + section: "Maintenance -- All Languages", + hidden: false, + }, + { + type: "docs", + scope: "dotnet", + section: "Maintenance -- DotNet", + hidden: false, + }, + { + type: "revert", + scope: "dafny", + section: "Fixes -- All Languages", + hidden: false, + }, + { + type: "revert", + scope: "dotnet", + section: "Fixes -- DotNet", + hidden: false, + }, + { type: "style", section: "Miscellaneous", hidden: false }, + { type: "refactor", section: "Miscellaneous", hidden: false }, + { type: "perf", section: "Miscellaneous", hidden: false }, + { type: "test", section: "Miscellaneous", hidden: false }, + ], + }, + }, + ], + // Update the change log with the generated release notes + [ + "@semantic-release/changelog", + { + changelogFile: "CHANGELOG.md", + changelogTitle: "# Changelog", + }, + ], + + // Bump the various versions + [ + "semantic-release-replace-plugin", + { + replacements: [ + // Update the version for all DotNet projects + // Does not update the dependencies + { + files: Object.keys(Runtimes.net), + from: ".*", + to: "${nextRelease.version}", + results: Object.keys(Runtimes.net).map(CheckResults), + countMatches: true, + }, + { + files: Object.keys(Runtimes.net), + from: '', + to: ``, + results: Object.keys(Runtimes.net).map(CheckResults), + countMatches: true, + }, + // Update the AssmeblyInfo.cs file of the DotNet projects + ...Object.entries(Runtimes.net).flatMap( + ([file, { assemblyInfo }]) => ({ + files: assemblyInfo, + from: "assembly: AssemblyVersion(.*)", + to: 'assembly: AssemblyVersion("${nextRelease.version}")]', + results: [CheckResults(assemblyInfo)], + countMatches: true, + }), + ), + ], + }, + ], + // Commit and push changes the changelog and versions bumps + [ + "@semantic-release/git", + { + assets: [ + "CHANGELOG.md", + ...Object.values(Runtimes).flatMap((r) => Object.keys(r)), + ...Object.values(Runtimes.net).flatMap((r) => r.assemblyInfo), + ], + message: + "chore(release): ${nextRelease.version} \n\n${nextRelease.notes}", + }, + ], + ], +}; + +function CheckResults(file) { + return { + file, + hasChanged: true, + numMatches: 1, + numReplacements: 1, + }; +} diff --git a/.releaserc.cjs b/.releaserc.cjs index 21f6d9af3e..25db26cbc4 100644 --- a/.releaserc.cjs +++ b/.releaserc.cjs @@ -48,12 +48,6 @@ const Runtimes = { dependencies: [], }, }, - net: { - "DynamoDbEncryption/runtimes/net/DynamoDbEncryption.csproj": { - dependencies: [], - assemblyInfo: "DynamoDbEncryption/runtimes/net/AssemblyInfo.cs", - }, - }, }; /** @@ -69,7 +63,7 @@ module.exports = { { preset: "conventionalcommits", parserOpts: { - noteKeywords: ["BREAKING CHANGE", "BREAKING CHANGES"], + noteKeywords: ["BREAKING-CHANGE", "BREAKING-CHANGES"], }, presetConfig: { types: [ @@ -97,19 +91,111 @@ module.exports = { { preset: "conventionalcommits", parserOpts: { - noteKeywords: ["BREAKING CHANGE", "BREAKING CHANGES"], + noteKeywords: ["BREAKING-CHANGE", "BREAKING-CHANGES"], }, presetConfig: { types: [ - { type: "feat", section: "Features" }, - { type: "fix", section: "Fixes" }, - { type: "chore", section: "Maintenance" }, - { type: "docs", section: "Maintenance" }, - { type: "revert", section: "Fixes" }, - { type: "style", hidden: true }, - { type: "refactor", hidden: true }, - { type: "perf", hidden: true }, - { type: "test", hidden: true }, + { + type: "feat", + scope: "dafny", + section: "Features -- All Languages", + hidden: false, + }, + { + type: "feat", + scope: "java", + section: "Features -- Java", + hidden: false, + }, + { + type: "feat", + scope: "rust", + section: "Features -- Rust", + hidden: false, + }, + + { + type: "fix", + scope: "dafny", + section: "Fixes -- All Languages", + hidden: false, + }, + { + type: "fix", + scope: "java", + section: "Fixes -- Java", + hidden: false, + }, + { + type: "fix", + scope: "rust", + section: "Fixes -- Rust", + hidden: false, + }, + + { + type: "chore", + scope: "dafny", + section: "Maintenance -- All Languages", + hidden: false, + }, + { + type: "chore", + scope: "java", + section: "Maintenance -- Java", + hidden: false, + }, + { + type: "chore", + scope: "rust", + section: "Maintenance -- Rust", + hidden: false, + }, + { + type: "chore", + section: "Miscellaneous", + hidden: false, + }, + { + type: "docs", + scope: "dafny", + section: "Maintenance -- All Languages", + hidden: false, + }, + { + type: "docs", + scope: "java", + section: "Maintenance -- Java", + hidden: false, + }, + { + type: "docs", + scope: "rust", + section: "Maintenance -- Rust", + hidden: false, + }, + { + type: "revert", + scope: "dafny", + section: "Fixes -- All Languages", + hidden: false, + }, + { + type: "revert", + scope: "java", + section: "Fixes -- Java", + hidden: false, + }, + { + type: "revert", + scope: "rust", + section: "Fixes -- Rust", + hidden: false, + }, + { type: "style", section: "Miscellaneous", hidden: false }, + { type: "refactor", section: "Miscellaneous", hidden: false }, + { type: "perf", section: "Miscellaneous", hidden: false }, + { type: "test", section: "Miscellaneous", hidden: false }, ], }, }, @@ -137,32 +223,6 @@ module.exports = { results: Object.keys(Runtimes.java).map(CheckResults), countMatches: true, }, - // Update the version for all DotNet projects - // Does not update the dependencies - { - files: Object.keys(Runtimes.net), - from: ".*", - to: "${nextRelease.version}", - results: Object.keys(Runtimes.net).map(CheckResults), - countMatches: true, - }, - { - files: Object.keys(Runtimes.net), - from: '', - to: ``, - results: Object.keys(Runtimes.net).map(CheckResults), - countMatches: true, - }, - // Update the AssmeblyInfo.cs file of the DotNet projects - ...Object.entries(Runtimes.net).flatMap( - ([file, { assemblyInfo }]) => ({ - files: assemblyInfo, - from: "assembly: AssemblyVersion(.*)", - to: 'assembly: AssemblyVersion("${nextRelease.version}")]', - results: [CheckResults(assemblyInfo)], - countMatches: true, - }), - ), ], }, ], @@ -173,10 +233,9 @@ module.exports = { assets: [ "CHANGELOG.md", ...Object.values(Runtimes).flatMap((r) => Object.keys(r)), - ...Object.values(Runtimes.net).flatMap((r) => r.assemblyInfo), ], message: - "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}", + "chore(release): ${nextRelease.version} \n\n${nextRelease.notes}", }, ], ], diff --git a/DynamoDbEncryption/runtimes/net/DynamoDbEncryption.csproj b/DynamoDbEncryption/runtimes/net/DynamoDbEncryption.csproj index bddba56f62..1b5db20bc1 100644 --- a/DynamoDbEncryption/runtimes/net/DynamoDbEncryption.csproj +++ b/DynamoDbEncryption/runtimes/net/DynamoDbEncryption.csproj @@ -58,9 +58,6 @@ - - -