Skip to content

Commit a06a85d

Browse files
committed
Add test publish workflow
1 parent d3b4b5f commit a06a85d

File tree

5 files changed

+77
-12
lines changed

5 files changed

+77
-12
lines changed

.github/workflows/test-pkg-remove.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
- name: Test
2020
id: test
21-
uses: neutrons/conda-actions/pkg-remove@main
21+
uses: ./pkg-remove
2222
with:
2323
anaconda_token: unset_token
2424
organization: neutronimaging
@@ -50,7 +50,7 @@ jobs:
5050

5151
- name: Test
5252
id: test
53-
uses: neutrons/conda-actions/pkg-remove@main
53+
uses: ./pkg-remove
5454
with:
5555
anaconda_token: unset_token
5656
organization: neutronimaging

.github/workflows/test-pkg-verify.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: actions/checkout@v6
2323

2424
- name: Verify conda package
25-
uses: neutrons/conda-actions/pkg-verify@main
25+
uses: ./pkg-verify
2626
with:
2727
# local-channel: /tmp/local-channel
2828
package-name: ${{ env.PKG_NAME }}
@@ -43,7 +43,7 @@ jobs:
4343
uses: actions/checkout@v6
4444

4545
- name: Verify conda package
46-
uses: neutrons/conda-actions/pkg-verify@main
46+
uses: ./pkg-verify
4747
with:
4848
# local-channel: /tmp/local-channel
4949
package-name: ${{ env.PKG_NAME }}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Test publish action
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches: [next, qa, main]
8+
tags: ["v*"]
9+
10+
jobs:
11+
test-auto-label:
12+
name: Test publish with auto-derived label
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v6
17+
18+
- name: Setup pixi
19+
uses: prefix-dev/setup-pixi@v0.9.4
20+
21+
- name: Publish package (dry run)
22+
uses: ./publish
23+
with:
24+
anaconda-token: unset_token
25+
organization: neutronimaging
26+
package-path: test-package-0.0.0-py_0.conda
27+
github-ref: refs/heads/next
28+
dry-run: true
29+
30+
- name: Verify workflow continued
31+
shell: bash
32+
run: echo "Dry-run publish with derived label completed"
33+
34+
test-explicit-label-force:
35+
name: Test publish with explicit label and force
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v6
40+
41+
- name: Setup pixi
42+
uses: prefix-dev/setup-pixi@v0.9.4
43+
44+
- name: Publish package (dry run, force)
45+
uses: ./publish
46+
with:
47+
anaconda-token: unset_token
48+
organization: neutronimaging
49+
package-path: test-package-0.0.0-py_0.conda
50+
label: dev
51+
force: true
52+
dry-run: true
53+
54+
- name: Verify workflow continued
55+
shell: bash
56+
run: echo "Dry-run publish with explicit label completed"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ Inputs:
144144
| `github-ref` | GitHub ref (e.g., `refs/tags/v1.0.0`) to determine the label | No | github.ref |
145145
| `label` | Label to apply to the package (e.g., `dev`, `nightly`, `rc`) | No | - |
146146
| `force` | If `true`, overwrite existing package with the same version | No | `false` |
147+
| `dry-run` | If `true`, print the upload command and skip publishing | No | `false` |
147148

148149
Example:
149150

publish/action.yaml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ inputs:
3232
If true, overwrite an existing package file with the same name/version.
3333
required: false
3434
default: "false"
35+
dry-run:
36+
description: |
37+
If true, print the upload command and skip publishing to Anaconda Cloud.
38+
required: false
39+
default: "false"
3540

3641
runs:
3742
using: "composite"
@@ -68,10 +73,11 @@ runs:
6873
REF: ${{ inputs.github-ref }}
6974
LABEL: ${{ inputs.label }}
7075
FORCE: ${{ inputs.force }}
76+
DRY_RUN: ${{ inputs.dry-run }}
7177
run: |
7278
set -euo pipefail
7379
74-
set CMD=${{ steps.get_command.outputs.CMD }}
80+
CMD=${{ steps.get_command.outputs.CMD }}
7581
7682
if [ "${LABEL}" = "" ]; then
7783
echo "No label input provided. Determining label from GitHub ref '${REF}'..."
@@ -92,13 +98,15 @@ runs:
9298
force_flag="--force"
9399
fi
94100
101+
upload_cmd="${CMD} --token \"${ANACONDA_API_TOKEN}\" upload --user \"${ORGANIZATION}\" --label \"${LABEL}\" ${force_flag} \"${PACKAGE_PATH}\""
102+
103+
if [ "${DRY_RUN}" = "true" ]; then
104+
echo "Dry run enabled. Skipping package upload."
105+
echo "Would run: ${upload_cmd}"
106+
exit 0
107+
fi
108+
95109
echo "Uploading ${PACKAGE_PATH} to ${ORGANIZATION} with label '${LABEL}'"
96-
${CMD} \
97-
--token "${ANACONDA_API_TOKEN}" \
98-
upload \
99-
--user "${ORGANIZATION}" \
100-
--label "${LABEL}" \
101-
${force_flag} \
102-
${{ inputs.package-path }}
110+
eval "${upload_cmd}"
103111
104112
echo "Upload complete."

0 commit comments

Comments
 (0)