Skip to content

Commit f02a699

Browse files
committed
CI: added a workflow to create a release when matching tag is pushed
1 parent 67d0931 commit f02a699

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*.*.*
7+
8+
jobs:
9+
release:
10+
name: Create release
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- name: Set variables
14+
id: init
15+
run: |
16+
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
17+
echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
- name: Write release body
21+
id: body
22+
run: |
23+
FILENAME=RELEASE.md
24+
extras/scripts/get-release-body.sh ${{ steps.init.outputs.tag }} CHANGELOG.md | tee $FILENAME
25+
echo ::set-output name=filename::$FILENAME
26+
- name: Amalgamate ArduinoJson.h
27+
id: amalgamate_h
28+
run: |
29+
FILENAME=ArduinoJson-${{ steps.init.outputs.tag }}.h
30+
extras/scripts/build-single-header.sh src/ArduinoJson.h "$FILENAME"
31+
echo ::set-output name=filename::$FILENAME
32+
- name: Amalgamate ArduinoJson.hpp
33+
id: amalgamate_hpp
34+
run: |
35+
FILENAME=ArduinoJson-${{ steps.init.outputs.tag }}.hpp
36+
extras/scripts/build-single-header.sh src/ArduinoJson.hpp "$FILENAME"
37+
echo ::set-output name=filename::$FILENAME
38+
- name: Create Arduino package
39+
id: arduino
40+
run: |
41+
FILENAME=ArduinoJson-${{ steps.init.outputs.tag }}.zip
42+
extras/scripts/build-arduino-package.sh . "$FILENAME"
43+
echo ::set-output name=filename::$FILENAME
44+
- name: Create release
45+
uses: ncipollo/release-action@v1
46+
with:
47+
bodyFile: ${{ steps.body.outputs.filename }}
48+
draft: true
49+
name: ArduinoJson ${{ steps.init.outputs.version }}
50+
artifacts: ${{ steps.amalgamate_h.outputs.filename }},${{ steps.amalgamate_hpp.outputs.filename }},${{ steps.arduino.outputs.filename }}
51+
token: ${{ secrets.GITHUB_TOKEN }}

extras/scripts/get-release-body.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
TAG="$1"
6+
CHANGELOG="$2"
7+
8+
cat << END
9+
## Changes
10+
11+
$(awk '/\* /{ FOUND=1; print; next } { if (FOUND) exit}' "$CHANGELOG")
12+
13+
[View version history](https://github.com/bblanchon/ArduinoJson/blob/$TAG/CHANGELOG.md)
14+
END

0 commit comments

Comments
 (0)