diff --git a/.github/workflows/create-tag-and-build-NG-CHM-Artifacts.yml b/.github/workflows/NG-CHM-Artifacts_push_main.yml similarity index 81% rename from .github/workflows/create-tag-and-build-NG-CHM-Artifacts.yml rename to .github/workflows/NG-CHM-Artifacts_push_main.yml index 0cdbe73d..da3eb298 100644 --- a/.github/workflows/create-tag-and-build-NG-CHM-Artifacts.yml +++ b/.github/workflows/NG-CHM-Artifacts_push_main.yml @@ -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: ## @@ -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. @@ -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: @@ -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 }} @@ -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/build-number-tag@v1.1.0 with: @@ -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 }} @@ -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/ @@ -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 "actions@github.com" @@ -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 }}" diff --git a/.github/workflows/NG-CHM-Artifacts_release.yml b/.github/workflows/NG-CHM-Artifacts_release.yml new file mode 100644 index 00000000..1a2e798b --- /dev/null +++ b/.github/workflows/NG-CHM-Artifacts_release.yml @@ -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/extract-version-from-file@v1.0.0 + 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 "actions@github.com" + 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 }}" + + diff --git a/.github/workflows/build-NGCHMSupportFiles.yml b/.github/workflows/NGCHMSupportFiles_release.yml similarity index 73% rename from .github/workflows/build-NGCHMSupportFiles.yml rename to .github/workflows/NGCHMSupportFiles_release.yml index 2847308f..1ced0b3a 100644 --- a/.github/workflows/build-NGCHMSupportFiles.yml +++ b/.github/workflows/NGCHMSupportFiles_release.yml @@ -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] @@ -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 @@ -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 @@ -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 }}" diff --git a/Dockerfile b/Dockerfile index 6eb53594..9876ad4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/NGCHM/build_galaxymapgen.xml b/NGCHM/build_galaxymapgen.xml index fbb14909..d67ba783 100644 --- a/NGCHM/build_galaxymapgen.xml +++ b/NGCHM/build_galaxymapgen.xml @@ -10,6 +10,7 @@ + @@ -24,22 +25,12 @@ - - - - - - - - - - - - + + diff --git a/NGCHM/build_guibuildermapgen.xml b/NGCHM/build_guibuildermapgen.xml index 92d93bae..df6f44be 100644 --- a/NGCHM/build_guibuildermapgen.xml +++ b/NGCHM/build_guibuildermapgen.xml @@ -10,6 +10,7 @@ + @@ -24,22 +25,12 @@ - - - - - - - - - - - - + + diff --git a/NGCHM/build_ngchmApp.xml b/NGCHM/build_ngchmApp.xml index 0e3a36bd..3c939be9 100644 --- a/NGCHM/build_ngchmApp.xml +++ b/NGCHM/build_ngchmApp.xml @@ -9,6 +9,7 @@ + @@ -68,14 +69,8 @@ - - /* commit hash: ${commithash} */${line.separator} - - - - - - /* build tag: ${latest_tag} */${line.separator} + /* commit hash: ${env.GIT_COMMIT} */${line.separator} + /* build tag: ${env.GIT_LATEST_TAG} */${line.separator} @@ -111,14 +106,8 @@ - - /* commit hash: ${commithash} */${line.separator} - - - - - - /* build tag: ${latest_tag} */${line.separator} + /* commit hash: ${env.GIT_COMMIT} */${line.separator} + /* build tag: ${env.GIT_LATEST_TAG} */${line.separator} diff --git a/NGCHM/build_shaidyRmapgen.xml b/NGCHM/build_shaidyRmapgen.xml index 047124b1..4cdeddf3 100644 --- a/NGCHM/build_shaidyRmapgen.xml +++ b/NGCHM/build_shaidyRmapgen.xml @@ -10,6 +10,7 @@ + @@ -24,22 +25,12 @@ - - - - - - - - - - - - + + diff --git a/README.md b/README.md index 623bd8d4..fa2898e0 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,12 @@ This [demo video](https://youtu.be/DuObpGNpDhw) quickly demonstrates the viewer' The project [homepage](https://bioinformatics.mdanderson.org/main/NG-CHM-V2:Overview) includes additional documentation, introductory videos, and tutorials. + +To build image: + +```bash +docker build \ + --build-arg="GIT_COMMIT=$(git rev-parse --short HEAD)" \ + --build-arg="GIT_LATEST_TAG=$(git describe --tags --abbrev=0)" \ + -t ngchm:latest . +```