From d6c57e6a1a80c1bca96ef33519aa6fce32c5e10a Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Wed, 29 Nov 2023 05:07:30 -0500 Subject: [PATCH] Add ci and LICENSE --- .github/workflows/build.yml | 95 +++++++++++++++++++++++++++++++++++++ LICENSE | 21 ++++++++ README.md | 5 +- 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml create mode 100644 LICENSE diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..87e6d8f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,95 @@ +name: build + +on: + push: + branches: [ master ] + tags: + - "v?[0-9]+.[0-9]+.[0-9]+*" + pull_request: + branches: [ main ] + +jobs: + build: + name: Build + runs-on: ubuntu-22.04 + + steps: + - name: Decide image tags + id: info + shell: python + run: | + import os + import itertools + + def join_tag(t): + registry, repo, tag = t + return f'{registry}/{repo}:{tag}'.lower() + + registries = ['docker.io', 'ghcr.io'] + repos = ['${{ github.repository }}'] + if '${{ github.ref_type }}' == 'branch': + tags = ['latest'] + elif '${{ github.ref_type }}' == 'tag': + tag = '${{ github.ref_name }}' + version = tag[1:] if tag.startswith('v') else tag + tags = ['latest', version] + else: + tags = [] + + if '${{ github.ref_type }}' == 'tag': + local_tag = join_tag(('ghcr.io', '${{ github.repository }}', version)) + else: + local_tag = join_tag(('localhost', '${{ github.repository }}', 'latest')) + + product = itertools.product(registries, repos, tags) + tags_csv = ','.join(map(join_tag, product)) + outputs = { + 'tags_csv' : tags_csv, + 'push' : 'true' if tags_csv else 'false', + 'local_tag': local_tag + } + with open(os.environ['GITHUB_OUTPUT'], 'a') as out: + for k, v in outputs.items(): + out.write(f'{k}={v}\n') + + - uses: actions/checkout@v4 + # QEMU is used for non-x86_64 builds + - uses: docker/setup-qemu-action@v3 + # buildx adds additional features to docker build + - uses: docker/setup-buildx-action@v3 + with: + driver-opts: network=host + + - name: Login to DockerHub + if: (github.event_name == 'push' || github.event_name == 'release') && contains(steps.info.outputs.tags_csv, 'docker.io') + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Login to GitHub Container Registry + if: (github.event_name == 'push' || github.event_name == 'release') && contains(steps.info.outputs.tags_csv, 'ghcr.io') + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v3 + if: (github.event_name == 'push' || github.event_name == 'release') + with: + context: . + file: ./Dockerfile + tags: ${{ steps.info.outputs.tags_csv }} + platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7,linux/ppc64le + push: ${{ steps.info.outputs.push }} + cache-to: type=gha,mode=max + + - name: Update DockerHub description + if: (github.event_name == 'push' || github.event_name == 'release') + uses: peter-evans/dockerhub-description@v3 + continue-on-error: true # it is not crucial that this works + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + short-description: Web brain hemisphere surface viewer + readme-filepath: ./README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d3ffa30 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 FNNDSC / BCH + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index af1b540..a65ed09 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Niivue Hemisphere Surface Browser +[![MIT License](https://img.shields.io/github/license/fnndsc/niivue-browser)](./LICENSE) +[![build](https://github.com/FNNDSC/niivue-browser/actions/workflows/build.yml/badge.svg)](https://github.com/FNNDSC/niivue-browser/actions/workflows/build.yml) + An opinionated [NiiVue](https://github.com/niivue/niivue) application for browsing surface meshes found in a filesystem directory. ## Usage @@ -22,7 +25,7 @@ docker run --rm --name niivue-browser \ - Data files may represent: brain hemisphere volumes, hemisphere masks, hemisphere surfaces, or hemisphere surface data. For example, you could have a white matter surface mesh and sulcal depth data for that surface. Supported file formats include `.nii`, `.nii.gz`, and `.mz3`. We recommend using - [`pl-mni2common`](https://github.com/FNNDSC/pl-mni2common/) to convert from MNI formats (`.mnc`, `.obj` and `.txt`). + [`niivue-browser`](https://github.com/FNNDSC/niivue-browser/) to convert from MNI formats (`.mnc`, `.obj` and `.txt`). - Data file names must be prefixed with `lh.` for left hemispheres or `rh.` for right hemispheres. - Associated data files must have the same file name, not considering the `lh.`/`rh.` prefix nor file extension. For example, `lh.wm.mz3` and `rh.wm.mz3` will be recognized together as "wm" surfaces.