This repository contains GitHub actions for various conda-related tasks, such as verifying a conda package, and uploading a conda package to Anaconda Cloud.
These actions primarily assumes that you have built a <package-name>.conda,
and that it is located in a conda-style channel directory (see conda-index).
Available actions:
- pkg-verify: Verify a conda package by installing it with
micromambaand ensuring it is importable by Python, and that the version reported by conda and python match. - pkg-remove: Clean up old conda packages from Anaconda Cloud.
- publish: Publish a conda package to Anaconda Cloud.
GitHub action to verify a conda package by installing it with micromamba and ensuring it is importable by Python, and that the version reported by conda and python match.
Full list of available inputs in pkg-verify/action.yaml.
Inputs:
| Input | Description | Required | Default |
|---|---|---|---|
local-channel |
Path to the local conda channel containing the package to verify | No | - |
package-name |
Name of the conda package | Yes | - |
module-name |
Name of the Python module to import (if different from package name) | No | - |
python-version |
Python version to use for testing (e.g., 3.10) |
No | 3.10 |
extra-channels |
Additional conda channels to use for dependencies (comma-separated) | No | - |
extra-commands |
Additional shell commands to run after installing the package (newline-separated) | No | - |
Example usage in a GitHub workflow:
jobs:
# First, build your conda package and upload it as an artifact:
build:
steps:
- name: Build conda package
run: |
# steps to build your .conda package
- name: Upload conda package as artifact
uses: actions/upload-artifact@main
with:
name: artifact-conda-package
path: ${{ env.PKG_NAME }}-*.conda
# Then, to verify the conda package:
pkg-verify:
needs: build
run-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- name: Download conda package artifact
uses: actions/download-artifact@main
with:
name: artifact-conda-package
path: /tmp/local-channel/linux-64
- name: Verify Conda Package
uses: neutrons/conda-actions/pkg-verify@main
with:
local-channel: /tmp/local-channel
package-name: ${{ env.PKG_NAME }}
extra-channels: mantid neutrons pyoncatGitHub action to remove old packages of a specific label from anaconda.org, keeping the N most recent versions.
Full list of available inputs in pkg-remove/action.yaml.
Inputs:
| Input | Description | Required | Default |
|---|---|---|---|
anaconda_token |
Anaconda.org API token | Yes | - |
organization |
Anaconda.org organization or user name | Yes | - |
package_name |
Name of the conda package to clean up | Yes | - |
label |
Label to target for cleanup (e.g., dev, nightly, rc) |
No | - |
keep |
Number of most recent package versions to keep | No | 5 |
dry_run |
If true, only print what would be deleted without actually deleting |
No | false |
Outputs:
| Output | |
|---|---|
num_removed |
Number of files that would be deleted |
Example:
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Remove old dev packages
uses: neutrons/conda-actions/pkg-remove@main
with:
anaconda_token: ${{ secrets.ANACONDA_TOKEN }}
organization: neutrons
package_name: my-package
label: dev
keep: 5GitHub action to publish a conda package to Anaconda Cloud.
This action assumes that:
- The package has already been built and is available in a local conda channel directory
- Either
anaconda-clientorpixiis installed in the environment where the action is running
If label is not provided, the action will attempt to determine the label from the github-ref:
- If the ref is tagged
refs/tags/v*, the package will be published to themainlabel - If the ref is tagged
refs/tags/v*rc*, the package will be published to therclabel - If the ref is tagged
refs/heads/next, the package will be published to thedevlabel - If the label cannot be determined from the ref, the action will fail
Full list of available inputs in publish/action.yaml.
Inputs:
| Input | Description | Required | Default |
|---|---|---|---|
anaconda-token |
Anaconda.org API token | Yes | - |
organization |
Anaconda.org organization or user name | Yes | - |
package-path |
Path to the conda package to publish | Yes | - |
github-ref |
GitHub ref (e.g., refs/tags/v1.0.0) to determine the label |
No | github.ref |
label |
Label to apply to the package (e.g., dev, nightly, rc) |
No | - |
force |
If true, overwrite existing package with the same version |
No | false |
Example:
jobs:
publish:
- uses: actions/checkout@main
- uses: prefix-dev/setup-pixi@main
- name: Build package
run: |
# steps to build your .conda package, for example:
pixi build
- name: Publish package to Anaconda Cloud
uses: neutrons/conda-actions/publish@main
with:
anaconda-token: ${{ secrets.ANACONDA_TOKEN }}
organization: neutrons
package-path: my-package-*.conda