Files
copr-rpms/.gitea/workflows/update-readme-version.yaml
T
2026-05-04 10:25:13 -04:00

106 lines
3.6 KiB
YAML

name: Update README version
on:
push:
branches:
- master
schedule:
- cron: "17 2 * * *"
workflow_dispatch:
permissions:
contents: write
jobs:
update-readme-version:
runs-on: ubuntu-latest
env:
COPR_WEBHOOK_URL: ${{ secrets.COPR_WEBHOOK_URL }}
TARBALL_URL_AARCH64: https://packages.element.io/desktop/install/linux/glibc-aarch64/element-desktop.tar.gz
TARBALL_URL_X86_64: 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_x86_64="$(curl -fsSL "$TARBALL_URL_X86_64" | tar -tzf - | sed -n '1s#/##p')"
topdir_aarch64="$(curl -fsSL "$TARBALL_URL_AARCH64" | tar -tzf - | sed -n '1s#/##p')"
latest_version_x86_64="${topdir_x86_64#element-desktop-}"
latest_version_aarch64="${topdir_aarch64#element-desktop-}"
latest_version_aarch64="${latest_version_aarch64%-arm64}"
current_version="$(sed -n 's/^Latest upstream version tracked in this repo: `\([^`]*\)`$/\1/p' README.md)"
if [ -z "$latest_version_x86_64" ] || [ "$latest_version_x86_64" = "$topdir_x86_64" ]; then
echo "Failed to derive upstream x86_64 version from tarball root: $topdir_x86_64" >&2
exit 1
fi
if [ -z "$latest_version_aarch64" ] || [ "$latest_version_aarch64" = "$topdir_aarch64" ]; then
echo "Failed to derive upstream aarch64 version from tarball root: $topdir_aarch64" >&2
exit 1
fi
if [ -z "$current_version" ]; then
echo "Could not find tracked version marker in README.md" >&2
exit 1
fi
if [ "$latest_version_x86_64" != "$latest_version_aarch64" ]; then
echo "Upstream version mismatch: x86_64=$latest_version_x86_64 aarch64=$latest_version_aarch64" >&2
exit 1
fi
echo "latest=$latest_version_x86_64" >> "$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
id: commit
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
echo "pushed=true" >> "$GITHUB_OUTPUT"
- name: Trigger COPR build
if: gitea.event_name == 'push' && steps.commit.outputs.pushed != 'true'
shell: bash
run: |
set -euo pipefail
if [ -z "${COPR_WEBHOOK_URL:-}" ]; then
echo "COPR_WEBHOOK_URL secret is not set" >&2
exit 1
fi
curl --fail --show-error --silent \
--retry 3 \
--retry-all-errors \
-X POST \
"$COPR_WEBHOOK_URL"