Skip to content

Release

Release #13

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
linux:
description: 'Run build on Linux'
type: boolean
required: false
default: true
windows:
description: 'Run build on Windows'
type: boolean
required: false
default: true
macos:
description: 'Run build on macOS'
type: boolean
required: false
default: true
defaults:
run:
shell: bash -l {0}
env:
GITHUB_TOKEN: ${{ github.token }}
jobs:
print-job:
name: Print event
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
build-release:
name: Build
needs: [print-job, generate-matrix]
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
python-version: [3.9]
os: ${{ fromJSON(needs.generate-matrix.outputs.os) }}
fail-fast: false
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Cache conda
if: ${{ !env.ACT }}
id: cache
uses: actions/cache@v3
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
with:
path: |
~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('metgem/environment*.yml') }}
- name: Set up Python
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: metgem
mamba-version: "*"
channel-priority: strict
channels: conda-forge,metgem,bioconda
python-version: ${{ matrix.python-version }}
environment-file: metgem/environment.yml
- run: |
conda info
conda list
conda config --show-sources
conda config --show
- name: Install Build Dependencies
uses: ./.github/actions/install_build_dependencies
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' }}
- name: Build
id: build
uses: ./.github/actions/build
- name: Run Tests
id: tests
uses: ./.github/actions/tests
- name: Upload Tests Artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: tests
path: ${{ steps.tests.outputs.log }}
- name: Get/Create Release
if: ${{ !env.ACT }}
id: create-release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: true
allowUpdates: true
updateOnlyUnreleased: true
repo: metgem
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: metgem_packaging/${{ steps.build.outputs.asset-name }}
asset_name: ${{ steps.build.outputs.asset-basename }}-${{ github.ref }}.${{ steps.build.outputs.asset-ext }}
asset_content_type: ${{ steps.build.outputs.asset-mimetype }}
generate-matrix:
runs-on: ubuntu-latest
name: "Generate matrix job specs"
outputs:
os: ${{ steps.generate-matrix.outputs.os }}
steps:
- name: generate-matrix
id: generate-matrix
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
os=()
if [ "${{ github.event.inputs.linux}}" == "true" ]; then
os+=('ubuntu')
fi
if [ "${{ github.event.inputs.windows}}" == "true" ]; then
os+=('windows')
fi
if [ "${{ github.event.inputs.macos }}" == "true" ]; then
os+=('macos')
fi
os=$(printf ', "%s"' "${os[@]}")
os="[${os:2}]"
echo "[INFO] OS selected: $os"
echo "os=$os" >> $GITHUB_OUTPUT
else
echo 'os=["ubuntu","windows","macos"]' >> $GITHUB_OUTPUT
fi