Skip to content

Issue #217: Check out submodules in maven-release-plugin #18

Issue #217: Check out submodules in maven-release-plugin

Issue #217: Check out submodules in maven-release-plugin #18

# Runs on every commit to main. This is the main CI job; it:
# * Builds
# * Runs tests
# * Uploads Test reports to BuildKite
# * Uploads Coverage reports to CodeCov
# * Uploads Web5 Test Vectors reports to the SDK Report Runner
# * Publishes (deploys) a SNAPSHOT to TBD's Artifactory instance
name: Build, Test, and Publish SNAPSHOT to TBD Artifactory
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish. For example "1.0.0-SNAPSHOT". If not supplied, will default to version specified in the POM.'
required: false
default: '0.0.0-SNAPSHOT'
push:
branches:
- issue-217/maven-build
# Put this back and remove section above before merging to main
#pull_request:
# branches:
# - '*'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
steps:
- uses: actions/checkout@v4
with:
submodules: true
# https://cashapp.github.io/hermit/usage/ci/
- name: Init Hermit
uses: cashapp/activate-hermit@v1
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: hash test inputs
run: |
if ! which sha256sum; then brew install coreutils; fi
sha256sum $(find test-vectors -name '*.json') > test-vector-hashes.txt
- name: Build, Test, and Deploy SNAPSHOT
run: |
# Version resolution: use provided
if [ -n "${{ github.event.inputs.version }}" ]; then
resolvedVersion=${{ github.event.inputs.version }}
# Otherwise, construct a version for deployment in form X.Y.Z-commit-$shortSHA-SNAPSHOT
else
mvnVersion=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
longSHA=$(git rev-parse --verify HEAD)
version=$(echo "$mvnVersion" | cut -d'-' -f1)
shortSHA=$(echo "${longSHA:0:7}")
resolvedVersion="$version-commit-$shortSHA-SNAPSHOT"
echo "Requesting deployment as version: $resolvedVersion"
fi
# Postcondition check; only allow this to proceed if we have a version ending in "-SNAPSHOT"
if [[ ! "$resolvedVersion" =~ -SNAPSHOT$ ]]; then
echo "Error: The version does not end with \"-SNAPSHOT\": $resolvedVersion"
exit 1
fi
# Set newly resolved version in POM config
mvn \
versions:set \
--batch-mode \
-DnewVersion=$resolvedVersion
# Maven deploy lifecycle will build, run tests, verify, and deploy
mvn \
deploy \
--batch-mode \
--settings .maven_settings.xml
env:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
# Upload Web5 Vector test resultsß
- uses: actions/upload-artifact@v3
with:
name: test-results
path: |
**/target/surefire-reports/*Web5TestVectors*.xml
test-vector-hashes.txt
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
flags: ${{ runner.os }}
- uses: actions/upload-artifact@v3
with:
name: tests-report-junit
path: |
**/target/surefire-reports/*.xml
- name: Generate an access token to trigger downstream repo
uses: actions/create-github-app-token@2986852ad836768dfea7781f31828eb3e17990fa # v1.6.2
id: generate_token
if: github.ref == 'refs/heads/main'
with:
app-id: ${{ secrets.CICD_ROBOT_GITHUB_APP_ID }}
private-key: ${{ secrets.CICD_ROBOT_GITHUB_APP_PRIVATE_KEY }}
owner: TBD54566975
repositories: sdk-report-runner
- name: Trigger sdk-report-runner report build
if: github.ref == 'refs/heads/main'
run: |
curl -L \
-H "Authorization: Bearer ${APP_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/json" \
--fail \
--data '{"ref": "main"}' \
https://api.github.com/repos/TBD54566975/sdk-report-runner/actions/workflows/build-report.yaml/dispatches
env:
APP_TOKEN: ${{ steps.generate_token.outputs.token }}