9494 curl -sL "$(curl -sL "https://api.github.com/repos/cli/cli/releases" | grep _linux_amd64.tar.gz | grep https | head -n1 | cut -d'"' -f4)" -o gh.tar.gz \
9595 && tar xzf gh.tar.gz \
9696 && find gh*/ -name gh -exec mv {} /usr/local/bin/ \;
97- git config --global --add safe.directory "$PWD " \
97+ git config --global --add safe.directory "$(pwd) " \
9898 && git tag -f ci-latest HEAD \
9999 && git push -f origin tag ci-latest
100100 find build/ -iname '*.deb' | while read -r f; do
@@ -170,6 +170,24 @@ jobs:
170170 # Checkout repository --------------------------------------------------------------------
171171 - uses : actions/checkout@v2
172172
173+ # Checkout release tag (if on release branch)
174+ - name : Checkout release tag (if on release branch)
175+ if : github.ref == 'refs/heads/ci-release'
176+ env :
177+ GH_TOKEN : ${{ github.token }}
178+ IMAGE_NAME : ${{ matrix.image }}
179+ run : |
180+ set -x
181+ git config --global --add safe.directory "$(pwd)"
182+ git fetch --tags
183+ git tag
184+ latest_tag="$(git tag | grep 'v[0-9]*\.[0-9]*\.[0-9]*' | sort -rn | head -n1)"
185+ if [ -z "$latest_tag" ]; then
186+ echo "could not find latest tag"
187+ exit 1
188+ fi
189+ git checkout "$latest_tag"
190+
173191 # Build LIBFDS RPM package ---------------------------------------------------------------
174192 - name : Checkout libfds library - master branch
175193 if : github.ref == 'refs/heads/master'
@@ -199,7 +217,6 @@ jobs:
199217 ipfixcol2 -L -v
200218 - name : Build IPFIXcol2 ClickHouse Output RPMs
201219 run : |
202- set -xe
203220 rpmdev-setuptree
204221 cp -r ./extra_plugins/output/clickhouse/ ./ipfixcol2-clickhouse-output-1.0.0/
205222 tar -czvf ~/rpmbuild/SOURCES/ipfixcol2-clickhouse-output-1.0.0.tar.gz ./ipfixcol2-clickhouse-output-1.0.0
@@ -217,7 +234,8 @@ jobs:
217234 path : |
218235 build/pkg/rpm/rpmbuild/RPMS/
219236 build/pkg/rpm/rpmbuild/SRPMS/
220- - name : Publish RPM packages to GitHub releases
237+
238+ - name : Publish RPM packages to GitHub releases (latest)
221239 if : github.ref == 'refs/heads/master' || github.ref == 'refs/heads/ci-publish-packages-to-releases'
222240 env :
223241 GH_TOKEN : ${{ github.token }}
@@ -226,11 +244,33 @@ jobs:
226244 curl -sL "$(curl -sL "https://api.github.com/repos/cli/cli/releases" | grep _linux_amd64.tar.gz | grep https | head -n1 | cut -d'"' -f4)" -o gh.tar.gz \
227245 && tar xzf gh.tar.gz \
228246 && find gh*/ -name gh -exec mv {} /usr/local/bin/ \;
229- git config --global --add safe.directory "$PWD " \
247+ git config --global --add safe.directory "$(pwd) " \
230248 && git tag -f ci-latest HEAD \
231249 && git push -f origin tag ci-latest
232250 find build/ -iname '*.rpm' | while read -r f; do
233251 newf="$IMAGE_NAME-$(basename "$f")"
234252 mv "$f" "$newf"
235253 gh release upload --clobber ci-latest "$newf"
236254 done
255+
256+ - name : Publish RPM packages to GitHub releases (stable)
257+ if : github.ref == 'refs/heads/ci-release'
258+ env :
259+ GH_TOKEN : ${{ github.token }}
260+ IMAGE_NAME : ${{ matrix.image }}
261+ run : |
262+ curl -sL "$(curl -sL "https://api.github.com/repos/cli/cli/releases" | grep _linux_amd64.tar.gz | grep https | head -n1 | cut -d'"' -f4)" -o gh.tar.gz \
263+ && tar xzf gh.tar.gz \
264+ && find gh*/ -name gh -exec mv {} /usr/local/bin/ \;
265+
266+ latest_tag="$(git describe --exact-match --tags)"
267+ if ! gh release view "$latest_tag"; then
268+ echo "could not find release for tag $latest_tag"
269+ exit 1
270+ fi
271+
272+ find build/ -iname '*.rpm' | while read -r f; do
273+ newf="$IMAGE_NAME-$(basename "$f")"
274+ mv "$f" "$newf"
275+ gh release upload --clobber "$latest_tag" "$newf"
276+ done
0 commit comments