Skip to content

Commit

Permalink
feat(sonatype): Add Sonatype release (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugo-vrijswijk authored and nicojs committed Apr 5, 2019
1 parent 0645ced commit f5447d6
Show file tree
Hide file tree
Showing 9 changed files with 289 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ node_modules
dist
dist-test
.stryker-tmp
reports
reports

target/
pom.xml.versionsBackup
packages/*/mvn/resources/
27 changes: 27 additions & 0 deletions mvn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Maven artifacts

This is the base for the deployment of the packages to Sonatype, so they can be used in any Java/Scala/etc project.

There are no classes or source files in the project. Instead, only the resources are included in the project. The used resources are the `dist/` folder for each project, with the packaged resources in `$project-name/` for the corresponding project. It should only be built after the npm project is built.

There is no version defined in the project. Instead, the version is read in the `package.json` of the npm project, and set in the release script (`mvnPublish.sh`).

The artifacts can be added as follows (replace `mutation-testing-elements` with `mutation-testing-report-schema` if you need the report):

Maven:

```xml
<dependency>
<groupId>io.stryker-mutator</groupId>
<artifactId>mutation-testing-elements</artifactId>
<version>${mutation-testing-elements.version}</version> <!-- Version defined elsewhere -->
</dependency>
```

Sbt:

```scala
libraryDependencies += "io.stryker-mutator" % "mutation-testing-elements" % elementsVersion // Version defined elsewhere
```

Replace `mutation-testing-elements` with `mutation-testing-report-schema` if you need the report.
22 changes: 22 additions & 0 deletions mvn/mvnPublish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e

# Called from packages/$project by npm postpublish, so the pwd is already the project folder

PROJ_BASE=$(basename `pwd`)
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[", ]//g')

echo "Deploying $PROJ_BASE $PACKAGE_VERSION..."

echo "Copying dist files to resources"
mkdir -p mvn/resources
cp -r dist mvn/resources/$PROJ_BASE

echo "Starting deploy process"
cd mvn
mvn -P release versions:set "-DnewVersion=$PACKAGE_VERSION"
mvn -P release deploy --settings ../../../mvn/settings.xml
9 changes: 9 additions & 0 deletions mvn/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>ossrh</id>
<username>${env.SONATYPE_USERNAME}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>
</settings>
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"lerna:version:patch": "lerna version --conventional-commits patch",
"lerna:version:minor": "lerna version --conventional-commits minor",
"lerna:version:major": "lerna version --conventional-commits major",
"lerna:publish": "lerna publish from-git --yes"
"lerna:publish": "lerna publish from-git --yes",
"prepublishOnly": "echo $PGP_SECRET | base64 --decode | gpg --import"
},
"repository": {
"type": "git",
Expand Down
110 changes: 110 additions & 0 deletions packages/mutation-testing-elements/mvn/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.stryker-mutator</groupId>
<artifactId>mutation-testing-elements</artifactId>
<version>SET-BY-SCRIPT-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>A suite of web components for a mutation testing report.</description>
<url>https://stryker-mutator.io/</url>
<inceptionYear>2019</inceptionYear>

<licenses>
<license>
<name>Apache License 2.0</name>
<url>https://github.com/stryker-mutator/mutation-testing-elements/blob/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<!-- TODO -->
</developers>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/stryker-mutator/mutation-testing-elements/issues</url>
</issueManagement>
<scm>
<connection>scm:git:https://github.com/stryker-mutator/mutation-testing-elements.git</connection>
<developerConnection>scm:git:https://github.com/stryker-mutator/mutation-testing-elements.git</developerConnection>
<url>https://github.com/stryker-mutator/mutation-testing-elements</url>
<tag>HEAD</tag>
</scm>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<properties>
<encoding>UTF-8</encoding>
<!-- Release versions-->
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
</properties>
<dependencies></dependencies>
<build>
<resources>
<resource>
<directory>resources/</directory>
</resource>
</resources>
<plugins></plugins>
</build>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<keyname>strykermutator</keyname>
<passphrase>${env.PGP_PASSPHRASE}</passphrase>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven-deploy-plugin.version}</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
3 changes: 2 additions & 1 deletion packages/mutation-testing-elements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"test": "npm run test:unit && npm run test:integration",
"test:mutation": "cross-env STRYKER=true stryker run",
"test:unit": "karma start --singleRun true",
"test:integration": "mocha -r ts-node/register -r chromedriver --timeout 60000 --file test/integration/init/init-browser.ts --file test/integration/init/init-server.ts test/integration/*.ts"
"test:integration": "mocha -r ts-node/register -r chromedriver --timeout 60000 --file test/integration/init/init-browser.ts --file test/integration/init/init-server.ts test/integration/*.ts",
"postpublish": "../../mvn/mvnPublish.sh"
},
"repository": {
"type": "git",
Expand Down
110 changes: 110 additions & 0 deletions packages/mutation-testing-report-schema/mvn/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.stryker-mutator</groupId>
<artifactId>mutation-testing-report-schema</artifactId>
<version>SET-BY-SCRIPT-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>The json schema for a mutation testing report.</description>
<url>https://stryker-mutator.io/</url>
<inceptionYear>2019</inceptionYear>

<licenses>
<license>
<name>Apache License 2.0</name>
<url>https://github.com/stryker-mutator/mutation-testing-elements/blob/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<!-- TODO -->
</developers>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/stryker-mutator/mutation-testing-elements/issues</url>
</issueManagement>
<scm>
<connection>scm:git:https://github.com/stryker-mutator/mutation-testing-elements.git</connection>
<developerConnection>scm:git:https://github.com/stryker-mutator/mutation-testing-elements.git</developerConnection>
<url>https://github.com/stryker-mutator/mutation-testing-elements</url>
<tag>HEAD</tag>
</scm>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<properties>
<encoding>UTF-8</encoding>
<!-- Release versions-->
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
</properties>
<dependencies></dependencies>
<build>
<resources>
<resource>
<directory>resources/</directory>
</resource>
</resources>
<plugins></plugins>
</build>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<keyname>strykermutator</keyname>
<passphrase>${env.PGP_PASSPHRASE}</passphrase>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven-deploy-plugin.version}</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
3 changes: 2 additions & 1 deletion packages/mutation-testing-report-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
"scripts": {
"test": "mocha -r source-map-support/register dist/test/**/*.js"
"test": "mocha -r source-map-support/register dist/test/**/*.js",
"postpublish": "../../mvn/mvnPublish.sh"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit f5447d6

Please sign in to comment.