diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index b63a9c1..0caa13a 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -17,10 +17,17 @@ jobs: test: runs-on: ubuntu-latest steps: - - run: | - export HUGO_VERSION=$(curl --silent -I https://github.com/gohugoio/hugo/releases/latest | grep location | sed 's|.*tag/||' | tr -d '\r') - export HUGO_VERSION_SHORT=$(echo ${HUGO_VERSION} | sed 's/v//') - wget https://github.com/gohugoio/hugo/releases/download/${HUGO_VERSION}/hugo_${HUGO_VERSION_SHORT}_linux-amd64.deb + - name: Install latest Hugo + run: | + set -euo pipefail + tag="$(curl --silent --show-error --location --fail-with-body \ + -H 'Accept: application/vnd.github+json' \ + https://api.github.com/repos/gohugoio/hugo/releases/latest \ + | jq -r '.tag_name // empty')" + [ -n "$tag" ] || { echo "no tag_name in gohugoio/hugo releases/latest" >&2; exit 1; } + export HUGO_VERSION="$tag" + export HUGO_VERSION_SHORT="${HUGO_VERSION#v}" + wget "https://github.com/gohugoio/hugo/releases/download/${HUGO_VERSION}/hugo_${HUGO_VERSION_SHORT}_linux-amd64.deb" dpkg -i hugo_*.deb - uses: actions/checkout@v4 with: diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index e3241a1..6d46bc1 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -17,10 +17,17 @@ jobs: test: runs-on: ubuntu-latest steps: - - run: | - export HUGO_VERSION=$(curl --silent -I https://github.com/gohugoio/hugo/releases/latest | grep location | sed 's|.*tag/||' | tr -d '\r') - export HUGO_VERSION_SHORT=$(echo ${HUGO_VERSION} | sed 's/v//') - wget https://github.com/gohugoio/hugo/releases/download/${HUGO_VERSION}/hugo_${HUGO_VERSION_SHORT}_linux-amd64.deb + - name: Install latest Hugo + run: | + set -euo pipefail + tag="$(curl --silent --show-error --location --fail-with-body \ + -H 'Accept: application/vnd.github+json' \ + https://api.github.com/repos/gohugoio/hugo/releases/latest \ + | jq -r '.tag_name // empty')" + [ -n "$tag" ] || { echo "no tag_name in gohugoio/hugo releases/latest" >&2; exit 1; } + export HUGO_VERSION="$tag" + export HUGO_VERSION_SHORT="${HUGO_VERSION#v}" + wget "https://github.com/gohugoio/hugo/releases/download/${HUGO_VERSION}/hugo_${HUGO_VERSION_SHORT}_linux-amd64.deb" dpkg -i hugo_*.deb - uses: actions/checkout@v4 with: