Upgrade Temml if possible #77
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-License-Identifier: CC0-1.0 | |
name: Upgrade Temml if possible | |
on: | |
schedule: | |
- cron: '30 18 * * 4' | |
workflow_dispatch: | |
jobs: | |
pr: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
ruby-version: '3.3' | |
- name: Check versions | |
id: check-versions | |
run: | | |
current_version=$(perl -ne "print \$1 if /TEMML_VERSION = '(\d+\.\d+\.\d+)'/" lib/temml/version.rb) | |
upstream_version=$(curl -sL https://api.github.com/repos/ronkok/Temml/releases/latest | jq -r '.tag_name' | sed 's/^v//') | |
newer_version=$(echo -e "${current_version}\n${upstream_version}" | sort -V | tail -n1) | |
{ \ | |
echo "current_version=${current_version}"; \ | |
echo "upstream_version=${upstream_version}"; \ | |
echo "newer_version=${newer_version}"; \ | |
} >> "$GITHUB_OUTPUT" | |
echo "current version: ${current_version}" | |
echo "upstream version: ${upstream_version}" | |
echo "newer_version: ${newer_version}" | |
- name: Import Temml assets | |
if: > | |
steps.check-versions.outputs.current_version != steps.check-versions.outputs.upstream_version && | |
steps.check-versions.outputs.newer_version == steps.check-versions.outputs.upstream_version | |
run: | | |
bundle exec rake "update[${{ steps.check-versions.outputs.newer_version }}]" | |
- uses: peter-evans/create-pull-request@v6 | |
if: > | |
steps.check-versions.outputs.current_version != steps.check-versions.outputs.upstream_version && | |
steps.check-versions.outputs.newer_version == steps.check-versions.outputs.upstream_version | |
with: | |
commit-message: rake update[${{ steps.check-versions.outputs.newer_version }}] | |
branch: upgrade-temml-to-${{ steps.check-versions.outputs.newer_version }} | |
delete-branch: true | |
title: Upgrade Temml to v${{ steps.check-versions.outputs.newer_version }} | |
body: | | |
Upgrade Temml to v[${{ steps.check-versions.outputs.newer_version }}](https://github.com/ronkok/Temml/releases/tag/v${{ steps.check-versions.outputs.newer_version }}). | |
Don't forget to execute the workflow! | |
[![lint and test](https://github.com/sudotac/temml-ruby/actions/workflows/lint-and-test.yml/badge.svg?branch=upgrade-temml-to-${{ steps.check-versions.outputs.newer_version }})](https://github.com/sudotac/temml-ruby/actions/workflows/lint-and-test.yml) | |
assignees: sudotac | |
reviewers: sudotac |