diff --git a/README.md b/README.md index ac38568..def4098 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,10 @@ arm.enable_all() - **C++**: `examples/demo.cpp` - Complete arm control demo - **Python**: `python/examples/example.py` - Basic Python usage +## For developers + +See [dev/README.md](dev/README.md). + ## Related links - 📚 Read the [documentation](https://docs.openarm.dev/software/can/) diff --git a/Rakefile b/Rakefile index 94a8368..18216b7 100644 --- a/Rakefile +++ b/Rakefile @@ -75,4 +75,47 @@ namespace :release do sh("git", "push") end end + + desc "Tag" + task :tag do + current_version = Helper.detect_version + + changelog = "packages/debian/changelog" + case File.readlines(changelog)[0] + when /\((.+)-1\)/ + package_version = $1 + unless package_version == current_version + raise "package version isn't updated: #{package_version}" + end + else + raise "failed to detect deb package version: #{changelog}" + end + + sh("git", + "tag", + current_version, + "-a", + "-m", + "OpenArm CAN #{current_version}!!!") + sh("git", "push", "origin", current_version) + end + + desc "Release packages for Ubuntu" + task :ubuntu do + current_version = Helper.detect_version + Helper.wait_github_actions_workflow(current_version, "release.yaml") + exit + ruby("-C", + "packages", + "-S", + "rake", + "ubuntu") + end end + +desc "Release" +task release: [ + "release:version:update", + "release:tag", + "release:ubuntu", +] diff --git a/dev/README.md b/dev/README.md index 3be0908..d129ee4 100644 --- a/dev/README.md +++ b/dev/README.md @@ -3,7 +3,12 @@ ## How to release ```bash +export LAUNCHPAD_UPLOADER_PGP_KEY=YOUR_PGP_KEY # e.g. export LAUNCHPAD_UPLOADER_PGP_KEY=08D3564B7C6A9CAFBFF6A66791D18FCF079F8007 +git clone https://github.com/apache/arrow.git +export APACHE_ARROW_REPOSITORY=${PWD}/arrow +git clone https://github.com/groonga/groonga.git +export GROONGA_REPOSITORY=${PWD}/groonga git clone git@github.com:enactic/openarm_can.git cd openarm_can -dev/release.sh ${VERSION} # e.g. dev/release.sh 1.0.0 +rake release NEW_VERSION=X.Y.Z # e.g. rake release 1.0.0 ``` diff --git a/dev/release.sh b/dev/release.sh deleted file mode 100755 index 8a22a08..0000000 --- a/dev/release.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# -# Copyright 2025 Enactic, Inc. -# -# Licensed 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. - -set -eu - -if [ $# -ne 1 ]; then - echo "Usage: $0 version" - echo " e.g.: $0 1.0.0" - exit 0 -fi - -version="$1" - -base_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -cd "${base_dir}" - -if [ "${RELEASE_CHECK_ORIGIN:-yes}" = "yes" ]; then - git_origin_url="$(git remote get-url origin)" - if [ "${git_origin_url}" != "git@github.com:enactic/openarm_can.git" ]; then - echo "This script must be ran with working copy of enactic/openarm_can." - echo "The origin's URL: ${git_origin_url}" - exit 1 - fi -fi - -if [ "${RELEASE_PULL:-yes}" = "yes" ]; then - echo "Ensure using the latest commit" - git checkout main - git pull --ff-only -fi - -if [ "${RELEASE_TAG:-yes}" = "yes" ]; then - echo "Tag" - git tag -a -m "OpenArm CAN ${version}" "${version}" - git push origin "${version}" -fi diff --git a/helper.rb b/helper.rb index 39b561e..bde8458 100644 --- a/helper.rb +++ b/helper.rb @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +require "cgi/escape" +require "json" +require "open-uri" + module Helper module_function def cmake_lists_txt @@ -35,4 +39,39 @@ module Helper end end end + + def github_repository + ENV["GITHUB_REPOSITORY"] || "enactic/openarm_can" + end + + def call_github_api(path, **parameters) + url = "https://api.github.com/#{path}" + unless parameters.empty? + encoded_parameters = parameters.collect do |key, value| + "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}" + end + url += "?#{encoded_parameters.join("&")}" + end + URI.open(url) do |response| + JSON.parse(response.read) + end + end + + def wait_github_actions_workflow(branch, workflow_file) + response = call_github_api("repos/#{github_repository}/actions/runs", + branch: branch) + run = response["workflow_runs"].find do |workflow_run| + workflow_run["path"] == ".github/workflows/#{workflow_file}" + end + + run_id = run["id"] + run_request_path = "repos/#{github_repository}/actions/runs/#{run_id}" + loop do + response = call_github_api(run_request_path) + status = response["status"] + return if response["status"] == "completed" + puts("Waiting...: #{status}") + sleep(60) + end + end end diff --git a/packages/Rakefile b/packages/Rakefile index 0295f84..a14a7a1 100644 --- a/packages/Rakefile +++ b/packages/Rakefile @@ -82,7 +82,7 @@ class OpenArmCANPackageTask < PackageTask end def github_repository - ENV["GITHUB_REPOSITORY"] || "enactic/openarm_can" + Helper.github_repository end def docker_image(os, architecture)