Skip to content

Commit b2ead1c

Browse files
committed
Inline deps bumper and customize
1 parent 08d324b commit b2ead1c

File tree

1 file changed

+122
-1
lines changed

1 file changed

+122
-1
lines changed

.github/workflows/bump.yml

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Based on nomeata's dep bumper, should go back to using that when it supports executing build-tzdata.sh after checkout
12
name: Create dependency bump PR
23
on:
34
# allows manual triggering from https://github.com/../../actions/workflows/bump.yml
@@ -13,5 +14,125 @@ permissions:
1314
jobs:
1415
bump:
1516
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: ./servant-swagger-ui-core
1620
steps:
17-
- uses: nomeata/haskell-bounds-bump-action@main
21+
- uses: actions/checkout@v3
22+
23+
- name: cache cabal store
24+
uses: actions/cache@v3
25+
with:
26+
key: bump-action-cabal-store-${{ runner.os }}-${{ github.sha }}
27+
path: ~/.cabal/store
28+
restore-keys: bump-action-cabal-store-${{ runner.os }}-
29+
30+
- uses: haskell/actions/setup@v2
31+
with:
32+
ghc-version: latest
33+
34+
- name: Run cabal outdated
35+
shell: bash
36+
run: |
37+
cabal outdated
38+
39+
# also remember the values and the number of changes
40+
echo 'Output of `cabal outdated`:' >> $GITHUB_STEP_SUMMARY
41+
echo '```' >> $GITHUB_STEP_SUMMARY
42+
cabal outdated >> $GITHUB_STEP_SUMMARY
43+
echo '```' >> $GITHUB_STEP_SUMMARY
44+
45+
DELIMITER=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
46+
echo "CABAL_OUTDATED<<$DELIMITER" >> $GITHUB_ENV
47+
cabal outdated | tail -n +2 | sort | uniq >> $GITHUB_ENV
48+
echo "$DELIMITER" >> $GITHUB_ENV
49+
50+
echo "CABAL_COUNT<<$DELIMITER" >> $GITHUB_ENV
51+
cabal outdated | tail -n +2 | sort | uniq | wc -l >> $GITHUB_ENV
52+
echo "$DELIMITER" >> $GITHUB_ENV
53+
54+
echo "CABAL_FLAGS<<$DELIMITER" >> $GITHUB_ENV
55+
cabal outdated | tail -n +2 | sort | uniq |
56+
perl -ne 'print "--allow-newer=*:$1 --constraint=$1==$2 " if /([a-zA-Z0-9-]*).*\(latest: (.*)\)/' >> $GITHUB_ENV
57+
echo "" >> $GITHUB_ENV
58+
echo "$DELIMITER" >> $GITHUB_ENV
59+
60+
- name: Gather PR description
61+
if: env.CABAL_COUNT > 0
62+
shell: bash
63+
run: |
64+
DELIMITER=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
65+
echo "GIT_PR_TITLE<<$DELIMITER" >> $GITHUB_ENV
66+
if [ "$CABAL_COUNT" = 1 ]
67+
then
68+
echo "Bumping $CABAL_COUNT dependency" >> $GITHUB_ENV
69+
else
70+
echo "Bumping $CABAL_COUNT dependencies" >> $GITHUB_ENV
71+
fi
72+
echo "$DELIMITER" >> $GITHUB_ENV
73+
74+
echo "GIT_PR_BODY<<$DELIMITER" >> $GITHUB_ENV
75+
echo '```' >> $GITHUB_ENV
76+
echo "$CABAL_OUTDATED" >> $GITHUB_ENV
77+
echo '```' >> $GITHUB_ENV
78+
echo >> $GITHUB_ENV
79+
echo "(Close and reopen this PR to trigger CI checks.)" >> $GITHUB_ENV
80+
echo "$DELIMITER" >> $GITHUB_ENV
81+
82+
echo "GIT_COMMIT_MESSAGE<<$DELIMITER" >> $GITHUB_ENV
83+
if [ "$CABAL_COUNT" = 1 ]
84+
then
85+
echo "Bumping $CABAL_COUNT dependency" >> $GITHUB_ENV
86+
else
87+
echo "Bumping $CABAL_COUNT dependencies" >> $GITHUB_ENV
88+
fi
89+
echo "" >> $GITHUB_ENV
90+
cabal outdated >> $GITHUB_ENV
91+
echo "$DELIMITER" >> $GITHUB_ENV
92+
93+
94+
- name: Build
95+
if: env.CABAL_COUNT > 0
96+
shell: bash
97+
run: |
98+
cabal build --enable-tests --write-ghc-environment-files=always ${{ env.CABAL_FLAGS }}
99+
cabal test ${{ env.CABAL_FLAGS }}
100+
101+
- name: Fetch cabal-plan-bounds
102+
if: env.CABAL_COUNT > 0
103+
shell: bash
104+
run: |
105+
curl -L https://github.com/nomeata/cabal-plan-bounds/releases/latest/download/cabal-plan-bounds.linux.gz | gunzip > /usr/local/bin/cabal-plan-bounds
106+
chmod +x /usr/local/bin/cabal-plan-bounds
107+
108+
- name: Update .cabal file
109+
if: env.CABAL_COUNT > 0
110+
shell: bash
111+
run: |
112+
# This line was added just for servant-swagger-ui, and counter-acts the default
113+
cd ..
114+
115+
cabal-plan-bounds --extend dist-newstyle/cache/plan.json -c *.cabal
116+
git diff *.cabal
117+
118+
- name: Create Pull Request
119+
id: cpr
120+
if: env.CABAL_COUNT > 0
121+
uses: peter-evans/create-pull-request@v5
122+
with:
123+
branch: "cabal-updates"
124+
title: ${{ env.GIT_PR_TITLE }}
125+
body: ${{ env.GIT_PR_BODY }}
126+
commit-message: ${{ env.GIT_COMMIT_MESSAGE }}
127+
delete-branch: true
128+
add-paths: |
129+
servant-swagger-ui-core/*.cabal
130+
131+
- name: Link to Pull Requst from summary
132+
if: env.CABAL_COUNT > 0 && steps.cpr.outputs.pull-request-number
133+
shell: bash
134+
run: |
135+
# This line was added just for servant-swagger-ui, and counter-acts the default
136+
cd ..
137+
138+
echo "See [pull request ${{ steps.cpr.outputs.pull-request-number }}](${{ steps.cpr.outputs.pull-request-url }})" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)