Merge pull request #3 from ACCESS-NRI/davide/conda_package #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD | |
on: | |
push: | |
tags: | |
- '**' | |
jobs: | |
get-package-name: | |
name: Get package name | |
runs-on: ubuntu-latest | |
outputs: | |
package-name: ${{ steps.get-package-name.outputs.package-name }} | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Get name | |
id: get-package-name | |
run: | | |
echo "package-name=$(yq '.project.name' pyproject.toml)" >> $GITHUB_OUTPUT | |
release-conda-package: | |
name: Build with conda and release | |
runs-on: ubuntu-latest | |
needs: get-package-name | |
env: | |
BUILD_FOLDER: ${{github.workspace}}/build | |
PACKAGE_PATH: ${{github.workspace}}/build/noarch/*.tar.bz2 | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Setup conda build environment | |
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4 | |
with: | |
miniconda-version: "latest" | |
python-version: ${{ vars.PY_VERSION }} | |
environment-file: .conda/env_build.yml | |
auto-activate-base: false | |
auto-update-conda: false | |
show-channel-urls: true | |
- name: Build conda package | |
shell: bash -el {0} | |
run: | | |
conda build . --no-anaconda-upload --output-folder=${{env.BUILD_FOLDER}} -c accessnri -c conda-forge -c coecms | |
- name: Upload conda package to Anaconda.org | |
shell: bash -el {0} | |
run: | | |
anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload --user ${{ secrets.ANACONDA_USER_NAME }} ${{env.PACKAGE_PATH}} | |
- name: Create Release | |
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 #v2.0.8 | |
with: | |
tag_name: ${{ github.ref_name }} | |
name: ${{needs.get-package-name.outputs.package-name}} ${{ github.ref_name }} | |
generate_release_notes: true | |
fail_on_unmatched_files: true | |
files: | | |
${{env.PACKAGE_PATH}} | |
# Dispatch the access-ram-condaenv repo (within the same GitHub organization) to update the conda environment | |
# and deploy the new conda environment | |
dispatch-access-ram-condaenv: | |
name: Dispatch the ${{ github.repository_owner }}/access-ram-condaenv repo | |
runs-on: ubuntu-latest | |
needs: [get-package-name, release-conda-package] | |
steps: | |
- name: Dispatch repo | |
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0 | |
with: | |
token: ${{ secrets.ADMIN_TOKEN }} | |
repository: ${{ github.repository_owner }}/access-ram-condaenv | |
event-type: release | |
client-payload: |- | |
{ | |
"dependency": "${{needs.get-package-name.outputs.package-name}}", | |
"version": "${{github.ref_name}}", | |
"token": "${{secrets.ADMIN_TOKEN}}" | |
} |