Create dependency bump PR #9
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
# Based on nomeata's dep bumper, should go back to using that when it supports executing build-tzdata.sh after checkout | |
name: Create dependency bump PR | |
on: | |
# allows manual triggering from https://github.com/../../actions/workflows/bump.yml | |
workflow_dispatch: | |
# runs weekly on Thursday at 8:00 | |
schedule: | |
- cron: '0 8 * * 4' | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
bump: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./servant-swagger-ui-core | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache cabal store | |
id: cache | |
uses: actions/cache/restore@v3 | |
with: | |
key: bump-action-cabal-store-${{ runner.os }}-${{ github.sha }} | |
path: ~/.cabal/store | |
restore-keys: bump-action-cabal-store-${{ runner.os }}- | |
- uses: haskell/actions/setup@v2 | |
with: | |
ghc-version: latest | |
- name: Run cabal outdated | |
shell: bash | |
run: | | |
cabal outdated | |
# also remember the values and the number of changes | |
echo 'Output of `cabal outdated`:' >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
cabal outdated >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
DELIMITER=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "CABAL_OUTDATED<<$DELIMITER" >> $GITHUB_ENV | |
cabal outdated | tail -n +2 | sort | uniq >> $GITHUB_ENV | |
echo "$DELIMITER" >> $GITHUB_ENV | |
echo "CABAL_COUNT<<$DELIMITER" >> $GITHUB_ENV | |
cabal outdated | tail -n +2 | sort | uniq | wc -l >> $GITHUB_ENV | |
echo "$DELIMITER" >> $GITHUB_ENV | |
echo "CABAL_FLAGS<<$DELIMITER" >> $GITHUB_ENV | |
cabal outdated | tail -n +2 | sort | uniq | | |
perl -ne 'print "--allow-newer=*:$1 --constraint=$1==$2 " if /([a-zA-Z0-9-]*).*\(latest: (.*)\)/' >> $GITHUB_ENV | |
echo "" >> $GITHUB_ENV | |
echo "$DELIMITER" >> $GITHUB_ENV | |
- name: Gather PR description | |
if: env.CABAL_COUNT > 0 | |
shell: bash | |
run: | | |
DELIMITER=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "GIT_PR_TITLE<<$DELIMITER" >> $GITHUB_ENV | |
if [ "$CABAL_COUNT" = 1 ] | |
then | |
echo "Bumping $CABAL_COUNT dependency" >> $GITHUB_ENV | |
else | |
echo "Bumping $CABAL_COUNT dependencies" >> $GITHUB_ENV | |
fi | |
echo "$DELIMITER" >> $GITHUB_ENV | |
echo "GIT_PR_BODY<<$DELIMITER" >> $GITHUB_ENV | |
echo '```' >> $GITHUB_ENV | |
echo "$CABAL_OUTDATED" >> $GITHUB_ENV | |
echo '```' >> $GITHUB_ENV | |
echo >> $GITHUB_ENV | |
echo "(Close and reopen this PR to trigger CI checks.)" >> $GITHUB_ENV | |
echo "$DELIMITER" >> $GITHUB_ENV | |
echo "GIT_COMMIT_MESSAGE<<$DELIMITER" >> $GITHUB_ENV | |
if [ "$CABAL_COUNT" = 1 ] | |
then | |
echo "Bumping $CABAL_COUNT dependency" >> $GITHUB_ENV | |
else | |
echo "Bumping $CABAL_COUNT dependencies" >> $GITHUB_ENV | |
fi | |
echo "" >> $GITHUB_ENV | |
cabal outdated >> $GITHUB_ENV | |
echo "$DELIMITER" >> $GITHUB_ENV | |
- name: Build dependencies | |
id: dependency-build | |
if: env.CABAL_COUNT > 0 | |
shell: bash | |
continue-on-error: true | |
run: | | |
cabal build --only-dependencies --enable-tests --write-ghc-environment-files=always ${{ env.CABAL_FLAGS }} | |
- name: Save cache | |
uses: actions/cache/save@v3 | |
if: always() | |
with: | |
key: ${{ steps.cache.outputs.cache-primary-key }} | |
path: ~/.cabal/store | |
- name: Build local package | |
if: env.CABAL_COUNT > 0 && steps.dependency-build.outcome == 'success' | |
shell: bash | |
run: | | |
cabal build --enable-tests --write-ghc-environment-files=always ${{ env.CABAL_FLAGS }} | |
cabal test ${{ env.CABAL_FLAGS }} | |
- name: Fetch cabal-plan-bounds | |
if: env.CABAL_COUNT > 0 && steps.dependency-build.outcome == 'success' | |
shell: bash | |
run: | | |
curl -L https://github.com/nomeata/cabal-plan-bounds/releases/latest/download/cabal-plan-bounds.linux.gz | gunzip > /usr/local/bin/cabal-plan-bounds | |
chmod +x /usr/local/bin/cabal-plan-bounds | |
- name: Update .cabal file | |
if: env.CABAL_COUNT > 0 && steps.dependency-build.outcome == 'success' | |
shell: bash | |
run: | | |
# This line was added just for servant-swagger-ui, and counter-acts the default | |
cd .. | |
cabal-plan-bounds --extend dist-newstyle/cache/plan.json -c *.cabal | |
git diff *.cabal | |
- name: Create Pull Request | |
id: cpr | |
if: env.CABAL_COUNT > 0 && steps.dependency-build.outcome == 'success' | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
branch: "cabal-updates" | |
title: ${{ env.GIT_PR_TITLE }} | |
body: ${{ env.GIT_PR_BODY }} | |
commit-message: ${{ env.GIT_COMMIT_MESSAGE }} | |
delete-branch: true | |
add-paths: | | |
servant-swagger-ui-core/*.cabal | |
- name: Link to Pull Requst from summary | |
if: env.CABAL_COUNT > 0 && steps.cpr.outputs.pull-request-number | |
shell: bash | |
run: | | |
# This line was added just for servant-swagger-ui, and counter-acts the default | |
cd .. | |
echo "See [pull request ${{ steps.cpr.outputs.pull-request-number }}](${{ steps.cpr.outputs.pull-request-url }})" >> $GITHUB_STEP_SUMMARY |