Use Rake to release (#49)

I want to automate pushing to Launchpad. But it's a manual operation for
now.
This commit is contained in:
Sutou Kouhei 2025-10-10 15:48:54 +09:00 committed by GitHub
parent 5730284d1e
commit cd9b7717d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 93 additions and 52 deletions

View File

@ -87,6 +87,10 @@ arm.enable_all()
- **C++**: `examples/demo.cpp` - Complete arm control demo - **C++**: `examples/demo.cpp` - Complete arm control demo
- **Python**: `python/examples/example.py` - Basic Python usage - **Python**: `python/examples/example.py` - Basic Python usage
## For developers
See [dev/README.md](dev/README.md).
## Related links ## Related links
- 📚 Read the [documentation](https://docs.openarm.dev/software/can/) - 📚 Read the [documentation](https://docs.openarm.dev/software/can/)

View File

@ -75,4 +75,47 @@ namespace :release do
sh("git", "push") sh("git", "push")
end end
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 end
desc "Release"
task release: [
"release:version:update",
"release:tag",
"release:ubuntu",
]

View File

@ -3,7 +3,12 @@
## How to release ## How to release
```bash ```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 git clone git@github.com:enactic/openarm_can.git
cd openarm_can 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
``` ```

View File

@ -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

View File

@ -12,6 +12,10 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
require "cgi/escape"
require "json"
require "open-uri"
module Helper module Helper
module_function module_function
def cmake_lists_txt def cmake_lists_txt
@ -35,4 +39,39 @@ module Helper
end end
end 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 end

View File

@ -82,7 +82,7 @@ class OpenArmCANPackageTask < PackageTask
end end
def github_repository def github_repository
ENV["GITHUB_REPOSITORY"] || "enactic/openarm_can" Helper.github_repository
end end
def docker_image(os, architecture) def docker_image(os, architecture)