68 lines
2.1 KiB
YAML
68 lines
2.1 KiB
YAML
name: Update README version
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "17 2 * * *"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
update-readme-version:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
TARBALL_URL: https://packages.element.io/desktop/install/linux/glibc-x86-64/element-desktop.tar.gz
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITEA_TOKEN }}
|
|
fetch-depth: 0
|
|
ref: ${{ gitea.ref_name }}
|
|
|
|
- name: Detect latest upstream version
|
|
id: version
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
topdir="$(curl -fsSL "$TARBALL_URL" | tar -tzf - | sed -n '1s#/##p')"
|
|
latest_version="${topdir#element-desktop-}"
|
|
current_version="$(sed -n 's/^Latest upstream version tracked in this repo: `\([^`]*\)`$/\1/p' README.md)"
|
|
|
|
if [ -z "$latest_version" ] || [ "$latest_version" = "$topdir" ]; then
|
|
echo "Failed to derive upstream version from tarball root: $topdir" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$current_version" ]; then
|
|
echo "Could not find tracked version marker in README.md" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "latest=$latest_version" >> "$GITHUB_OUTPUT"
|
|
echo "current=$current_version" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Update README
|
|
if: steps.version.outputs.latest != steps.version.outputs.current
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
sed -i \
|
|
"s/^Latest upstream version tracked in this repo: .*/Latest upstream version tracked in this repo: \`${{ steps.version.outputs.latest }}\`/" \
|
|
README.md
|
|
|
|
- name: Commit and push update
|
|
if: steps.version.outputs.latest != steps.version.outputs.current
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
git config user.name "Gitea Actions"
|
|
git config user.email "actions@localhost"
|
|
git add README.md
|
|
git commit -m "docs: update tracked Element Desktop version to ${{ steps.version.outputs.latest }}"
|
|
git push
|