91 lines
2.7 KiB
YAML
91 lines
2.7 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: 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
|
|
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"
|