generated from circuitdojo/zephyr-template
-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (116 loc) · 4.62 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
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
name: Release
on:
workflow_dispatch:
inputs:
version_tag:
description: 'Version tag'
required: true
type: string
workflow_call:
inputs:
version_tag:
description: 'Version tag'
required: true
type: string
jobs:
build:
uses: ./.github/workflows/build.yml
with:
upload_artifacts: true
secrets: inherit
release:
needs: build
runs-on: ubuntu-latest
env:
version_tag: ${{ inputs.version_tag }}
steps:
- name: Check for curl
run: type -p curl >/dev/null || (sudo apt-get update && sudo apt-get install curl -y)
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
BRANCH: main
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ env.OWNER }}/${{ env.REPO }}/releases" \
-d '{"tag_name":"${{ env.version_tag }}","target_commitish":"${{ env.BRANCH }}","body":"___This release was automatically generated when the app version increased___","draft":false,"prerelease":false,"generate_release_notes":true}' \
-o release.json
echo "upload_url=$(grep -Po '(?:\G(?!^)",|"upload_url":\s*)\s*"\K[^"{]+' release.json)" >> "$GITHUB_ENV"
html_url=$(grep -Po -m 1 '(?:\G(?!^)",|"html_url":\s*)\s*"\K[^"]+' release.json)
echo "Created release [${{ env.version_tag }}]($html_url)" >> $GITHUB_STEP_SUMMARY
- name: Download merged.hex
uses: actions/download-artifact@v4
with:
name: merged.hex
- name: Download app_update.bin
uses: actions/download-artifact@v4
with:
name: app_update.bin
- name: Upload merged.hex
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ env.upload_url }}?name=merged.hex" \
--data-binary "@merged.hex"
echo 'Uploaded build artifact merged.hex as asset to release' >> $GITHUB_STEP_SUMMARY
- name: Upload merged_sha256.sum
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
sha256sum merged.hex > merged_sha256.sum
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ env.upload_url }}?name=merged_sha256.sum" \
--data-binary "@merged_sha256.sum"
echo 'Uploaded build artifact merged_sha256.sum as asset to release' >> $GITHUB_STEP_SUMMARY
- name: Upload app_update.bin
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ env.upload_url }}?name=app_update.bin" \
--data-binary "@app_update.bin"
echo 'Uploaded build artifact app_update.bin as asset to release' >> $GITHUB_STEP_SUMMARY
- name: Upload app_update_sha256.sum
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
sha256sum app_update.bin > app_update_sha256.sum
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ env.upload_url }}?name=app_update_sha256.sum" \
--data-binary "@app_update_sha256.sum"
echo 'Uploaded build artifact app_update_sha256.sum as asset to release' >> $GITHUB_STEP_SUMMARY