Skip to content

Commit 43ccc73

Browse files
committed
...
1 parent 1ee75db commit 43ccc73

3 files changed

Lines changed: 35 additions & 49 deletions

File tree

.github/workflows/packages.yml

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ jobs:
4646
DEBIAN_FRONTEND: noninteractive
4747

4848
# Checkout repository --------------------------------------------------------------------
49-
- uses: actions/checkout@v2
49+
- uses: actions/checkout@v4
50+
51+
# Install GitHub CLI
52+
- name: Install GitHub CLI
53+
run: .github/workflow/scripts/install-gh-cli.sh
5054

5155
# Checkout release tag (if on release branch)
5256
- name: Checkout release tag (if on release branch)
@@ -55,7 +59,6 @@ jobs:
5559
GH_TOKEN: ${{ github.token }}
5660
IMAGE_NAME: ${{ matrix.image }}
5761
run: |
58-
git config --global --add safe.directory "$PWD"
5962
git fetch --tags
6063
latest_tag="$(git tag | grep 'v[0-9]*\.[0-9]*\.[0-9]*' | sort -rn | head -n1)"
6164
if [ -z "$latest_tag" ]; then
@@ -108,37 +111,23 @@ jobs:
108111
GH_TOKEN: ${{ github.token }}
109112
IMAGE_NAME: ${{ matrix.image }}
110113
run: |
111-
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 \
112-
&& tar xzf gh.tar.gz \
113-
&& find gh*/ -name gh -exec mv {} /usr/local/bin/ \;
114114
git config --global --add safe.directory "$PWD" \
115115
&& git tag -f ci-latest HEAD \
116116
&& git push -f origin tag ci-latest
117-
find build/ -iname '*.deb' | while read -r f; do
118-
newf="$IMAGE_NAME-$(basename "$f")"
119-
mv "$f" "$newf"
120-
gh release upload --clobber ci-latest "$newf"
121-
done
117+
TAG_NAME="ci-latest" ./.github/workflows/scripts/upload-packages.sh
122118
123119
- name: Publish DEB packages to GitHub releases (stable)
124120
if: github.ref == 'refs/heads/ci-release'
125121
env:
126122
GH_TOKEN: ${{ github.token }}
127123
IMAGE_NAME: ${{ matrix.image }}
128124
run: |
129-
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 \
130-
&& tar xzf gh.tar.gz \
131-
&& find gh*/ -name gh -exec mv {} /usr/local/bin/ \;
132125
latest_tag="$(git describe --exact-match --tags)"
133126
if ! gh release view "$latest_tag"; then
134127
echo "could not find release for tag $latest_tag"
135128
exit 1
136129
fi
137-
find build/ -iname '*.deb' | while read -r f; do
138-
newf="$IMAGE_NAME-$(basename "$f")"
139-
mv "$f" "$newf"
140-
gh release upload --clobber "$latest_tag" "$newf"
141-
done
130+
TAG_NAME="$latest_tag" ./.github/workflows/scripts/upload-packages.sh
142131
143132
rpm:
144133
# Try to build RPM packages
@@ -211,7 +200,11 @@ jobs:
211200
yum -y install rpmdevtools
212201
213202
# Checkout repository --------------------------------------------------------------------
214-
- uses: actions/checkout@v2
203+
- uses: actions/checkout@v4
204+
205+
# Install GitHub CLI
206+
- name: Install GitHub CLI
207+
run: .github/workflow/scripts/install-gh-cli.sh
215208

216209
# Checkout release tag (if on release branch)
217210
- name: Checkout release tag (if on release branch)
@@ -286,47 +279,19 @@ jobs:
286279
GH_TOKEN: ${{ github.token }}
287280
IMAGE_NAME: ${{ matrix.image }}
288281
run: |
289-
set -x
290-
291-
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 \
292-
&& tar xzf gh.tar.gz \
293-
&& find gh*/ -name gh -exec mv {} /usr/local/bin/ \;
294-
295-
git config --global --add safe.directory "$PWD"
296282
git tag -f ci-latest HEAD
297283
git push -f origin tag ci-latest
298-
299-
IFS=$'\n'
300-
set +e; assets="$(gh release view ci-latest | grep '^asset:' | cut -f2 | grep -F "${IMAGE_NAME//:/.}")"; set -e
301-
files="$(find build/ -iname '*.rpm')"
302-
for f in $files; do
303-
newf="$IMAGE_NAME-$(basename "$f")"
304-
mv "$f" "$newf"
305-
gh release upload --clobber ci-latest "$newf"
306-
set +e; assets="$(grep -vF "${newf//:/.}" <<<"$assets")"; set -e
307-
done
308-
309-
for asset in $assets; do
310-
gh release delete-asset ci-latest "$asset"
311-
done
284+
TAG_NAME="ci-latest" ./.github/workflows/scripts/upload-packages.sh
312285
313286
- name: Publish RPM packages to GitHub releases (stable)
314287
if: github.ref == 'refs/heads/ci-release'
315288
env:
316289
GH_TOKEN: ${{ github.token }}
317290
IMAGE_NAME: ${{ matrix.image }}
318291
run: |
319-
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 \
320-
&& tar xzf gh.tar.gz \
321-
&& find gh*/ -name gh -exec mv {} /usr/local/bin/ \;
322292
latest_tag="$(git describe --exact-match --tags)"
323293
if ! gh release view "$latest_tag"; then
324294
echo "could not find release for tag $latest_tag"
325295
exit 1
326296
fi
327-
328-
find build/ -iname '*.rpm' | while read -r f; do
329-
newf="$IMAGE_NAME-$(basename "$f")"
330-
mv "$f" "$newf"
331-
gh release upload --clobber "$latest_tag" "$newf"
332-
done
297+
TAG_NAME="$latest_tag" ./.github/workflows/scripts/upload-packages.sh
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -eu
3+
tmpdir="$(mktemp -d)"; mkdir "$tmpdir"; cd "$tmpdir"
4+
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
5+
tar xzf gh.tar.gz
6+
find gh*/ -name gh -exec mv {} /usr/local/bin/ \;
7+
rm -rf "$tmpdir"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -eu
3+
IFS=$'\n'
4+
set +e; assets="$(gh release view "$TAG_NAME" | grep '^asset:' | cut -f2 | grep -F "${IMAGE_NAME//:/.}")"; set -e
5+
files="$(find build/ \( -iname '*.rpm' -or -iname '*.deb' \) )"
6+
for f in $files; do
7+
newf="$IMAGE_NAME-$(basename "$f")"
8+
mv "$f" "$newf"
9+
gh release upload --clobber ci-latest "$newf"
10+
set +e; assets="$(grep -vF "${newf//:/.}" <<<"$assets")"; set -e
11+
done
12+
for asset in $assets; do
13+
gh release delete-asset "$TAG_NAME" "$asset"
14+
done

0 commit comments

Comments
 (0)