-
Notifications
You must be signed in to change notification settings - Fork 34
153 lines (132 loc) · 5.46 KB
/
bump.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# 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