Skip to content

Commit d9d5d78

Browse files
committed
feat: Automate Release
1 parent c9c3a9f commit d9d5d78

File tree

4 files changed

+113
-116
lines changed

4 files changed

+113
-116
lines changed

.github/workflows/release.yml

Lines changed: 77 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -14,133 +14,106 @@
1414
name: Release
1515

1616
on:
17-
release:
18-
types: [published]
1917
schedule:
2018
- cron: "0 0 * * 1-5"
2119
workflow_dispatch:
20+
inputs:
21+
live-run:
22+
type: boolean
23+
description: Live-run
24+
required: false
25+
version:
26+
type: string
27+
description: Release number
28+
required: false
2229

2330
jobs:
24-
preps:
25-
name: Preparation
31+
tag:
32+
name: Branch, Bump & tag
2633
runs-on: ubuntu-latest
34+
outputs:
35+
version: ${{ steps.create-release-branch.outputs.version }}
36+
branch: ${{ steps.create-release-branch.outputs.branch }}
2737
steps:
38+
- id: create-release-branch
39+
uses: eclipse-zenoh/ci/create-release-branch@main
40+
with:
41+
repo: ${{ github.repository }}
42+
live-run: ${{ inputs.live-run || false }}
43+
version: ${{ inputs.version }}
44+
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}
45+
2846
- name: Clone this repository
2947
uses: actions/checkout@v4
48+
with:
49+
ref: ${{ steps.create-release-branch.outputs.branch }}
3050

31-
- name: Environment setup
32-
id: env
33-
shell: bash
34-
run: |
35-
echo "GITHUB_REF=${GITHUB_REF}"
36-
echo "GITHUB_SHA=${GITHUB_SHA:0:8}"
37-
GIT_BRANCH=`[[ $GITHUB_REF =~ ^refs/heads/.* ]] && echo ${GITHUB_REF/refs\/heads\//} || true`
38-
echo "GIT_BRANCH=${GIT_BRANCH}"
39-
echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_OUTPUT
40-
GIT_TAG=`[[ $GITHUB_REF =~ ^refs/tags/.* ]] && echo ${GITHUB_REF/refs\/tags\//} || true`
41-
echo "GIT_TAG=${GIT_TAG}"
42-
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
51+
- name: Bump and tag project
52+
run: bash ci/scripts/bump-and-tag.bash
53+
env:
54+
VERSION: ${{ steps.create-release-branch.outputs.version }}
55+
GIT_USER_NAME: eclipse-zenoh-bot
56+
GIT_USER_EMAIL: [email protected]
4357

44-
ZENOH_VERSION=$(sed -n 's/^[ \t]*VERSION \([0-9][0-9]*\.[0-9][0-9]*\.[0.9][0-9]*\.[0-9][0-9]*\).*/\1/p' CMakeLists.txt | head -n1)
45-
echo "ZENOH_VERSION=${ZENOH_VERSION}"
46-
echo "ZENOH_VERSION=${ZENOH_VERSION}" >> $GITHUB_OUTPUT
47-
if [ -n "${GIT_TAG}" ]; then
48-
IS_RELEASE="true"
49-
echo "IS_RELEASE=${IS_RELEASE}"
50-
echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT
51-
PKG_VERSION=${ZENOH_VERSION}
52-
elif [ -n "${GIT_BRANCH}" ]; then
53-
PKG_VERSION=${GIT_BRANCH}-${GITHUB_SHA:0:8}
54-
else
55-
PKG_VERSION=${ZENOH_VERSION}-${GITHUB_SHA:0:8}
56-
fi
57-
echo "PKG_VERSION=${PKG_VERSION}"
58-
echo "PKG_VERSION=${PKG_VERSION}" >> $GITHUB_OUTPUT
59-
outputs:
60-
GIT_BRANCH: ${{ steps.env.outputs.GIT_BRANCH }}
61-
GIT_TAG: ${{ steps.env.outputs.GIT_TAG }}
62-
IS_RELEASE: ${{ steps.env.outputs.IS_RELEASE }}
63-
ZENOH_VERSION: ${{ steps.env.outputs.ZENOH_VERSION }}
64-
PKG_VERSION: ${{ steps.env.outputs.PKG_VERSION }}
65-
linux-build:
58+
build:
6659
name: Build packages for Linux
67-
needs: preps
60+
needs: tag
6861
runs-on: ubuntu-latest
6962
steps:
7063
- name: Clone this repository
7164
uses: actions/checkout@v4
65+
with:
66+
ref: ${{ needs.tag.outputs.branch }}
7267

73-
- name: Make packages
74-
shell: bash
75-
run: |
76-
mkdir -p build && cd build
77-
cmake ../install -DCPACK_PACKAGE_VERSION=${{ needs.preps.outputs.PKG_VERSION }}
78-
cmake --build . --target package
68+
- id: build
69+
run: bash ci/scripts/build.bash
70+
env:
71+
REPO: ${{ github.repository }}
72+
VERSION: ${{ needs.tag.outputs.version }}
7973

80-
- name: Packaging
81-
id: package
82-
shell: bash
83-
run: |
84-
ZIP_NAME=zenoh-cpp-${{ needs.preps.outputs.PKG_VERSION }}.zip
85-
LIB_PKG_NAME=${PWD}/${ZIP_NAME}
86-
DEB_PKG_NAME=${PWD}/zenoh-cpp-${{ needs.preps.outputs.PKG_VERSION }}-deb-pkgs.zip
87-
RPM_PKG_NAME=${PWD}/zenoh-cpp-${{ needs.preps.outputs.PKG_VERSION }}-rpm-pkgs.zip
88-
echo "DEB_PKG_NAME=${DEB_PKG_NAME}" >> $GITHUB_OUTPUT
89-
echo "RPM_PKG_NAME=${RPM_PKG_NAME}" >> $GITHUB_OUTPUT
90-
echo "LIB_PKG_NAME=${LIB_PKG_NAME}" >> $GITHUB_OUTPUT
91-
cd build/packages
92-
echo "Packaging ${LIB_PKG_NAME}:"
93-
mv ${ZIP_NAME} ${LIB_PKG_NAME}
94-
echo "Packaging ${DEB_PKG_NAME}:"
95-
zip ${DEB_PKG_NAME} *.deb
96-
echo "Packaging ${RPM_PKG_NAME}:"
97-
zip ${RPM_PKG_NAME} *.rpm
74+
- name: Upload library archive
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: ${{ steps.build.outputs.archive-lib }}
78+
path: ${{ steps.build.outputs.archive-lib }}
79+
80+
- name: Upload DEB archive
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: ${{ steps.build.outputs.archive-deb }}
84+
path: ${{ steps.build.outputs.archive-deb }}
9885

99-
- name: "Upload packages"
100-
uses: actions/upload-artifact@v3
86+
- name: Upload RPM archive
87+
uses: actions/upload-artifact@v4
10188
with:
102-
name: Upload packages
103-
path: |
104-
${{ steps.package.outputs.LIB_PKG_NAME }}
105-
${{ steps.package.outputs.DEB_PKG_NAME }}
106-
${{ steps.package.outputs.RPM_PKG_NAME }}
89+
name: ${{ steps.build.outputs.archive-rpm }}
90+
path: ${{ steps.build.outputs.archive-rpm }}
10791

108-
publication:
109-
name: Publish the release
110-
if: needs.preps.outputs.IS_RELEASE == 'true'
111-
needs: [preps, linux-build]
92+
eclipse:
93+
needs: [tag, build]
11294
runs-on: ubuntu-latest
11395
steps:
114-
- name: Download result of previous builds
115-
uses: actions/download-artifact@v3
96+
- uses: eclipse-zenoh/ci/publish-crates-eclipse@main
11697
with:
117-
path: ARTIFACTS
98+
live-run: ${{ inputs.live-run || false }}
99+
version: ${{ needs.tag.outputs.version }}
100+
101+
ssh-host-path: /home/data/httpd/download.eclipse.org/zenoh/zenoh-cpp
102+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
103+
ssh-passphrase: ${{ secrets.SSH_PASSPHRASE }}
104+
archive-patterns: '.*\.zip'
118105

119-
- name: Publish as github release
120-
uses: softprops/action-gh-release@v1
106+
github:
107+
needs: [tag, build]
108+
runs-on: ubuntu-latest
109+
steps:
110+
- uses: eclipse-zenoh/ci/publish-crates-github@main
121111
with:
122-
files: ARTIFACTS/*/*.*
123-
124-
- name: Publish to download.eclipse.org/zenoh
125-
env:
126-
SSH_TARGET: [email protected]
127-
ECLIPSE_BASE_DIR: /home/data/httpd/download.eclipse.org/zenoh/zenoh-cpp
128-
shell: bash
129-
run: |
130-
echo "--- setup ssh-agent"
131-
eval "$(ssh-agent -s)"
132-
echo 'echo "${{ secrets.SSH_PASSPHRASE }}"' > ~/.ssh_askpass && chmod +x ~/.ssh_askpass
133-
echo "${{ secrets.SSH_PRIVATE_KEY }}" | tr -d '\r' | DISPLAY=NONE SSH_ASKPASS=~/.ssh_askpass ssh-add - > /dev/null 2>&1
134-
rm -f ~/.ssh_askpass
135-
echo "--- test ssh:"
136-
ssh -o "StrictHostKeyChecking=no" ${SSH_TARGET} ls -al
137-
echo "---- list artifacts to upload:"
138-
ls -R ARTIFACTS || true
139-
DOWNLOAD_DIR=${ECLIPSE_BASE_DIR}/${{ needs.preps.outputs.PKG_VERSION }}
140-
echo "---- copy artifacts into ${DOWNLOAD_DIR}"
141-
ssh -o "StrictHostKeyChecking=no" ${SSH_TARGET} mkdir -p ${DOWNLOAD_DIR}
142-
cd ARTIFACTS
143-
sha256sum */* > sha256sums.txt
144-
scp -o "StrictHostKeyChecking=no" -r * ${SSH_TARGET}:${DOWNLOAD_DIR}/
145-
echo "---- cleanup identity"
146-
ssh-add -D
112+
repo: ${{ github.repository }}
113+
live-run: ${{ inputs.live-run || false }}
114+
version: ${{ needs.tag.outputs.version }}
115+
branch: ${{ needs.tag.outputs.branch }}
116+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
117+
ssh-passphrase: ${{ secrets.SSH_PASSPHRASE }}
118+
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}
119+
archive-patterns: '.*\.zip'

ci/scripts/build.bash

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
set -xeo pipefail
4+
5+
# Repository
6+
readonly repo=${REPO:?input REPO is required}
7+
# Release number
8+
readonly version=${VERSION:-''}
9+
10+
readonly out=$GITHUB_WORKSPACE
11+
readonly repo_name=${repo#*/}
12+
readonly archive_lib=$out/$repo_name-$version.zip
13+
readonly archive_deb=$out/$repo_name-$version-deb-pkgs.zip
14+
readonly archive_rpm=$out/$repo_name-$version-rpm-pkgs.zip
15+
16+
# Make packages into build/packages
17+
mkdir -p build
18+
cd build
19+
cmake ../install
20+
cmake --build . --target package
21+
ls -R
22+
23+
cd "$GITHUB_WORKSPACE"
24+
mv "build/packages/$repo_name-$version.zip" "$archive_lib"
25+
zip --verbose --junk-paths "$archive_deb" build/packages/*.deb
26+
zip --verbose --junk-paths "$archive_rpm" build/packages/*.rpm
27+
28+
{ echo "archive-lib=$(basename "$archive_lib")";
29+
echo "archive-deb=$(basename "$archive_deb")";
30+
echo "archive-rpm=$(basename "$archive_rpm")";
31+
} >> "$GITHUB_OUTPUT"

ci/scripts/bump-and-tag.bash

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
#!/usr/bin/env bash
22

3-
set -eo pipefail
3+
set -xeo pipefail
44

5-
# Repository
6-
readonly repo=${REPO:?input REPO is required}
75
# Release number
86
readonly version=${VERSION:-''}
9-
# Release branch
10-
readonly branch=${BRANCH:?input BRANCH is required}
11-
# GitHub token
12-
readonly github_token=${GITHUB_TOKEN:?input GITHUB_TOKEN is required}
137
# Git actor name
148
readonly git_user_name=${GIT_USER_NAME:?input GIT_USER_NAME is required}
159
# Git actor email
@@ -20,8 +14,6 @@ export GIT_AUTHOR_EMAIL=$git_user_email
2014
export GIT_COMMITTER_NAME=$git_user_name
2115
export GIT_COMMITTER_EMAIL=$git_user_email
2216

23-
git clone --recursive --single-branch --branch "$branch" "https://github.com/$repo"
24-
2517
# Bump CMake project version
2618
if [[ "$version" == '' ]]; then
2719
# If no version has been specified, infer it using git-describe
@@ -31,7 +23,8 @@ else
3123
fi
3224

3325
git commit version.txt -m "chore: Bump version to $version"
34-
git tag "$version" -m "v$version"
26+
git tag --force "$version" -m "v$version"
3527
git log -10
3628
git show-ref --tags
37-
git push "https://$github_token@github.com/$repo" "$branch" "$version"
29+
git push origin
30+
git push --force origin"$version"

install/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ if(UNIX)
8888
set(CPACK_DEB_COMPONENT_INSTALL ON)
8989
set(CPACK_DEBIAN_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
9090
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "")
91+
endif()
9192

9293
# RPM package
9394
# rpmbuild should be installed
@@ -102,5 +103,4 @@ if(UNIX)
102103
set(CPACK_RPM_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
103104
set(CPACK_RPM_DEV_PACKAGE_REQUIRES "")
104105
endif()
105-
106106
include(CPack)

0 commit comments

Comments
 (0)