Skip to content

Commit

Permalink
tag version numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
terrywbrady committed Jul 23, 2024
1 parent 4799b38 commit 052751d
Showing 1 changed file with 50 additions and 71 deletions.
121 changes: 50 additions & 71 deletions design/aws-build/tagging.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,71 @@
# CodeArtifact Tagging for Merritt

- [Design](README.md)
- [Merritt AWS Build Design](README.md)

## Merritt JAR Versioning
## General Guidelines

- Non-breaking changes SHOULD NOT update snapshot versions.
- Breaking changes SHOULD update snapshot versions.
- This will necessitate update of SNAPSHOT references in our 5 java services.
- Consider registring Merritt JAR versions in the BOM files.

## Update JAR Version

```
bash-4.2$ pwd
/apps/dpr2/merritt-workspace/tbrady/merritt-docker/mrt-services/dep_zk/mrt-zk
bash-4.2$ mvn release:update-versions
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< org.cdlib.mrt.zk:MerrittZK >---------------------
[INFO] Building Test 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.5.3:update-versions (default-cli) @ MerrittZK ---
What is the new development version for "Test"? (org.cdlib.mrt.zk:MerrittZK) 1.1-SNAPSHOT: :
```

Check in POM change to github.

## Update WAR Version
## Use Cases

WAR file snapshot changes can be updated as listed above.
1. Non-breaking change to Merritt Service
2. Non-breaking change to Merritt Library
3. Breaking/significant change to Merritt Service
4. Breaking/significant change to Merritt Library

## WAR File Tagged Release
## Non-breaking change to Merritt Service
- Update Merritt Service repo code
- Tag Merritt Service in github with semantic version (2.3.4)
- Deploy service using semantic tag

In `buildspec.yml`, change
## Non-breaking change to Merritt Library
- Update Merritt Service library code
- Tag each Merritt Service that depends on the library in order to trigger a new release
- ingest 2.3.5
- store 2.0.2
- Deploy each service using the semantic tag

```bash
mvn deploy:deploy-file -Durl=${CODEARTIFACT_URL} -DrepositoryId=cdlib-uc3-mrt-uc3-mrt-java -Dfile=$(ls audit-it/target/mrt-audit-it-*.war)
mvn deploy:deploy-file -Durl=${CODEARTIFACT_URL} -DrepositoryId=cdlib-uc3-mrt-uc3-mrt-java -Dfile=$(ls audit-war/target/mrt-auditwarpub-*.war)
```
## Breaking/significant change to Merritt Service
- Run `mvn release:update-versions` to update the snapshot(s) for the service.
- Committ the change to pom.xml
- Update Merritt Service repo code.
- TODO: reduce the number of artifact for each service.
- Tag Merritt Service in github with semantic version (2.3.4)
- Deploy service using semantic tag

TO
## Breaking/significant change to Merritt Library
This is the most complicated scenario. This will also make it easier to keep services consistent with the appropriate version of a jar file.

```bash
mvn deploy:deploy-file -Durl=${CODEARTIFACT_URL} -DrepositoryId=cdlib-uc3-mrt-uc3-mrt-java -Dfile=$(ls audit-it/target/mrt-audit-it-*.war) -Dversion=2.0.0
mvn deploy:deploy-file -Durl=${CODEARTIFACT_URL} -DrepositoryId=cdlib-uc3-mrt-uc3-mrt-java -Dfile=$(ls audit-war/target/mrt-auditwarpub-*.war) -Dversion=2.0.0
```

## Identifying the Tag/Branch for a build
### Update the appropriate library/libraries
- Run `mvn release:update-versions` to update the snapshot(s) for the library/libraries being modified.
- Commit the change to pom.xml

https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
### Update BOM
> [!IMPORTANT]
> You must create a new version of the BOM in order to register your new snapshot
Note that we are not using webhooks, so the following cannot be used. `CODEBUILD_WEBHOOK_TRIGGER`
- cd to mrt-core2/reflect
- Run `mvn release:update-versions` to force a new version of the BOM
- Modify the version number for you library/libraries in the BOM's pom.xml
- Commit the change to pom.xml

If we perform a `full clone`, we can use git commands to identify branch and tag names.
yaml
### Update BOM version number in ALL dependent libaries and Merritt Services
```
Configuration:
BranchName: main
ConnectionArn: !Ref CodeStarConnectionArn
FullRepositoryId: !Ref RepositoryName
OutputArtifactFormat: CODEBUILD_CLONE_REF
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.cdlib.mrt</groupId>
<artifactId>mrt-reflectoring-bom</artifactId>
<version>1.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
```

## Git Commands to extract branch and tag

```bash
BRANCHTAG=`git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD || git name-rev $(git rev-parse --short HEAD) | cut -d' ' -f2 || git rev-parse --short HEAD`
```

## Publish with tag

```bash
mvn -ntp clean install
if [[ "${BRANCHTAG}" == "main" ]]
then
SEMVER=''
elif [[ "${BRANCHTAG}" == "codebuild" ]]
then
SEMVER=''
else
SEMVER="-Dversion=${BRANCHTAG}"
fi
echo "Semver $SEMVER"
mvn -ntp deploy:deploy-file -Durl=${CODEARTIFACT_URL} -DrepositoryId=cdlib-uc3-mrt-uc3-mrt-java -Dfile=$(ls audit-it/target/mrt-audit-it-*.war) ${SEMVER}
mvn -ntp deploy:deploy-file -Durl=${CODEARTIFACT_URL} -DrepositoryId=cdlib-uc3-mrt-uc3-mrt-java -Dfile=$(ls audit-war/target/mrt-auditwarpub-*.war) ${SEMVER}
```

### V2 Pipeline Needed for Tag Tracking

<img width="1269" alt="image" src="https://github.com/CDLUC3/mrt-doc/assets/1111057/02a72896-9309-41ab-a0d5-f8d38fdcbcb1">
- Update all the dependent pom.files
- Tag new versions for each service

0 comments on commit 052751d

Please sign in to comment.