Skip to content

Commit 6a78377

Browse files
authored
Merge pull request #12 from conveyal/dev
New release
2 parents 260bc9b + 74b7a7e commit 6a78377

File tree

5 files changed

+65
-41
lines changed

5 files changed

+65
-41
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Optionally, you can also use this enable this tool to create and push some commi
1414

1515
This tool is intended to automate the releases of maven projects to maven central. However, a lot of manual steps unfortunately must be taken to get your maven project setup so it can work properly. Big thanks to Nathan Fischer for detailing how to do a lot of these steps in a blog post [here](http://www.debonair.io/post/maven-cd/).
1616

17+
If your project merely wants to take advantage of committing version numbers and creating nice release notes on your github project, you can skip steps 1-4. In step 5, the creation of the maven artifact signing key can be skipped and the `skip-maven-deploy` flag must be set.
18+
1719
### Step 1: Setup an account with OSSRH
1820

1921
Follow [this guide](http://central.sonatype.org/pages/ossrh-guide.html#initial-setup).
@@ -76,6 +78,13 @@ after_success:
7678
- semantic-release --prepare @conveyal/maven-semantic-release --publish @semantic-release/github,@conveyal/maven-semantic-release --verify-conditions @semantic-release/github,@conveyal/maven-semantic-release --verify-release @conveyal/maven-semantic-release --use-conveyal-workflow --dev-branch=dev
7779
```
7880

81+
It is also possible to skip deploying to maven central, but still incrementing the version in pom.xml by setting the flag `skip-maven-deploy`. For example:
82+
83+
```
84+
after_success:
85+
- semantic-release --prepare @conveyal/maven-semantic-release --publish @semantic-release/github,@conveyal/maven-semantic-release --verify-conditions @semantic-release/github,@conveyal/maven-semantic-release --verify-release @conveyal/maven-semantic-release --use-conveyal-workflow --dev-branch=dev --skip-maven-deploy
86+
```
87+
7988
#### before_install
8089

8190
Be sure to include the import of your signing keys. If you followed everything correctly in step 4 you should have something like the following added to your .travis.yml file:

lib/maven.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const {exec, getError} = require('./util')
22

33
/**
4-
* Change the pom.xml file, commit the change and then push it to the repo
4+
* Change the version number in the pom.xml file(s)
55
*/
66
async function updateVersionInPomXml (logger, versionStr) {
77
logger.log(`Updating pom.xml to version ${versionStr}`)

lib/publish.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ module.exports = async function publish (pluginConfig, context) {
1111
const {logger, nextRelease, options} = context
1212
printVersion(logger)
1313

14-
await deploy(logger, nextRelease)
14+
if (!options.skipMavenDeploy) {
15+
await deploy(logger, nextRelease)
16+
}
1517

1618
// special logic to do some extra Conveyal-specific tasks
1719
if (options.useConveyalWorkflow) {

lib/verify-conditions.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const {getError, getPomInfo, printVersion} = require('./util')
77
* Verify that the maven project is properly setup to allow deployment to maven central
88
*/
99
module.exports = async function verifyConditions (pluginConfig, context) {
10-
const {logger} = context
10+
const {logger, options} = context
1111
printVersion(logger)
1212

1313
// make sure pom.xml file is good to go
@@ -16,17 +16,19 @@ module.exports = async function verifyConditions (pluginConfig, context) {
1616
validatePomXml(pomXml)
1717
logger.log('pom.xml validation successful')
1818

19-
// make sure maven-settings file exists
20-
logger.log('validating maven-settings.xml')
21-
const stats = await fs.stat('./maven-settings.xml')
19+
if (!options.skipMavenDeploy) {
20+
// make sure maven-settings file exists
21+
logger.log('validating maven-settings.xml')
22+
const stats = await fs.stat('./maven-settings.xml')
2223

23-
if (!stats) {
24-
throw getError('ENOMAVENSETTINGS')
25-
}
24+
if (!stats) {
25+
throw getError('ENOMAVENSETTINGS')
26+
}
2627

27-
logger.log('validating maven-settings.xml')
28+
logger.log('maven-settings.xml validation successful')
2829

29-
// HELP WANTED: do more validation of maven-settings.xml file and OSSRH login
30+
// HELP WANTED: do more validation of maven-settings.xml file and OSSRH login
31+
}
3032
}
3133

3234
/**

lib/verify-release.js

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,19 @@ module.exports = async function verifyRelease (pluginConfig, context) {
1212

1313
const pomXml = await getPomInfo(logger)
1414
const pomVersion = pomXml.project.version[0]
15-
const mavenCentralVersion = await getLatestVersionFromMavenCentral(
16-
pomXml,
17-
logger
18-
)
1915
const lastReleaseVersion = context.lastRelease.version
2016

21-
if (!semver.valid(mavenCentralVersion)) {
22-
logger.log(
23-
'WARNING: maven central version of %s is an invalid semver version',
24-
mavenCentralVersion
25-
)
26-
}
27-
17+
// check integrity of pom version
2818
if (!semver.valid(pomVersion)) {
2919
logger.log(
3020
'WARNING: pom.xml version of %s is an invalid semver version',
3121
pomVersion
3222
)
3323
}
3424

35-
if (
36-
semver.inc(mavenCentralVersion, 'patch') !==
37-
semver.inc(pomVersion, 'patch')
38-
) {
39-
logger.log(
40-
'WARNING: maven central version of %s differs widely from pom version of %s',
41-
mavenCentralVersion,
42-
pomVersion
43-
)
44-
}
45-
46-
if (lastReleaseVersion !== mavenCentralVersion) {
47-
logger.log(
48-
'WARNING: maven central version of %s differs from last version of %s found in git history',
49-
mavenCentralVersion,
50-
lastReleaseVersion
51-
)
52-
}
53-
25+
// make sure the difference in versions doesn't differ too much
26+
// this is sort of a safegaurd against the pom.xml version straying from the
27+
// git version too much through manual edits to pom.xml
5428
if (semver.inc(lastReleaseVersion, 'patch') !== semver.inc(pomVersion, 'patch')) {
5529
// only throw an error if using the Conveyal workflow
5630
if (options.useConveyalWorkflow) {
@@ -61,6 +35,43 @@ module.exports = async function verifyRelease (pluginConfig, context) {
6135
)
6236
}
6337
}
38+
39+
// if deploying to maven central, do some more checks of the version found in
40+
// the pom.xml versus what is on maven central
41+
// These checks only result in warnings as the git tags are the source of
42+
// truth for the last version number
43+
if (!options.skipMavenDeploy) {
44+
const mavenCentralVersion = await getLatestVersionFromMavenCentral(
45+
pomXml,
46+
logger
47+
)
48+
49+
if (!semver.valid(mavenCentralVersion)) {
50+
logger.log(
51+
'WARNING: maven central version of %s is an invalid semver version',
52+
mavenCentralVersion
53+
)
54+
}
55+
56+
if (
57+
semver.inc(mavenCentralVersion, 'patch') !==
58+
semver.inc(pomVersion, 'patch')
59+
) {
60+
logger.log(
61+
'WARNING: maven central version of %s differs widely from pom version of %s',
62+
mavenCentralVersion,
63+
pomVersion
64+
)
65+
}
66+
67+
if (lastReleaseVersion !== mavenCentralVersion) {
68+
logger.log(
69+
'WARNING: maven central version of %s differs from last version of %s found in git history',
70+
mavenCentralVersion,
71+
lastReleaseVersion
72+
)
73+
}
74+
}
6475
}
6576

6677
/**

0 commit comments

Comments
 (0)