Skip to content

Get latest release version #395

Get latest release version

Get latest release version #395

name: Get latest release version
on:
schedule:
- cron: '0 10 * * *'
workflow_dispatch: # on button click
jobs:
get-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
token: ${{ secrets.PAT }}
fetch-depth: 0
- name: Checkout latest release tag
run: |
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "Latest tag is $LATEST_TAG"
git checkout tags/$LATEST_TAG
- name: Fetch release version
run: |
curl -sL https://api.github.com/repos/keepassxreboot/keepassxc/releases/latest | \
jq -r ".tag_name" > .kpxc-upstream-version
- name: Check for modified files
id: git-check
run: |
[ -z "`git status --porcelain`" ] && echo "false" || echo "true"
echo modified=$([ -z "`git status --porcelain`" ] && echo "false" || echo "true") >> $GITHUB_OUTPUT
- name: Commit latest release version
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'Release Bot'
git config --global user.email '[email protected]'
echo "Adding file…" && git add .kpxc-upstream-version
echo "Committing file…" && git commit -am "Found new release version $(cat .kpxc-upstream-version)"
echo "Switching to new branch…" && git switch -c proposed-$(cat .kpxc-upstream-version)
echo "Adding upstream remote…" && git remote add upstream https://github.com/keepassxreboot/keepassxc.git
echo "Fetching tags…" && git fetch --tags --force upstream
echo "Merging…" && git merge --allow-unrelated-histories --strategy-option theirs --no-edit tags/$(cat .kpxc-upstream-version)
echo "Modifying changelog…" && sed -i "1s/^/keepassxc ($(cat .kpxc-upstream-version)-1~jammy1) jammy; urgency=medium\n\n * Upstream update\n\n -- Fabian Schillig <[email protected]> $(date -R)\n\n/" debian/changelog
echo "Adding changelog…" && git add debian/changelog
echo "Committing changelog…" && git commit -am "Update debian changelog"
echo "Pushing…" && git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
echo "Creating tag…" && git tag $(cat .kpxc-upstream-version)p
echo "Pushing tag…" && git push origin $(cat .kpxc-upstream-version)p