-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (68 loc) · 2.69 KB
/
release.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
name: Create new Release
# Run on a push to master, and everyday at 4:20
on:
push:
branches: [ 'master' ]
schedule:
- cron: '20 4 * * *'
jobs:
check:
name: Check new Raspberry Pi OS Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check
env:
ALL_OWN_RELEASES: https://api.github.com/repos/${{ github.repository }}/releases
run: |
VERSION="$(./modify-image.sh version)"
TAGS="$(wget -qO- "$ALL_OWN_RELEASES" | jq -r '.[].tag_name')"
if [ -n "$TAGS" ] && echo "$TAGS" | grep "$VERSION"; then
echo "Nothing to do. Exiting."
exit 0
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
URL="$(./modify-image.sh url)"
echo "SRC_URL=$URL" >> $GITHUB_ENV
echo "SRC_FILE=$(basename "$URL")" >> $GITHUB_ENV
- name: Modify Raspberry Pi OS image
if: env.VERSION != ''
run: |
./modify-image-in-docker.sh
echo "FILE=$(cd images && ls *-firstboot.zip)" >> $GITHUB_ENV
- name: Create Github Release
uses: meeDamian/[email protected]
if: env.VERSION != '' && env.FILE != ''
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.VERSION }}
name: ${{ env.FILE }}
prerelease: true
allow_override: false
gzip: false
files: >
images/${{ env.FILE }}
images/${{ env.FILE }}.sha256
body: >
This release adds [`firstboot.sh`](/firstboot.service#L8) capabilities to
the original Raspberry Pi OS Lite image: [${{ env.SRC_FILE }}](${{ env.SRC_URL }}).
- name: Comment
if: steps.release.outputs.release_id != ''
env:
URL: https://api.github.com/repos/${{ github.repository }}/issues
body: >
New Raspberry Pi OS Lite release detected. It has been modified with `firstboot.service`, and pre-released as https://github.com/${{ github.repository }}/releases/tag/${{ env.VERSION }}.
Please verify, [everything checks out](https://github.com/${{ github.repository }}/runs/${{ github.run_id }}?check_suite_focus=true), and upgrade `Pre-release` to `Release`.
run: |
jq -nc \
--arg title "$VERSION released" \
--arg body "$body" \
--argjson assignees '["meeDamian"]' \
--argjson labels '["release-pending-approval"]' \
'{$title, $body, $assignees, $labels}' \
| curl -d @- \
-X "POST" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"$URL" \
| jq '.'