From 7c6b7c8e4bee9df923c5a80e960485f450839b8a Mon Sep 17 00:00:00 2001 From: "~ . ~" Date: Mon, 7 Oct 2024 15:15:17 -0400 Subject: [PATCH] adjust workflow for snapshot tagging --- .github/workflows/release-assembly.yml | 23 +++++++++++++++---- .github/workflows/unit-tests.yml | 2 +- .../oscal/tools/server/OscalVerticle.kt | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-assembly.yml b/.github/workflows/release-assembly.yml index c81e4e8..5ba71cb 100644 --- a/.github/workflows/release-assembly.yml +++ b/.github/workflows/release-assembly.yml @@ -17,6 +17,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Set up JDK 17 uses: actions/setup-java@v3 @@ -28,27 +30,38 @@ jobs: - name: Build with Maven run: mvn clean package - - name: Get version and set release name + - name: Get version and set release info id: get_version run: | if [[ $GITHUB_REF == refs/tags/v* ]]; then - echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + VERSION=${GITHUB_REF#refs/tags/v} + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "TAG_NAME=v$VERSION" >> $GITHUB_OUTPUT echo "RELEASE_NAME=Release $VERSION" >> $GITHUB_OUTPUT + echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT else - echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + COMMIT_HASH=$(git rev-parse --short HEAD) + TIMESTAMP=$(date +'%Y%m%d%H%M%S') + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "TAG_NAME=v$VERSION-$COMMIT_HASH-$TIMESTAMP" >> $GITHUB_OUTPUT echo "RELEASE_NAME=Release $VERSION ($(date +'%Y-%m-%d %H:%M:%S'))" >> $GITHUB_OUTPUT + echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT fi + - name: List target directory + run: ls -l target/ + - name: Create Release id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: v${{ steps.get_version.outputs.VERSION }} + tag_name: ${{ steps.get_version.outputs.TAG_NAME }} release_name: ${{ steps.get_version.outputs.RELEASE_NAME }} draft: false - prerelease: false + prerelease: ${{ steps.get_version.outputs.IS_PRERELEASE }} - name: Upload Release Asset uses: actions/upload-release-asset@v1 diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c9f995c..526af61 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: jobs: - build-and-release: + build-and-test: runs-on: ubuntu-latest permissions: contents: write diff --git a/src/main/kotlin/gov/nist/secauto/oscal/tools/server/OscalVerticle.kt b/src/main/kotlin/gov/nist/secauto/oscal/tools/server/OscalVerticle.kt index 6125c16..a4efb02 100644 --- a/src/main/kotlin/gov/nist/secauto/oscal/tools/server/OscalVerticle.kt +++ b/src/main/kotlin/gov/nist/secauto/oscal/tools/server/OscalVerticle.kt @@ -287,6 +287,7 @@ class OscalVerticle : CoroutineVerticle() { ctx.response() .setStatusCode(200) // HTTP 200 OK .putHeader("Content-Type", "application/json") + .putHeader("Exit-Status", exitStatus.toString()) .end(fileContent) }