Răsfoiți Sursa

CI: added a workflow to create a release when matching tag is pushed

Benoit Blanchon 4 ani în urmă
părinte
comite
f02a699c26
2 a modificat fișierele cu 65 adăugiri și 0 ștergeri
  1. 51 0
      .github/workflows/release.yml
  2. 14 0
      extras/scripts/get-release-body.sh

+ 51 - 0
.github/workflows/release.yml

@@ -0,0 +1,51 @@
+name: Release
+
+on:
+  push:
+    tags:
+      - v*.*.*
+
+jobs:
+  release:
+    name: Create release
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Set variables
+        id: init
+        run: |
+          echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
+          echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
+      - name: Checkout
+        uses: actions/checkout@v2
+      - name: Write release body
+        id: body
+        run: |
+          FILENAME=RELEASE.md
+          extras/scripts/get-release-body.sh ${{ steps.init.outputs.tag }} CHANGELOG.md | tee $FILENAME
+          echo ::set-output name=filename::$FILENAME
+      - name: Amalgamate ArduinoJson.h
+        id: amalgamate_h
+        run: |
+          FILENAME=ArduinoJson-${{ steps.init.outputs.tag }}.h
+          extras/scripts/build-single-header.sh src/ArduinoJson.h "$FILENAME"
+          echo ::set-output name=filename::$FILENAME
+      - name: Amalgamate ArduinoJson.hpp
+        id: amalgamate_hpp
+        run: |
+          FILENAME=ArduinoJson-${{ steps.init.outputs.tag }}.hpp
+          extras/scripts/build-single-header.sh src/ArduinoJson.hpp "$FILENAME"
+          echo ::set-output name=filename::$FILENAME
+      - name: Create Arduino package
+        id: arduino
+        run: |
+          FILENAME=ArduinoJson-${{ steps.init.outputs.tag }}.zip
+          extras/scripts/build-arduino-package.sh . "$FILENAME"
+          echo ::set-output name=filename::$FILENAME
+      - name: Create release
+        uses: ncipollo/release-action@v1
+        with:
+          bodyFile: ${{ steps.body.outputs.filename }}
+          draft: true
+          name: ArduinoJson ${{ steps.init.outputs.version }}
+          artifacts: ${{ steps.amalgamate_h.outputs.filename }},${{ steps.amalgamate_hpp.outputs.filename }},${{ steps.arduino.outputs.filename }}
+          token: ${{ secrets.GITHUB_TOKEN }}

+ 14 - 0
extras/scripts/get-release-body.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -eu
+
+TAG="$1"
+CHANGELOG="$2"
+
+cat << END
+## Changes
+
+$(awk '/\* /{ FOUND=1; print; next } { if (FOUND) exit}' "$CHANGELOG")
+
+[View version history](https://github.com/bblanchon/ArduinoJson/blob/$TAG/CHANGELOG.md)
+END