Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add release action/script #189

Open
wants to merge 6 commits into
base: ros2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Create Release

on:
push:
tags:
- 'v*.*.*' # Matches tags like v1.2.3

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Set up Python
uses: actions/setup-python@v4

- name: Install vcstool
run: |
pip install vcstool

- name: Checkout code
uses: actions/checkout@v4

- name: Export release dependency
run: |
# copy the checkout dir
cd ..
cp -r cabot cabot-temp
cd cabot-temp
# get all depedencies and freeze
./setup-dependency.sh
./setup-dependency.sh -r
# copy the release repos file
cp dependency-release.repos ../cabot

- name: Create zip file
run: |
rm -rf .git
name=$(basename $(pwd))
cd ..
zip -r cabot-${{ github.ref_name }}.zip ${name}

- name: Create GitHub Release
id: create_release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: ../cabot-*.zip

- name: Build docker image
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.CABOT_BUILD_TOKEN}}" \
https://api.github.com/repos/CMU-cabot/cabot-build/dispatches \
-d '{"event_type": "build-release", "client_payload":{"ref_name": "${{ github.ref_name }}"}}'
env:
PAT: ${{ secrets.CABOT_BUILD_TOKEN }}
25 changes: 24 additions & 1 deletion setup-dependency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ function help {
echo "-h show this help"
echo "-c clean (rm -rf) dependency repositories"
echo "-n <count> max count for recursive check (default=2)"
echo "-r update depedency-release.repos"
}

clean=0
count=3
release=0

while getopts "hcn:" arg; do
while getopts "hcn:r" arg; do
case $arg in
h)
help
Expand All @@ -49,9 +51,20 @@ while getopts "hcn:" arg; do
n)
count=$OPTARG
;;
r)
release=1
;;
esac
done

## export dependencies to dependency-release.repos
if [[ $release -eq 1 ]]; then
mv .git .git-back # work around to eliminate the current repository itself
vcs export -n --exact-with-tags > dependency-release.repos
mv .git-back .git # restore the .git dir
exit
fi


if [[ $clean -eq 1 ]]; then
pwd=$(pwd)
Expand All @@ -68,6 +81,16 @@ if [[ $clean -eq 1 ]]; then
exit
fi


## for release
if [[ -e dependency-release.repos ]]; then
echo "setup dependency from release"
vcs import < dependency-release.repos
exit
fi


## for dev
declare -A visited

for (( i=1; i<=count; i++ ))
Expand Down