-
Notifications
You must be signed in to change notification settings - Fork 34
146 lines (136 loc) · 5.36 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#
# Copyright (c) 2022 ZettaScale Technology
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# ZettaScale Zenoh Team, <[email protected]>
#
name: Release
on:
release:
types: [published]
schedule:
- cron: "0 0 * * 1-5"
workflow_dispatch:
jobs:
preps:
name: Preparation
runs-on: ubuntu-latest
steps:
- name: Clone this repository
uses: actions/checkout@v4
- name: Environment setup
id: env
shell: bash
run: |
echo "GITHUB_REF=${GITHUB_REF}"
echo "GITHUB_SHA=${GITHUB_SHA:0:8}"
GIT_BRANCH=`[[ $GITHUB_REF =~ ^refs/heads/.* ]] && echo ${GITHUB_REF/refs\/heads\//} || true`
echo "GIT_BRANCH=${GIT_BRANCH}"
echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_OUTPUT
GIT_TAG=`[[ $GITHUB_REF =~ ^refs/tags/.* ]] && echo ${GITHUB_REF/refs\/tags\//} || true`
echo "GIT_TAG=${GIT_TAG}"
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
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)
echo "ZENOH_VERSION=${ZENOH_VERSION}"
echo "ZENOH_VERSION=${ZENOH_VERSION}" >> $GITHUB_OUTPUT
if [ -n "${GIT_TAG}" ]; then
IS_RELEASE="true"
echo "IS_RELEASE=${IS_RELEASE}"
echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT
PKG_VERSION=${ZENOH_VERSION}
elif [ -n "${GIT_BRANCH}" ]; then
PKG_VERSION=${GIT_BRANCH}-${GITHUB_SHA:0:8}
else
PKG_VERSION=${ZENOH_VERSION}-${GITHUB_SHA:0:8}
fi
echo "PKG_VERSION=${PKG_VERSION}"
echo "PKG_VERSION=${PKG_VERSION}" >> $GITHUB_OUTPUT
outputs:
GIT_BRANCH: ${{ steps.env.outputs.GIT_BRANCH }}
GIT_TAG: ${{ steps.env.outputs.GIT_TAG }}
IS_RELEASE: ${{ steps.env.outputs.IS_RELEASE }}
ZENOH_VERSION: ${{ steps.env.outputs.ZENOH_VERSION }}
PKG_VERSION: ${{ steps.env.outputs.PKG_VERSION }}
linux-build:
name: Build packages for Linux
needs: preps
runs-on: ubuntu-latest
steps:
- name: Clone this repository
uses: actions/checkout@v4
- name: Make packages
shell: bash
run: |
mkdir -p build && cd build
cmake ../install -DCPACK_PACKAGE_VERSION=${{ needs.preps.outputs.PKG_VERSION }}
cmake --build . --target package
- name: Packaging
id: package
shell: bash
run: |
ZIP_NAME=zenoh-cpp-${{ needs.preps.outputs.PKG_VERSION }}.zip
LIB_PKG_NAME=${PWD}/${ZIP_NAME}
DEB_PKG_NAME=${PWD}/zenoh-cpp-${{ needs.preps.outputs.PKG_VERSION }}-deb-pkgs.zip
RPM_PKG_NAME=${PWD}/zenoh-cpp-${{ needs.preps.outputs.PKG_VERSION }}-rpm-pkgs.zip
echo "DEB_PKG_NAME=${DEB_PKG_NAME}" >> $GITHUB_OUTPUT
echo "RPM_PKG_NAME=${RPM_PKG_NAME}" >> $GITHUB_OUTPUT
echo "LIB_PKG_NAME=${LIB_PKG_NAME}" >> $GITHUB_OUTPUT
cd build/packages
echo "Packaging ${LIB_PKG_NAME}:"
mv ${ZIP_NAME} ${LIB_PKG_NAME}
echo "Packaging ${DEB_PKG_NAME}:"
zip ${DEB_PKG_NAME} *.deb
echo "Packaging ${RPM_PKG_NAME}:"
zip ${RPM_PKG_NAME} *.rpm
- name: "Upload packages"
uses: actions/upload-artifact@v3
with:
name: Upload packages
path: |
${{ steps.package.outputs.LIB_PKG_NAME }}
${{ steps.package.outputs.DEB_PKG_NAME }}
${{ steps.package.outputs.RPM_PKG_NAME }}
publication:
name: Publish the release
if: needs.preps.outputs.IS_RELEASE == 'true'
needs: [preps, linux-build]
runs-on: ubuntu-latest
steps:
- name: Download result of previous builds
uses: actions/download-artifact@v3
with:
path: ARTIFACTS
- name: Publish as github release
uses: softprops/action-gh-release@v1
with:
files: ARTIFACTS/*/*.*
- name: Publish to download.eclipse.org/zenoh
env:
SSH_TARGET: [email protected]
ECLIPSE_BASE_DIR: /home/data/httpd/download.eclipse.org/zenoh/zenoh-cpp
shell: bash
run: |
echo "--- setup ssh-agent"
eval "$(ssh-agent -s)"
echo 'echo "${{ secrets.SSH_PASSPHRASE }}"' > ~/.ssh_askpass && chmod +x ~/.ssh_askpass
echo "${{ secrets.SSH_PRIVATE_KEY }}" | tr -d '\r' | DISPLAY=NONE SSH_ASKPASS=~/.ssh_askpass ssh-add - > /dev/null 2>&1
rm -f ~/.ssh_askpass
echo "--- test ssh:"
ssh -o "StrictHostKeyChecking=no" ${SSH_TARGET} ls -al
echo "---- list artifacts to upload:"
ls -R ARTIFACTS || true
DOWNLOAD_DIR=${ECLIPSE_BASE_DIR}/${{ needs.preps.outputs.PKG_VERSION }}
echo "---- copy artifacts into ${DOWNLOAD_DIR}"
ssh -o "StrictHostKeyChecking=no" ${SSH_TARGET} mkdir -p ${DOWNLOAD_DIR}
cd ARTIFACTS
sha256sum */* > sha256sums.txt
scp -o "StrictHostKeyChecking=no" -r * ${SSH_TARGET}:${DOWNLOAD_DIR}/
echo "---- cleanup identity"
ssh-add -D