From 5175af0a78354d5e6e60bd65827f9bb582086991 Mon Sep 17 00:00:00 2001 From: Thomas Zahner Date: Thu, 20 Nov 2025 13:48:16 +0100 Subject: [PATCH 1/5] Create script and workflow --- .github/workflows/bump-lychee-version.yml | 20 ++++++++++++++++++++ bump-lychee.sh | 23 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 .github/workflows/bump-lychee-version.yml create mode 100755 bump-lychee.sh diff --git a/.github/workflows/bump-lychee-version.yml b/.github/workflows/bump-lychee-version.yml new file mode 100644 index 0000000..07068df --- /dev/null +++ b/.github/workflows/bump-lychee-version.yml @@ -0,0 +1,20 @@ +name: Links + +on: push + +# on: +# repository_dispatch: +# workflow_dispatch: +# schedule: +# - cron: "00 18 * * *" + +jobs: + bumpLycheeVersion: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - name: Bump lychee version + run: ./bump-lychee.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/bump-lychee.sh b/bump-lychee.sh new file mode 100755 index 0000000..b4a3178 --- /dev/null +++ b/bump-lychee.sh @@ -0,0 +1,23 @@ +#! /usr/bin/env bash + +POSITION=1 # 0 is nightly, 1 is latest stable release +LATEST=$(curl "https://api.github.com/repos/lycheeverse/lychee/releases" | jq -r ".[$POSITION] | .name") +FILE=src/generate/lychee-version.ts + +sed -i -e "s/LYCHEE_VERSION = \"[^\"]*\"/LYCHEE_VERSION = \"$LATEST\"/" $FILE + +if git status --porcelain | grep $FILE; then + echo New version found: $LATEST + git add $FILE + BRANCH="bump-$LATEST" + MESSAGE="Bump lychee: $LATEST" + git checkout -b $BRANCH + git add $FILE + git config user.name "lychee bot" + git config user.email "noreply@lychee.cli.rs" + git commit --message "$MESSAGE" + git push -u origin $BRANCH + gh pr create -B master -H $BRANCH --title "$MESSAGE" --body 'Created by Github action' +else + echo Version is up to date +fi From 9346b3a9b37f86b86576c2b96c176a4309b92e2a Mon Sep 17 00:00:00 2001 From: Thomas Zahner Date: Thu, 20 Nov 2025 14:14:50 +0100 Subject: [PATCH 2/5] Update workflow name and trigger --- .github/workflows/bump-lychee-version.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/bump-lychee-version.yml b/.github/workflows/bump-lychee-version.yml index 07068df..5ea9275 100644 --- a/.github/workflows/bump-lychee-version.yml +++ b/.github/workflows/bump-lychee-version.yml @@ -1,12 +1,10 @@ -name: Links +name: Bump lychee version -on: push - -# on: -# repository_dispatch: -# workflow_dispatch: -# schedule: -# - cron: "00 18 * * *" +on: + repository_dispatch: + workflow_dispatch: + schedule: + - cron: "00 18 * * *" jobs: bumpLycheeVersion: From 97f06f85e1132d84079a55b2369be5157d296c6e Mon Sep 17 00:00:00 2001 From: Thomas Zahner Date: Wed, 10 Dec 2025 16:18:47 +0100 Subject: [PATCH 3/5] Update endpoint Thanks @katrinafyi for the idea --- bump-lychee.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bump-lychee.sh b/bump-lychee.sh index b4a3178..4559769 100755 --- a/bump-lychee.sh +++ b/bump-lychee.sh @@ -1,7 +1,6 @@ #! /usr/bin/env bash -POSITION=1 # 0 is nightly, 1 is latest stable release -LATEST=$(curl "https://api.github.com/repos/lycheeverse/lychee/releases" | jq -r ".[$POSITION] | .name") +LATEST=$(curl "https://api.github.com/repos/lycheeverse/lychee/releases/latest" | jq -r ".name") FILE=src/generate/lychee-version.ts sed -i -e "s/LYCHEE_VERSION = \"[^\"]*\"/LYCHEE_VERSION = \"$LATEST\"/" $FILE From 27fedd832c2d6e261b9eddeaf73b9289f28ebaf9 Mon Sep 17 00:00:00 2001 From: Thomas Zahner Date: Wed, 10 Dec 2025 17:07:42 +0100 Subject: [PATCH 4/5] Better error handling --- bump-lychee.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bump-lychee.sh b/bump-lychee.sh index 4559769..3dd5a49 100755 --- a/bump-lychee.sh +++ b/bump-lychee.sh @@ -1,6 +1,8 @@ #! /usr/bin/env bash -LATEST=$(curl "https://api.github.com/repos/lycheeverse/lychee/releases/latest" | jq -r ".name") +set -euo pipefail + +LATEST=$(curl --fail "https://api.github.com/repos/lycheeverse/lychee/releases/latest" | jq -er ".name") FILE=src/generate/lychee-version.ts sed -i -e "s/LYCHEE_VERSION = \"[^\"]*\"/LYCHEE_VERSION = \"$LATEST\"/" $FILE From 2d1c2806f401e94f0c00b65f2a6be54c4e08aea3 Mon Sep 17 00:00:00 2001 From: Thomas Zahner Date: Wed, 10 Dec 2025 17:48:30 +0100 Subject: [PATCH 5/5] Only set git user in CI --- bump-lychee.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bump-lychee.sh b/bump-lychee.sh index 3dd5a49..ef9315f 100755 --- a/bump-lychee.sh +++ b/bump-lychee.sh @@ -1,12 +1,17 @@ #! /usr/bin/env bash -set -euo pipefail +set -eo pipefail LATEST=$(curl --fail "https://api.github.com/repos/lycheeverse/lychee/releases/latest" | jq -er ".name") FILE=src/generate/lychee-version.ts sed -i -e "s/LYCHEE_VERSION = \"[^\"]*\"/LYCHEE_VERSION = \"$LATEST\"/" $FILE +if [ -n "$CI" ]; then + git config user.name "lychee bot" + git config user.email "noreply@lychee.cli.rs" +fi + if git status --porcelain | grep $FILE; then echo New version found: $LATEST git add $FILE @@ -14,8 +19,6 @@ if git status --porcelain | grep $FILE; then MESSAGE="Bump lychee: $LATEST" git checkout -b $BRANCH git add $FILE - git config user.name "lychee bot" - git config user.email "noreply@lychee.cli.rs" git commit --message "$MESSAGE" git push -u origin $BRANCH gh pr create -B master -H $BRANCH --title "$MESSAGE" --body 'Created by Github action'