Skip to content

Commit

Permalink
testing deploy with a non-SNAPSHOT version
Browse files Browse the repository at this point in the history
  • Loading branch information
Clayton7510 committed Sep 10, 2020
1 parent eb472bd commit ac65ad4
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 30 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Maven

on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop, master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Setup Maven
env:
GPG_KEY: ${{ secrets.MAVEN_KEY }}
run: |
cp .mvn.settings.xml $HOME/.m2/settings.xml
echo "$GPG_KEY" >> codesigning.asc
gpg --import codesigning.asc
shred --remove codesigning.asc
- name: Setup Terraform
run: |
curl -g https://releases.hashicorp.com/terraform/0.12.9/terraform_0.12.9_linux_amd64.zip -o /tmp/terraform.zip
sudo unzip /tmp/terraform.zip -d /usr/bin
- name: Build with Maven
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
cd tf-build-tools
./mvnw clean test coveralls:report -DrepoToken="$COVERALLS_REPO_TOKEN"
cd ..
- name: Deploy on Merge
id: deploy
env:
OSSRH_USERNAME: ${{ secrets.SONATYPE_USER }}
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PW }}
GPG_KEY_PW: ${{ secrets.MAVEN_KEY_PW }}
GPG_KEY_ID: ${{ secrets.MAVEN_KEY_ID }}
run: |
cd tf-build-tools
VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)
PROFILE=""
if [ "$BRANCH_NAME" == "develop" ] && ![ echo $VERSION | grep -q SNAPSHOT ]; then
DOTS=$VERSION | sed -e 's/\(.\)/\n/g' | grep l | wc -l
# Ensure that the build number is in the 4th [semver] position
if [ "$DOTS" < "3" ]; then
VERSION="${VERSION}.0"
fi
VERSION="${VERSION}-${GITHUB_RUN_NUMBER}"
echo "***** VERSION is $VERSION ******"
./mvnw versions:set -DnewVersion="${VERSION}"
else
PROFILE="release"
fi
# Stage for Maven Central Deployment
export GPG_TTY=$(tty)
./mvnw deploy -DskipTests=true -Dgpg.passphrase="$GPG_KEY_PW" -Dgpg.passphrase="$GPG_KEY_ID" -p ${PROFILE}
23 changes: 1 addition & 22 deletions .github/workflows/develop.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ name: Java CI with Maven

on:
pull_request:
branches: [ develop ]
push:
branches: [ develop ]
branches: [ develop, master ]

jobs:
build:
Expand All @@ -30,22 +28,3 @@ jobs:
run: |
cp .mvn.settings.xml $HOME/.m2/settings.xml
cd tf-build-tools && ./mvnw clean test coveralls:report -DrepoToken="$COVERALLS_REPO_TOKEN"
cd ..
- name: Deploy on Merge
id: deploy
env:
OSSRH_USERNAME: ${{ secrets.SONATYPE_USER }}
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PW }}
run: |
cd tf-build-tools
PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)
echo "***** VERSION is $VERSION ******"
if [ -z "$PR_NUMBER" ] && echo $VERSION | grep -q SNAPSHOT ; then
./mvnw deploy -DskipTests=true
else
echo "***** Skipping Deploy *****"
fi
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[tf-maven-plugin]:https://search.maven.org/artifact/com.deliveredtechnologies/tf-maven-plugin/0.11/maven-plugin
[tf-cmd-api]:https://search.maven.org/artifact/com.deliveredtechnologies/tf-cmd-api/0.11/jar
[tf-maven-plugin]:https://search.maven.org/artifact/com.deliveredtechnologies/tf-maven-plugin/0.11.1/maven-plugin
[tf-cmd-api]:https://search.maven.org/artifact/com.deliveredtechnologies/tf-cmd-api/0.11.1/jar
[tf-s3-archetype]:https://search.maven.org/artifact/com.deliveredtechnologies/tf-s3-archetype/0.11/jar
[tf-maven-plugin-snapshot]:https://oss.sonatype.org/content/repositories/snapshots/com/deliveredtechnologies/tf-maven-plugin/
[tf-cmd-api-snapshot]:https://oss.sonatype.org/content/repositories/snapshots/com/deliveredtechnologies/tf-cmd-api/
[tf-s3-archetype-snapshot]:https://oss.sonatype.org/content/repositories/snapshots/com/deliveredtechnologies/tf-s3-archetype/
[maven-badge]:https://img.shields.io/badge/maven%20central-0.11-green.svg
[maven-badge]:https://img.shields.io/badge/maven%20central-0.11.1-green.svg
[maven-snapshot-badge]:https://img.shields.io/badge/SNAPSHOT-0.12-green.svg

![terraform-maven](.docs/MavenTerraform.png)
Expand Down
2 changes: 1 addition & 1 deletion tf-build-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.deliveredtechnologies</groupId>
<artifactId>tf-build-tools</artifactId>
<packaging>pom</packaging>
<version>0.12-SNAPSHOT</version>
<version>0.12</version>
<description>Terraform Build Tools: The parent POM project for Java and Terraform Tools</description>
<modules>
<module>tf-cmd-api</module>
Expand Down
2 changes: 1 addition & 1 deletion tf-build-tools/tf-cmd-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tf-build-tools</artifactId>
<groupId>com.deliveredtechnologies</groupId>
<version>0.12-SNAPSHOT</version>
<version>0.12</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>tf-cmd-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tf-build-tools/tf-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.deliveredtechnologies</groupId>
<artifactId>tf-build-tools</artifactId>
<version>0.12-SNAPSHOT</version>
<version>0.12</version>
</parent>
<artifactId>tf-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
Expand Down
2 changes: 1 addition & 1 deletion tf-build-tools/tf-s3-archetype/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.deliveredtechnologies</groupId>
<version>0.12-SNAPSHOT</version>
<version>0.12</version>
<artifactId>tf-build-tools</artifactId>
</parent>
<artifactId>tf-s3-archetype</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tf-build-tools/tf-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tf-build-tools</artifactId>
<groupId>com.deliveredtechnologies</groupId>
<version>0.12-SNAPSHOT</version>
<version>0.12</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down

0 comments on commit ac65ad4

Please sign in to comment.