From 1f778166e58a056b41271e943c2fee4b09d2dd02 Mon Sep 17 00:00:00 2001
From: Alan Ross-Ross <11589230+alanrossx2@users.noreply.github.com>
Date: Sat, 25 Jun 2022 01:38:19 -0400
Subject: [PATCH] feat(bumpVersion): add prerelease semver level (#15626)

---
 docs/usage/configuration-options.md                  |  2 +-
 lib/config/options/index.ts                          |  2 +-
 .../manager/maven/__fixtures__/prerelease.pom.xml    |  6 ++++++
 lib/modules/manager/maven/update.spec.ts             | 12 ++++++++++++
 4 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 lib/modules/manager/maven/__fixtures__/prerelease.pom.xml

diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md
index a0a8e74d29..d244610892 100644
--- a/docs/usage/configuration-options.md
+++ b/docs/usage/configuration-options.md
@@ -320,7 +320,7 @@ Currently this setting supports `helmv3`, `npm`, `maven` and `sbt` only, so rais
 Its purpose is if you want Renovate to update the `version` field within your package file any time it updates dependencies within.
 Usually this is for automatic release purposes, so that you don't need to add another step after Renovate before you can release a new version.
 
-Configure this value to `"patch"`, `"minor"` or `"major"` to have Renovate update the version in your edited package file.
+Configure this value to `"prerelease"`, `"patch"`, `"minor"` or `"major"` to have Renovate update the version in your edited package file.
 e.g. if you wish Renovate to always increase the target `package.json` version with a patch update, configure this to `"patch"`.
 
 For `npm` only you can also configure this field to `"mirror:x"` where `x` is the name of a package in the `package.json`.
diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts
index e9c2c29b8a..a5b945ad1c 100644
--- a/lib/config/options/index.ts
+++ b/lib/config/options/index.ts
@@ -1250,7 +1250,7 @@ const options: RenovateOptions[] = [
     name: 'bumpVersion',
     description: 'Bump the version in the package file being updated.',
     type: 'string',
-    allowedValues: ['major', 'minor', 'patch'],
+    allowedValues: ['major', 'minor', 'patch', 'prerelease'],
     supportedManagers: ['helmv3', 'npm', 'maven', 'sbt'],
   },
   // Major/Minor/Patch
diff --git a/lib/modules/manager/maven/__fixtures__/prerelease.pom.xml b/lib/modules/manager/maven/__fixtures__/prerelease.pom.xml
new file mode 100644
index 0000000000..456a22e1e2
--- /dev/null
+++ b/lib/modules/manager/maven/__fixtures__/prerelease.pom.xml
@@ -0,0 +1,6 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>com.mycompany.app</groupId>
+  <artifactId>my-app</artifactId>
+  <version>1.0.0-1</version>
+</project>
\ No newline at end of file
diff --git a/lib/modules/manager/maven/update.spec.ts b/lib/modules/manager/maven/update.spec.ts
index dbe881f8d9..6e735018fe 100644
--- a/lib/modules/manager/maven/update.spec.ts
+++ b/lib/modules/manager/maven/update.spec.ts
@@ -5,6 +5,7 @@ import * as pomUpdater from '.';
 
 const simpleContent = Fixtures.get(`simple.pom.xml`);
 const minimumContent = Fixtures.get(`minimum.pom.xml`);
+const prereleaseContent = Fixtures.get(`prerelease.pom.xml`);
 
 describe('modules/manager/maven/update', () => {
   describe('bumpPackageVersion', () => {
@@ -63,5 +64,16 @@ describe('modules/manager/maven/update', () => {
       );
       expect(bumpedContent).toEqual(simpleContent);
     });
+
+    it('bumps pom.xml version with prerelease semver level', () => {
+      const { bumpedContent } = pomUpdater.bumpPackageVersion(
+        prereleaseContent,
+        '1.0.0-1',
+        'prerelease'
+      );
+
+      const project = new XmlDocument(bumpedContent!);
+      expect(project.valueWithPath('version')).toBe('1.0.0-2');
+    });
   });
 });
-- 
GitLab