Skip to content

Commit

Permalink
Ab#53428 maven build (#76)
Browse files Browse the repository at this point in the history
 * Add maven workflow with release upload, update starter to detect Java for maven builds ab#53428
* check for release_url to upload release artifacts, this only exists if it is a release build
* remove incorrect copy pasta comment
* store only the hpi without path info
  • Loading branch information
fiddlermikey authored Feb 16, 2024
1 parent 82d7b61 commit c0b6e22
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
type: string
release_dir:
description: The relative directory inside the repo where the build artifacts to publish for release will be located
required: false # leave empty for non-release build
required: false
type: string
integration_type:
description: The extension integration_type
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/maven-build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build Java project with Maven and potentially upload the release
on:
workflow_call:
inputs:
release_version:
description: The release version to use when publishing a build
required: false
type: string
default: 1.0.0 # for non-released builds
release_url:
description: The url to upload a publsihed release
required: false # leave empty for non-release build
type: string
release_dir:
description: The relative directory inside the repo where the build artifacts to publish for release will be located
required: false # leave empty for non-release build
type: string
create_release:
description: The trigger to upload the build artifacts
required: false # leave empty for non-release build
type: string
secrets:
token:
description: 'Secret token from caller workflow to access private packages'
required: true

jobs:
update_release_draft:
name: Build and Possibly release maven hpi artifact
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup REPO_NAME
run: |
repoName=$(echo "${{ github.repository }}" | awk -F'/' '{print $NF}')
echo "REPO_NAME=$repoName" >> $GITHUB_ENV
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Package with Maven
run: mvn package
- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
with:
name: hpi-artifact
path: target/*.hpi
retention-days: 5

- name: Archive Files
if: success() && ${{ inputs.release_url }} != ''
run: |
mkdir -p "${GITHUB_WORKSPACE}/zip/Keyfactor"
pushd "${GITHUB_WORKSPACE}/target" # Replace with ${{ inputs.release_dir }} when read from json is fixed
zip "${GITHUB_WORKSPACE}/zip/Keyfactor/${{env.REPO_NAME}}.zip" *.hpi
ls "${GITHUB_WORKSPACE}/zip/Keyfactor"
- name: Upload Release Asset (x64)
if: success() && ${{ inputs.release_url }} != ''
id: upload-release-asset-x64
uses: keyfactor/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.release_url }}
asset_path: ${{ github.workspace }}/zip/Keyfactor/${{ env.REPO_NAME}}.zip
asset_name: ${{ env.REPO_NAME}}_${{ inputs.release_version }}.zip
asset_content_type: application/zip

#- name: Delete Failed Release
# if: failure() && ${{ inputs.release_url }} != ''
# id: delete-failed-release
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# gh release delete ${{ inputs.release_version }} --yes --cleanup-tag

11 changes: 11 additions & 0 deletions .github/workflows/starter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ jobs:
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

call-maven-build-and-release-workflow:
needs: [call-get-primary-language, call-assign-from-json-workflow, call-create-github-release-workflow]
if: needs.call-get-primary-language.outputs.primary_language == 'Java'
uses: keyfactor/actions/.github/workflows/maven-build-and-release.yml@ab#53428-maven-build
with:
release_version: ${{ needs.call-create-github-release-workflow.outputs.release_version }}
release_url: ${{ needs.call-create-github-release-workflow.outputs.release_url }}
release_dir: ${{ needs.call-assign-from-json-workflow.outputs.release_dir }}
secrets:
token: ${{ secrets.token }}

call-generate-readme-workflow:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: Keyfactor/actions/.github/workflows/generate-readme.yml@v2
Expand Down
4 changes: 2 additions & 2 deletions readme-templates/readme.md.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{# Boilderplate section #}
{# Boilerplate section #}
# {{ name }}

{{ description }}
Expand All @@ -14,7 +14,7 @@
{{ name }} {{ shared.support_statement[support_level] }}

###### To report a problem or suggest a new feature, use the **[Issues](../../issues)** tab. If you want to contribute actual bug fixes or proposed enhancements, use the **[Pull requests](../../pulls)** tab.
{# End of Boilderplate section #}
{# End of Boilerplate section #}
---
{# Important information can go in the readme-pre.md to appear near the top of the document #}
{% include "./readme-src/readme-pre.md" ignore missing %}
Expand Down

0 comments on commit c0b6e22

Please sign in to comment.