Skip to content

Update Gamescope

Update Gamescope #6840

Workflow file for this run

name: Update Gamescope
on:
workflow_dispatch:
schedule:
- cron: "0 * * * *"
jobs:
update-gamescope:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get Latest Commit
id: get-commit
run: |
latest_commit=$(curl -s https://api.github.com/repos/ValveSoftware/gamescope/commits/master | jq -r '.sha')
latest_git_date=$(curl -s https://api.github.com/repos/ValveSoftware/gamescope/commits/master | jq -r '.commit.committer.date' | cut -d "T" -f1 | sed 's/-//g')
latest_tag=$(curl -s https://api.github.com/repos/ValveSoftware/gamescope/tags | jq -r '.[0].name')
echo "latest-commit=$latest_commit" >> $GITHUB_OUTPUT
echo "latest-git-date=$latest_git_date" >> $GITHUB_OUTPUT
echo "latest-tag=$latest_tag" >> $GITHUB_OUTPUT
- name: Get Current Commit
id: get-current-commit
run: |
current_commit=$(grep -oP '(?<=^%global commit ).*' gamescope.spec)
current_git_date=$(grep -oP '(?<=^%global git_date ).*' gamescope.spec)
current_ver_count=$(grep -oP '(?<=^%global ver_count ).*' gamescope.spec)
echo "current-commit=$current_commit" >> $GITHUB_OUTPUT
echo "current-git-date=$current_git_date" >> $GITHUB_OUTPUT
echo "current-ver-count=$current_ver_count" >> $GITHUB_OUTPUT
- name: Compare Commits
id: compare-commits
run: |
if [ "${{ steps.get-commit.outputs.latest-commit }}" != "${{ steps.get-current-commit.outputs.current-commit }}" ]; then
echo "new-commit='true'" >> $GITHUB_OUTPUT
if [ "${{ steps.get-commit.outputs.latest-git-date }}" == "${{ steps.get-current-commit.outputs.current-git-date }}" ]; then
new_ver_count=$((${{ steps.get-current-commit.outputs.current-ver-count }} + 1))
echo "ver-count=$new_ver_count" >> $GITHUB_OUTPUT
else
echo "ver-count=1" >> $GITHUB_OUTPUT
fi
else
echo "new-commit='false'" >> $GITHUB_OUTPUT
fi
- name: Update Spec File
if: ${{ contains(steps.compare-commits.outputs.new-commit, 'true') }}
run: |
sed -i "s/%global commit .*/%global commit ${{ steps.get-commit.outputs.latest-commit }}/g" gamescope.spec
sed -i "s/%global git_date .*/%global git_date ${{ steps.get-commit.outputs.latest-git-date }}/g" gamescope.spec
if [[ "${{ steps.get-commit.outputs.latest-tag }}" != *"-"* ]]; then
sed -i "s/%global tag .*/%global tag ${{ steps.get-commit.outputs.latest-tag }}/g" gamescope.spec
fi
sed -i "s/%global ver_count .*/%global ver_count ${{ steps.compare-commits.outputs.ver-count }}/g" gamescope.spec
- name: Commit and Push Changes
if: ${{ contains(steps.compare-commits.outputs.new-commit, 'true') }}
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add gamescope.spec
git commit -m "Update gamescope to ${{ steps.get-commit.outputs.latest-commit }}"
git push