You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by li...@apache.org on 2022/12/29 17:49:53 UTC

[arrow-adbc] branch main updated: ci: clean old releases (#247)

This is an automated email from the ASF dual-hosted git repository.

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new 689a47e  ci: clean old releases (#247)
689a47e is described below

commit 689a47e894ef874cc51da5f0d61546d37e092e6d
Author: David Li <li...@gmail.com>
AuthorDate: Thu Dec 29 12:49:48 2022 -0500

    ci: clean old releases (#247)
    
    For this to work, we need to first add the API token. This is a
    different token than the one used for uploading packages.
    
    Co-authored-by: Sutou Kouhei <ko...@cozmixng.org>
---
 .github/workflows/packaging.yml | 20 ++++++++++++++++++++
 ci/scripts/gemfury_clean.rb     | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/.github/workflows/packaging.yml b/.github/workflows/packaging.yml
index ea26bb2..c72076a 100644
--- a/.github/workflows/packaging.yml
+++ b/.github/workflows/packaging.yml
@@ -601,3 +601,23 @@ jobs:
           ./ci/scripts/python_wheel_upload.sh upload-staging/adbc_*.tar.gz upload-staging/*.whl
         env:
           GEMFURY_PUSH_TOKEN: ${{ secrets.GEMFURY_PUSH_TOKEN }}
+
+  clean-gemfury:
+    name: "Clean old releases"
+    runs-on: ubuntu-latest
+    if: "!startsWith(github.ref, 'refs/tags/')"
+    needs:
+      - upload-gemfury
+    steps:
+      - uses: actions/checkout@v3
+        with:
+          fetch-depth: 0
+          persist-credentials: true
+
+      - name: Clean old releases
+        shell: bash
+        run: |
+          gem install --user-install gemfury
+          ruby ./ci/scripts/gemfury_clean.rb
+        env:
+          GEMFURY_API_TOKEN: ${{ secrets.GEMFURY_API_TOKEN }}
diff --git a/ci/scripts/gemfury_clean.rb b/ci/scripts/gemfury_clean.rb
new file mode 100755
index 0000000..976d239
--- /dev/null
+++ b/ci/scripts/gemfury_clean.rb
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Clean old releases from Gemfury.
+
+require "gemfury"
+
+client = Gemfury::Client.new(user_api_key: ENV["GEMFURY_API_TOKEN"])
+
+client.list.each do |artifact|
+  puts artifact["name"]
+  versions = client.versions(artifact["name"])
+  versions.sort_by! { |v| v["created_at"] }
+
+  # Keep last two versions
+  versions[0...-2].each do |version|
+    client.yank_version(artifact["name"], version["version"])
+    puts "Yanked #{artifact['name']} #{version['version']} (created #{version['created_at']})"
+  end
+  versions.last(2).each do |version|
+    puts "Kept #{artifact['name']} #{version['version']} (created #{version['created_at']})"
+  end
+end