Skip to content

Commit

Permalink
Merge pull request #521 from MD-Anderson-Bioinformatics/buildargs
Browse files Browse the repository at this point in the history
This pull request merge addresses two main concerns:

1. Send git info to docker build via build arguments
2. Add action to create NG-CHM-Artifacts release
   - This addresses issue #514 

I also refactored other action workflows for clarity.
  • Loading branch information
marohrdanz authored Oct 19, 2023
2 parents a8ea8dc + 605a956 commit dd72fb9
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 73 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
##
## GitHub Workflow of 2 sequential jobs:
## Create build tag, build artifacts and push to NG-CHM-Artifacts triggered by push to main
##
## 1. make_build_tag
## This workflow has two sequential jobs:
##
## 1. make_build_tag
##
## Adds a incremental build tag to the repo based on:
##
Expand All @@ -17,7 +19,7 @@
## and the version from CompatibilityManager.js is '2.22.1', the new tag
## will be: 2.22.1-build-5.
##
## 2. build_artifacts
## 2. build_artifacts
##
## Builds all artifacts from Dockerfile and checks them into the 'NG-CHM-Artifacts'
## repo with the same tag as the build tag from the first job.
Expand All @@ -33,6 +35,9 @@
## - WebContent/server.app (directory)
##

name: NG-CHM-Artifacts tag
## concurrency group prevents race condition with NG-CHM-Artifacts_release.yml
concurrency: artifacts
on:
push:
branches:
Expand All @@ -42,12 +47,11 @@ on:
jobs:
make_build_tag:
runs-on: ubuntu-22.04
name: Creating Build Number Tag
name: Tag w/ build number
strategy:
max-parallel: 1
steps:
# https://github.com/marketplace/actions/checkout
- name: Checkout
- name: Checkout commit
uses: actions/checkout@v3
with:
ref: ${{ github.sha }}
Expand All @@ -61,7 +65,7 @@ jobs:
start_string: 'CM.version = '
# https://github.com/marohrdanz/build-number-tag
# Output from this step is tag name as 'build_number'.
- name: Create Build Number Tag
- name: Create build tag
id: make_tag
uses: marohrdanz/[email protected]
with:
Expand All @@ -73,16 +77,20 @@ jobs:
tag_name: ${{ steps.make_tag.outputs.tag_name }}
build_artifacts:
runs-on: ubuntu-latest
name: Build Artifacts
name: NG-CHM-Artifacts tag
needs: make_build_tag
strategy:
max-parallel: 1
env:
Artifacts_REPOSITORY: "MD-Anderson-Bioinformatics/NG-CHM-Artifacts"
Artifacts_REPOSITORY: "${{ github.repository_owner }}/NG-CHM-Artifacts"
Artifacts_BRANCH: "main"
JAVA_VERSION: 11
steps:
- name: Checkout Tag Created In "Creating Build Number Tag" Job
- name: Make git info available for ant build
run: |
echo "GIT_COMMIT=`echo ${{ github.sha }} | cut -c1-7`" >> $GITHUB_ENV
echo "GIT_LATEST_TAG=${{ needs.make_build_tag.outputs.tag_name }}" >> $GITHUB_ENV
- name: Checkout build tag
uses: actions/checkout@v3
with:
ref: ${{ needs.make_build_tag.outputs.tag_name }}
Expand All @@ -107,14 +115,14 @@ jobs:
run: |
cd NGCHM
ant -f build_ngchmApp.xml
- name: Check out Artifacts repo
- name: Check out NG-CHM-Artifacts repo
uses: actions/checkout@v3
with:
repository: ${{ env.Artifacts_REPOSITORY }}
token: ${{ secrets.DQS_DEV_BCB_ACTIONS_TOKEN }}
ref: ${{ env.Artifacts_BRANCH }}
path: "./Artifacts"
- name: Copy artifacts
- name: Copy artifacts to NG-CHM-Artifacts
run: |
cd Artifacts
cp ../NGCHM/ShaidyMapGen.jar shaidymapgen/
Expand All @@ -132,7 +140,7 @@ jobs:
cp -r ../NGCHM/WebContent/ viewer.source/
echo "Build tag: ${{ needs.make_build_tag.outputs.tag_name }}" > viewer.source/WebContent/build_version.txt
echo "Git hash: ${{ github.sha }}" >> viewer.source/WebContent/build_version.txt
- name: Commit, tag, and push to Artifacts repo
- name: Commit, tag, and push to NG-CHM-Artifacts repo
run: |
cd Artifacts
git config --local user.email "[email protected]"
Expand All @@ -142,4 +150,5 @@ jobs:
git push origin ${{ env.Artifacts_BRANCH }}
git tag ${{ needs.make_build_tag.outputs.tag_name }}
git push origin ${{ needs.make_build_tag.outputs.tag_name }}
echo "::notice::Created tag ${{ needs.make_build_tag.outputs.tag_name }} in ${{ env.Artifacts_REPOSITORY }}"
119 changes: 119 additions & 0 deletions .github/workflows/NG-CHM-Artifacts_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
##
## Build artifacts for NG-CHM-Artifacts triggered by release
##
## Builds all artifacts from Dockerfile, checks them into the 'NG-CHM-Artifacts',
## and creates corresponding release.
##
## Artifacts built:
##
## - ShaidyMapGen.jar
## - GalaxyMapGen.jar
## - GUIBuilderMapGen.jar
## - ngchmWidget-min.js
## - ngchmEmbed-min.js
## - WebContent/ngChmApp.html
## - WebContent/server.app (directory)
##

name: NG-CHM-Artifacts release
## concurrency group prevents race condition with NG-CHM-Artifacts_push_main.yml
concurrency: artifacts
on:
release:
types: [published]
workflow_dispatch:

jobs:
build_artifacts:
runs-on: ubuntu-latest
name: NG-CHM-Artifacts release
strategy:
max-parallel: 1
env:
Artifacts_REPOSITORY: "${{ github.repository_owner }}/NG-CHM-Artifacts"
Artifacts_BRANCH: "main"
JAVA_VERSION: 11
steps:
- name: Checkout commit
uses: actions/checkout@v3
with:
ref: ${{ github.sha }}
- name: Make git info available for ant build
run: |
echo "GIT_COMMIT=`echo ${{ github.sha }} | cut -c1-7`" >> $GITHUB_ENV
echo "GIT_LATEST_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
# https://github.com/marohrdanz/extract-version-from-file
# Output from this step is version from CompatibilityManager as 'version_number'.
- name: Get version number
id: get_version_number
uses: marohrdanz/[email protected]
with:
file_path: 'NGCHM/WebContent/javascript/CompatibilityManager.js'
start_string: 'CM.version = '
- name: Set up JDK for java ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v3
with:
java-version: "${{ env.JAVA_VERSION }}"
distribution: 'temurin'
- name: Build ShaidyMapGen.jar
run: |
cd NGCHM
ant -f build_shaidyRmapgen.xml
- name: Build GalaxyMapGen.jar
run: |
cd NGCHM
ant -f build_galaxymapgen.xml
- name: Build GUIBuilderMapGen.jar
run: |
cd NGCHM
ant -f build_guibuildermapgen.xml
- name: Build NG-CHM standalone files and server.app
run: |
cd NGCHM
ant -f build_ngchmApp.xml
- name: Check out NG-CHM-Artifacts repo
uses: actions/checkout@v3
with:
repository: ${{ env.Artifacts_REPOSITORY }}
token: ${{ secrets.DQS_DEV_BCB_ACTIONS_TOKEN }}
ref: ${{ env.Artifacts_BRANCH }}
path: "./Artifacts"
- name: Copy artifacts to NG-CHM-Artifacts
run: |
cd Artifacts
cp ../NGCHM/ShaidyMapGen.jar shaidymapgen/
cp ../NGCHM/GalaxyMapGen.jar galaxymapgen/
cp ../NGCHM/GUIBuilderMapGen.jar guibuildermapgen/
cp ../NGCHM/ngchmWidget-min.js viewer.standalone/
cp ../NGCHM/ngchmEmbed-min.js viewer.standalone/
cp ../NGCHM/WebContent/ngChmApp.html viewer.standalone/
echo "Build tag: ${{ github.ref_name }}" > viewer.standalone/build_version.txt
echo "Git hash: ${{ github.sha }}" >> viewer.standalone/build_version.txt
cp -r ../NGCHM/WebContent/server.app viewer.build/
echo "Build tag: ${{ github.ref_name }}" > viewer.build/server.app/build_version.txt
echo "Git hash: ${{ github.sha }}" >> viewer.build/server.app/build_version.txt
rm -rf ../NGCHM/WebContent/server.app
cp -r ../NGCHM/WebContent/ viewer.source/
echo "Build tag: ${{ github.ref_name }}" > viewer.source/WebContent/build_version.txt
echo "Git hash: ${{ github.sha }}" >> viewer.source/WebContent/build_version.txt
- name: Commit, tag, and push to NG-CHM-Artifacts repo
run: |
cd Artifacts
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add .
git commit -m "Build from NG-CHM tag ${{ github.ref_name }}"
git push origin ${{ env.Artifacts_BRANCH }}
git tag ${{ github.ref_name }}
git push origin ${{ github.ref_name }}
- name: Create a release in NG-CHM-Artifacts repo
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.DQS_DEV_BCB_ACTIONS_TOKEN }}
body: "Version ${{ steps.get_version_number.outputs.version_number }}"
repository: ${{ env.Artifacts_REPOSITORY }}
- name: Create notice of success
run: |
echo "::notice::Created release ${{ steps.get_version_number.outputs.version_number }} in ${{ env.Artifacts_REPOSITORY }}"
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
##
## GitHub Action to build artifacts for NGCHMSupportFiles,
## triggered by publishing a release
## Build artifacts for NGCHMSupportFiles triggered by release
##
## Builds selected artifacts from Dockerfile, checks them into the 'NGCHMSupportFiles',
## and creates corresponding release.
##
## Artifacts built:
##
## - ShaidyMapGen.jar
## - ngchmWidget-min.js
##

name: Build artifacts for NGCHMSupportFiles
name: NGCHMSupportFiles release
on:
release:
types: [published]
Expand All @@ -12,15 +19,20 @@ on:
jobs:
Build-ShaidyMapGen-and-ngchmWdiget-min:
runs-on: ubuntu-22.04
name: NGCHMSupportFiles release
env:
NGCHMSupportFiles_REPOSITORY: 'MD-Anderson-Bioinformatics/NGCHMSupportFiles'
NGCHMSupportFiles_REPOSITORY: '${{ github.repository_owner }}/NGCHMSupportFiles'
NGCHMSupportFiles_BRANCH: 'main'
JAVA_VERSION: 11
steps:
- name: Check out release tag
- name: Checkout commit
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
ref: ${{ github.sha }}
- name: Make git info available for ant build
run: |
echo "GIT_COMMIT=`echo ${{ github.sha }} | cut -c1-7`" >> $GITHUB_ENV
echo "GIT_LATEST_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
# https://github.com/marohrdanz/extract-version-from-file
# Output from this step is version from CompatibilityManager as 'version_number'.
- name: Get version number
Expand Down Expand Up @@ -49,7 +61,7 @@ jobs:
token: ${{ secrets.DQS_DEV_BCB_ACTIONS_TOKEN }}
ref: ${{ env.NGCHMSupportFiles_BRANCH }}
path: './NGCHMSupportFiles'
- name: Copy artifacts to NGCHMSupportFiles and update NGCHMSupportFiles version
- name: Copy artifacts and update NGCHMSupportFiles version
run: |
cd NGCHMSupportFiles
cp ../NGCHM/ShaidyMapGen.jar inst/java
Expand Down Expand Up @@ -77,5 +89,8 @@ jobs:
token: ${{ secrets.DQS_DEV_BCB_ACTIONS_TOKEN }}
body: "Version ${{ steps.get_version_number.outputs.version_number }}"
repository: ${{ env.NGCHMSupportFiles_REPOSITORY }}
- name: Create notice of success
run: |
echo "::notice::Created release ${{ steps.get_version_number.outputs.version_number }} in ${{ env.NGCHMSupportFiles_REPOSITORY }}"
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ RUN mkdir -p ${VIEWER} &&\

# Stage 1: Create Shaidy R MapGen
FROM ant AS shaidy
ARG GIT_COMMIT
ARG GIT_LATEST_TAG
COPY NGCHM /NGCHM/

ENV SMAPGEN=/artifacts/shaidymapgen
Expand All @@ -30,6 +32,8 @@ RUN mkdir -p ${SMAPGEN} &&\

# Stage 2: Create Galaxy MapGen
FROM ant AS galaxy
ARG GIT_COMMIT
ARG GIT_LATEST_TAG
COPY NGCHM /NGCHM/

ENV GMAPGEN=/artifacts/galaxymapgen
Expand All @@ -39,8 +43,9 @@ RUN mkdir -p ${GMAPGEN} &&\

# Stage 3: Create NG-CHM Standalone
FROM ant AS standalone
ARG GIT_COMMIT
ARG GIT_LATEST_TAG
COPY NGCHM /NGCHM/
COPY .git /.git/

ENV STANDALONE=/artifacts/standalone
ENV SERVERAPP=/artifacts/server.app
Expand All @@ -56,6 +61,8 @@ RUN mkdir -p ${STANDALONE} &&\

# Stage 4: Create GUIBuilderMapGen
FROM ant AS builder
ARG GIT_COMMIT
ARG GIT_LATEST_TAG
COPY NGCHM /NGCHM/

ENV BMAPGEN=/artifacts/builder
Expand Down
15 changes: 3 additions & 12 deletions NGCHM/build_galaxymapgen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<property name="dir.workspace" value="${dir.buildfile}"/>
<property name="dir.jarfile" value="."/>
<property name="mapgen.path" value="${dir.jarfile}/GalaxyMapGen.jar"/>
<property environment="env"/>

<!-- Clean the NGCHM Project -->
<target name="clean">
Expand All @@ -24,22 +25,12 @@

<!-- Execute the JAVA class to build the GalaxyMapGen JAR-->
<target name="create_run_jar" depends="compile">
<exec executable="git" outputproperty="commithash">
<arg value="rev-parse"/>
<arg value="--short"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" outputproperty="latest_tag">
<arg value="describe"/>
<arg value="--tags"/>
<arg value="--abbrev=0"/>
</exec>
<jar destfile="${mapgen.path}" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="mda.ngchm.datagenerator.GalaxyMapGen"/>
<attribute name="Class-Path" value="."/>
<attribute name="Git-Hash" value="${commithash}"/>
<attribute name="Git-Tag" value="${latest_tag}"/>
<attribute name="Git-Hash" value="${env.GIT_COMMIT}"/>
<attribute name="Git-Tag" value="${env.GIT_LATEST_TAG}"/>
</manifest>
<fileset dir="${dir.jarfile}/build/classes">
<exclude name="**/WEB-INF/**"/>
Expand Down
15 changes: 3 additions & 12 deletions NGCHM/build_guibuildermapgen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<property name="dir.workspace" value="${dir.buildfile}"/>
<property name="dir.jarfile" value="."/>
<property name="mapgen.path" value="${dir.jarfile}/GUIBuilderMapGen.jar"/>
<property environment="env"/>

<!-- Clean the NGCHM Project -->
<target name="clean">
Expand All @@ -24,22 +25,12 @@

<!-- Execute the JAVA class to build the GUIBuilderMapGen JAR-->
<target name="create_run_jar" depends="compile">
<exec executable="git" outputproperty="commithash">
<arg value="rev-parse"/>
<arg value="--short"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" outputproperty="latest_tag">
<arg value="describe"/>
<arg value="--tags"/>
<arg value="--abbrev=0"/>
</exec>
<jar destfile="${mapgen.path}" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="mda.ngchm.datagenerator.HeatmapDataGenerator"/>
<attribute name="Class-Path" value="."/>
<attribute name="Git-Hash" value="${commithash}"/>
<attribute name="Git-Tag" value="${latest_tag}"/>
<attribute name="Git-Hash" value="${env.GIT_COMMIT}"/>
<attribute name="Git-Tag" value="${env.GIT_LATEST_TAG}"/>
</manifest>
<fileset dir="${dir.jarfile}/build/classes">
<exclude name="**/WEB-INF/**"/>
Expand Down
Loading

0 comments on commit dd72fb9

Please sign in to comment.