Skip to content

Merge pull request #536 from MD-Anderson-Bioinformatics/actions-fix #10

Merge pull request #536 from MD-Anderson-Bioinformatics/actions-fix

Merge pull request #536 from MD-Anderson-Bioinformatics/actions-fix #10

##
## Create build tag, build artifacts and push to NG-CHM-Artifacts triggered by push to main
##
## This workflow has two sequential jobs:
##
## 1. make_build_tag
##
## Adds a incremental build tag to the repo based on:
##
## - Version number in CompatibilityManager.js
## - Existing '-build-' tags in repo
##
## For example, if there are exiting tags in the repo:
##
## - 2.22.1-build-4
## - 2.21.0-build-3
## - 2.20.1-build-2
##
## and the version from CompatibilityManager.js is '2.22.1', the new tag
## will be: 2.22.1-build-5.
##
## 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.
##
## 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 tag
## concurrency group prevents race condition with NG-CHM-Artifacts_release.yml
concurrency: artifacts
on:
push:
branches:
main
workflow_dispatch:
jobs:
make_build_tag:
runs-on: ubuntu-22.04
name: Tag w/ build number
strategy:
max-parallel: 1
steps:
- name: Checkout commit
uses: actions/[email protected]
with:
ref: ${{ github.sha }}
# 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'
search_string: 'CM.version = '
# https://github.com/marohrdanz/build-number-tag
# Output from this step is tag name as 'build_number'.
- name: Create build tag
id: make_tag
uses: marohrdanz/[email protected]
with:
token: ${{ secrets.DQS_DEV_BCB_ACTIONS_TOKEN }}
prefix: '-build-'
version_prefix: ${{ steps.get_version_number.outputs.version_number }}
outputs:
build_number: ${{ steps.make_tag.outputs.build_number }}
tag_name: ${{ steps.make_tag.outputs.tag_name }}
build_artifacts:
runs-on: ubuntu-latest
name: NG-CHM-Artifacts tag
needs: make_build_tag
strategy:
max-parallel: 1
env:
Artifacts_REPOSITORY: "${{ github.repository_owner }}/NG-CHM-Artifacts"
Artifacts_BRANCH: "main"
JAVA_VERSION: 11
steps:
- 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/[email protected]
with:
ref: ${{ needs.make_build_tag.outputs.tag_name }}
- name: Set up JDK for java ${{ env.JAVA_VERSION }}
uses: actions/[email protected]
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/[email protected]
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: ${{ needs.make_build_tag.outputs.tag_name }}" > viewer.standalone/build_version.txt
echo "Git hash: ${{ github.sha }}" >> viewer.standalone/build_version.txt
git rm viewer.build/server.app/javascript/*.js # rm old minified js files
cp -r ../NGCHM/WebContent/server.app viewer.build/
echo "Build tag: ${{ needs.make_build_tag.outputs.tag_name }}" > viewer.build/server.app/build_version.txt
echo "Git hash: ${{ github.sha }}" >> viewer.build/server.app/build_version.txt
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 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 ${{ needs.make_build_tag.outputs.tag_name }}"
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 }}"