Skip to content

Commit df79f4e

Browse files
committed
add github ref as input for publish
1 parent 3cc75ba commit df79f4e

File tree

2 files changed

+92
-20
lines changed

2 files changed

+92
-20
lines changed

README.md

Lines changed: 70 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,18 @@ GitHub action to verify a conda package by installing it with `micromamba` and e
1919

2020
#### Usage
2121

22-
Available inputs are listed in [`pkg-verify/action.yaml`](#pkg-verify/action.yaml).
22+
Full list of available inputs in [`pkg-verify/action.yaml`](#pkg-verify/action.yaml).
23+
24+
Inputs:
25+
26+
| Input | Description | Required | Default |
27+
| ---------------- | --------------------------------------------------------------------------------- | -------- | ------- |
28+
| `local-channel` | Path to the local conda channel containing the package to verify | No | - |
29+
| `package-name` | Name of the conda package | Yes | - |
30+
| `module-name` | Name of the Python module to import (if different from package name) | No | - |
31+
| `python-version` | Python version to use for testing (e.g., `3.10`) | No | `3.10` |
32+
| `extra-channels` | Additional conda channels to use for dependencies (comma-separated) | No | - |
33+
| `extra-commands` | Additional shell commands to run after installing the package (newline-separated) | No | - |
2334

2435
Example usage in a GitHub workflow:
2536

@@ -67,22 +78,7 @@ keeping the N most recent versions.
6778
6879
#### Usage
6980
70-
Available inputs are listed in [`pkg-remove/action.yaml`](#pkg-remove/action.yaml).
71-
72-
```yaml
73-
jobs:
74-
cleanup:
75-
runs-on: ubuntu-latest
76-
steps:
77-
- name: Remove old dev packages
78-
uses: neutrons/conda-actions/pkg-remove@main
79-
with:
80-
anaconda_token: ${{ secrets.ANACONDA_TOKEN }}
81-
organization: neutrons
82-
package_name: my-package
83-
label: dev
84-
keep: 5
85-
```
81+
Full list of available inputs in [`pkg-remove/action.yaml`](#pkg-remove/action.yaml).
8682

8783
Inputs:
8884

@@ -91,7 +87,7 @@ Inputs:
9187
| `anaconda_token` | Anaconda.org API token | Yes | - |
9288
| `organization` | Anaconda.org organization or user name | Yes | - |
9389
| `package_name` | Name of the conda package to clean up | Yes | - |
94-
| `label` | Label to target for cleanup (e.g., `dev`, `nightly`, `rc`) | Yes | - |
90+
| `label` | Label to target for cleanup (e.g., `dev`, `nightly`, `rc`) | No | - |
9591
| `keep` | Number of most recent package versions to keep | No | `5` |
9692
| `dry_run` | If `true`, only print what would be deleted without actually deleting | No | `false` |
9793

@@ -101,10 +97,65 @@ Outputs:
10197
| ------------- | ------------------------------------- |
10298
| `num_removed` | Number of files that would be deleted |
10399

100+
Example:
101+
102+
```yaml
103+
jobs:
104+
cleanup:
105+
runs-on: ubuntu-latest
106+
steps:
107+
- name: Remove old dev packages
108+
uses: neutrons/conda-actions/pkg-remove@main
109+
with:
110+
anaconda_token: ${{ secrets.ANACONDA_TOKEN }}
111+
organization: neutrons
112+
package_name: my-package
113+
label: dev
114+
keep: 5
115+
```
116+
104117
## publish
105118

106119
GitHub action to publish a conda package to Anaconda Cloud.
107120

121+
This action assumes that:
122+
123+
- The package has already been built and is available in a local conda channel directory
124+
- Either `anaconda-client` or `pixi` is installed in the environment where the action is running
125+
108126
#### Usage
109127

110-
TBD
128+
Full list of available inputs in [`publish/action.yaml`](#publish/action.yaml).
129+
130+
Inputs:
131+
132+
| Input | Description | Required | Default |
133+
| ---------------- | ------------------------------------------------------------ | -------- | ---------- |
134+
| `anaconda-token` | Anaconda.org API token | Yes | - |
135+
| `organization` | Anaconda.org organization or user name | Yes | - |
136+
| `package-path` | Path to the conda package to publish | Yes | - |
137+
| `github-ref` | GitHub ref (e.g., `refs/tags/v1.0.0`) to determine the label | No | github.ref |
138+
| `label` | Label to apply to the package (e.g., `dev`, `nightly`, `rc`) | No | - |
139+
| `force` | If `true`, overwrite existing package with the same version | No | `false` |
140+
141+
Example:
142+
143+
```yaml
144+
jobs:
145+
publish:
146+
- uses: actions/checkout@main
147+
148+
- uses: prefix-dev/setup-pixi@main
149+
150+
- name: Build package
151+
run: |
152+
# steps to build your .conda package, for example:
153+
pixi build
154+
155+
- name: Publish package to Anaconda Cloud
156+
uses: neutrons/conda-actions/publish@main
157+
with:
158+
anaconda-token: ${{ secrets.ANACONDA_TOKEN }}
159+
organization: neutrons
160+
package-path: my-package-*.conda
161+
```

publish/action.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ inputs:
1515
package-path:
1616
description: Path to the .conda file to upload.
1717
required: true
18+
github-ref:
19+
description: |
20+
GitHub ref (branch, tag, or commit) to include in the package metadata.
21+
Defaults to the current ref of the workflow run.
22+
required: false
23+
default: ${{ github.ref }}
1824
label:
1925
description: |
2026
Anaconda channel label to publish to (e.g. main, dev, nightly, rc).
2127
Defaults to "main".
2228
required: false
23-
default: "main"
29+
default: ""
2430
force:
2531
description: |
2632
If true, overwrite an existing package file with the same name/version.
@@ -49,11 +55,26 @@ runs:
4955
ANACONDA_API_TOKEN: ${{ inputs.anaconda-token }}
5056
ORGANIZATION: ${{ inputs.organization }}
5157
PACKAGE_PATH: ${{ inputs.package-path }}
58+
REF: ${{ inputs.github-ref }}
5259
LABEL: ${{ inputs.label }}
5360
FORCE: ${{ inputs.force }}
5461
run: |
5562
set -euo pipefail
5663
64+
if [ "${LABEL}" = "" ]; then
65+
echo "No label input provided. Determining label from GitHub ref '${REF}'..."
66+
case "${REF}" in
67+
refs/heads/next) LABEL="dev" ;;
68+
refs/tags/v*rc*) LABEL="rc" ;;
69+
refs/tags/v*) LABEL="main" ;;
70+
*)
71+
echo "Could not determine label from ref '${REF}'. Please provide a label input or use a ref format like 'refs/heads/next' or 'refs/tags/vX.Y.Z[rcN]'."
72+
exit 1
73+
;;
74+
esac
75+
fi
76+
echo "Using label '${LABEL}' for upload."
77+
5778
force_flag=""
5879
if [ "${FORCE}" = "true" ]; then
5980
force_flag="--force"

0 commit comments

Comments
 (0)