Skip to content

Commit

Permalink
Merge pull request #207 from salesforce/use-deploy-plugin
Browse files Browse the repository at this point in the history
Switch from multi-module-maven-release to deploy plugin
  • Loading branch information
justinharringa authored Mar 1, 2021
2 parents 9eab4d7 + e17d4c4 commit 7cde364
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
5 changes: 3 additions & 2 deletions .ci.deploy.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
# Validate required environment variables
declare -a vars=(JDK_VERSION encrypted_00fae8efff8c_key encrypted_00fae8efff8c_iv \
encrypted_96e73e3cb232_key encrypted_96e73e3cb232_iv CI_DEPLOY_USER CI_DEPLOY_PASSWORD \
GPG_KEY_NAME GPG_PASSPHRASE DOCKER_USERNAME DOCKER_PASSWORD)
GPG_KEY_NAME GPG_PASSPHRASE DOCKER_USERNAME DOCKER_PASSWORD NEW_PATCH_VERSION)

for var_name in "${vars[@]}"
do
Expand All @@ -28,7 +29,7 @@ docker run --rm -v "${PWD}":/usr/src/build \
-e GPG_KEY_NAME \
-e GPG_PASSPHRASE \
maven:3.6-jdk-"${JDK_VERSION}" \
/bin/bash -c "source .ci.prepare-ssh-gpg.sh && cd dockerfile-image-update && mvn --quiet --batch-mode releaser:release"
/bin/bash -c "source .ci.prepare-ssh-gpg.sh && cd dockerfile-image-update && mvn --quiet --batch-mode deploy -P release scm:tag -Drevision=${NEW_PATCH_VERSION}"

# Get MVN_VERSION
MVN_VERSION=$(cat ./dockerfile-image-update/target/classes/version.txt)
Expand Down
22 changes: 19 additions & 3 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,24 @@ jobs:
with:
name: dockerfile-image-update-itest
path: dockerfile-image-update-itest
get-next-version:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'dockerfile-image-update-') == false
outputs:
version: ${{ steps.version_tag.outputs.new_version }}
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: get version
id: version_tag
run: |
make get-new-version-from-tag
echo "::set-output name=new_version::$(cat new_patch_version.txt)"
integration-test:
runs-on: ubuntu-latest
needs: build-test
needs: [build-test, get-next-version]
steps:
- name: checkout
uses: actions/checkout@master
Expand All @@ -47,7 +62,7 @@ jobs:
- name: integration test
env:
ITEST_GH_TOKEN: ${{ secrets.ITEST_GH_TOKEN }}
run: make integration-test
run: echo "Testing new version ${{ needs.get-next-version.outputs.version }}" && make integration-test
codecov:
runs-on: ubuntu-latest
needs: build-test
Expand Down Expand Up @@ -87,7 +102,7 @@ jobs:
coverageLocations: |
${{github.workspace}}/dockerfile-image-update/target/site/jacoco/jacoco.xml:jacoco
master-deploy:
needs: integration-test
needs: [integration-test, get-next-version]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
Expand All @@ -111,4 +126,5 @@ jobs:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
CI_DEPLOY_USER: ${{ secrets.CI_DEPLOY_USER }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
NEW_PATCH_VERSION: ${{ needs.get-next-version.outputs.version }}
run: make deploy
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ target/
.imageupdate/
test-results/
dependency-reduced-pom.xml
new_patch_version.txt
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,12 @@ get-itest-jar-from-maven-image:
mkdir -p ${DFIU_ITEST_TARGET}
docker run --rm -v $(CURDIR):/tmp/project local-maven-build /bin/bash -c "cp ${DFIU_ITEST_FULLPATH} /tmp/project/${DFIU_ITEST_FULLPATH}"

get-new-version-from-tag:
# Get the latest patch revision
export LATEST_PATCH_VERSION=$$(git describe --match "dockerfile-image-update-1.0.*" --abbrev=0 --tags | sed s/dockerfile-image-update-1.0.// $<); \
NEW_PATCH_VERSION=1.0.$$(($${LATEST_PATCH_VERSION} + 1)); \
echo "New patch version: $${NEW_PATCH_VERSION}"; \
echo $${NEW_PATCH_VERSION} > new_patch_version.txt;

deploy:
JDK_VERSION=${JDK_VERSION} ./.ci.deploy.sh
26 changes: 9 additions & 17 deletions dockerfile-image-update/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<groupId>com.salesforce.dockerfile-image-update</groupId>
<artifactId>dockerfile-image-update</artifactId>
<version>1.0-SNAPSHOT</version>
<version>${revision}</version>

<name>com.salesforce.dockerfile-image-update:dockerfile-image-update</name>
<description>This tool provides a mechanism to make security updates to docker images at scale.
Expand Down Expand Up @@ -63,6 +63,7 @@
<properties>
<slf4j.version>1.7.30</slf4j.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>1.0-SNAPSHOT</revision>
</properties>


Expand Down Expand Up @@ -133,22 +134,6 @@
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>com.github.danielflower.mavenplugins</groupId>
<artifactId>multi-module-maven-release-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<releaseGoals>
<releaseGoal>clean</releaseGoal>
<releaseGoal>deploy</releaseGoal>
</releaseGoals>
<releaseProfiles>
<releaseProfile>release</releaseProfile>
</releaseProfiles>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down Expand Up @@ -305,6 +290,13 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-scm-plugin</artifactId>
<version>1.11.2</version>
<configuration>
<tag>${project.artifactId}-${project.version}</tag>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Expand Down

0 comments on commit 7cde364

Please sign in to comment.