Update C++ Library Component #6
Workflow file for this run
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
name: Update C++ Library Component | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout R package repo | |
uses: actions/checkout@v2 | |
- name: Check for new release | |
id: check_release | |
run: | | |
API_URL="https://api.github.com/repos/jolars/qualpal/releases/latest" | |
NEW_VERSION=$(curl -s $API_URL | jq -r '.tag_name' | tr -d 'v') | |
CURRENT_VERSION=$(cat src/qualpal/version.txt) | |
if [[ "$NEW_VERSION" != "$CURRENT_VERSION" ]]; then | |
RELEASE_URL=$(curl -s $API_URL | grep "tarball_url" | cut -d '"' -f 4) | |
echo "release_url=$RELEASE_URL" >> $GITHUB_OUTPUT | |
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
echo "update_needed=true" >> $GITHUB_OUTPUT | |
else | |
echo "update_needed=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Download and extract new release | |
if: steps.check_release.outputs.update_needed == 'true' | |
run: | | |
mkdir -p tmp | |
curl -L "${{ steps.check_release.outputs.release_url }}" | tar -xz --strip-components=1 -C tmp | |
rm -rf src/qualpal | |
cp -ri tmp/src/qualpal src/ | |
rm -rf tmp | |
- name: Write new version number | |
if: steps.check_release.outputs.update_needed == 'true' | |
run: | | |
echo "${{ steps.check_release.outputs.new_version }}" > src/qualpal/version.txt | |
- name: Create PR | |
if: steps.check_release.outputs.update_needed == 'true' | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "chore(deps): update qualpal c++ library to ${{ steps.check_release.outputs.new_version }}" | |
title: "Update qualpal C++ library to ${{ steps.check_release.outputs.new_version }}" | |
body: This PR updates the qualpal C++ library to the latest release. |