Skip to content

Commit 4833285

Browse files
add suppression of existing packages on devel channel
1 parent 6d82f46 commit 4833285

2 files changed

Lines changed: 26 additions & 13 deletions

File tree

.github/workflows/build_publish_package.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ jobs:
7575

7676
- name: Install conda environment
7777
shell: bash -l {0}
78+
# requests is used to query graphql prefix.dev api with devel packages
7879
run: |
79-
conda install rattler-build -c conda-forge
80+
conda install rattler-build requests -c conda-forge
8081
8182
# Same remark here about too long filename bug on windows, we have to force the output directory accordingly on windows
8283
- name: Setup output directory
@@ -97,7 +98,7 @@ jobs:
9798
conda config --show
9899
printenv | sort
99100
100-
- name: Configure recipe (if devel)
101+
- name: Configure recipe [devel]
101102
if: ${{ inputs.recipe-dir == 'devel' }}
102103
shell: bash -l {0}
103104
run: |
@@ -106,7 +107,7 @@ jobs:
106107
if [[ ! -z "${{ inputs.git-sha }}" && ! -z "${{ inputs.git-commit-date }}" ]]; then
107108
sed -e "s/%GIT_SHA%/${{ inputs.git-sha }}/g" -e "s/%DATE_YYYYMMDD%/${{ inputs.git-commit-date }}/g" recipe.yaml.in > recipe.yaml
108109
fi
109-
# output configured recipe
110+
# Show configured recipe
110111
echo "==== Configured recipe:"
111112
cat recipe.yaml
112113
@@ -136,19 +137,38 @@ jobs:
136137
rattler-build build --recipe ${{ inputs.package-name }}/recipe/recipe.yaml --variant-config $CONFIG_FILE --output-dir ${{ env.PKG_DIR }} --experimental -c conda-forge -c https://prefix.dev/${{ inputs.channel }} --channel-priority disabled
137138
138139
# Remove already existing package if any
139-
- name: Remove existing package
140-
if: ${{ inputs.publish-package == true }}
140+
# For release packages, we just remove if package with exact name already exists, and we keep previous builds
141+
- name: Remove existing package [non-devel]
142+
if: ${{ inputs.publish-package == true && inputs.recipe-dir != 'devel' }}
141143
shell: bash -l {0}
142144
run: |
143145
cd ${{ env.PKG_DIR }}/${{ inputs.platform }}
144146
for file in *${{ inputs.package-name }}*.conda; do
145147
curl -X DELETE https://prefix.dev/api/v1/delete/${{ inputs.channel }}/${{ inputs.platform }}/$file -H "Authorization: Bearer ${{ secrets.api-key }}"
146148
done
147149
150+
# For devel packages, we only keep last build. So we will remove previous one(s) after successful publish
151+
- name: Query existing package(s) [devel]
152+
if: ${{ inputs.publish-package == true && inputs.recipe-dir == 'devel' }}
153+
id: query_filenames
154+
shell: bash -l {0}
155+
run: |
156+
echo "result=$(python .github/workflows/fetch_packages_names.py --channel ${{ inputs.channel }} --package ${{ inputs.package }} --platform ${{ inputs.platform }})" >> $GITHUB_OUTPUT
157+
148158
- name: Publish conda package
149159
if: ${{ inputs.publish-package == true }}
150160
shell: bash -l {0}
151161
run: |
152162
for file in ${{ env.PKG_DIR }}/**/*${{ inputs.package-name }}*.conda; do
153163
rattler-build upload prefix -c ${{ inputs.channel }} --api-key ${{ secrets.api-key }} "$file"
154-
done
164+
done
165+
166+
- name: Remove existing package [devel]
167+
if: ${{ inputs.publish-package == true && inputs.recipe-dir == 'devel' }}
168+
shell: bash -l {0}
169+
run: |
170+
packages='${{ steps.query_filenames.outputs.result }}'
171+
172+
echo "$packages" | jq -c '.[]' | while read filename; do
173+
curl -X DELETE https://prefix.dev/api/v1/delete/${{ inputs.channel }}/${{ inputs.platform }}/$filename -H \"Authorization: Bearer ${{ secrets.api-key }}\""
174+
done

.github/workflows/query_package.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,4 @@ jobs:
4545
4646
echo "$packages" | jq -c '.[]' | while read package; do
4747
echo "$package"
48-
# platform=$(echo "$package" | jq -r '.[0]')
49-
# filename=$(echo "$package" | jq -r '.[1]')
50-
# echo "Platform: $platform - Filename: $filename"
5148
done
52-
# - name: Remove existing package
53-
# shell: bash -l {0}
54-
# run: |
55-
# echo "curl -X DELETE https://prefix.dev/api/v1/delete/${{ inputs.channel }}/${{ inputs.platform }}/${{ inputs.filename }} -H \"Authorization: Bearer --secrets--\""

0 commit comments

Comments
 (0)