Skip to content

Commit 3c03747

Browse files
authored
Merge pull request #11 from arduino/scerza/license-check
Add CI workflow to check the license file
2 parents e508ac9 + 4c2c3e8 commit 3c03747

File tree

2 files changed

+66
-14
lines changed

2 files changed

+66
-14
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-license.md
2+
name: Check License
3+
4+
env:
5+
# TODO: Define the project's license file name here:
6+
EXPECTED_LICENSE_FILENAME: LICENSE.txt
7+
# SPDX identifier: https://spdx.org/licenses/
8+
# TODO: Define the project's license type here
9+
EXPECTED_LICENSE_TYPE: GPL-3.0
10+
11+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
12+
on:
13+
push:
14+
paths:
15+
- ".github/workflows/check-license.ya?ml"
16+
# See: https://github.com/licensee/licensee/blob/master/docs/what-we-look-at.md#detecting-the-license-file
17+
- "[cC][oO][pP][yY][iI][nN][gG]*"
18+
- "[cC][oO][pP][yY][rR][iI][gG][hH][tH]*"
19+
- "[lL][iI][cC][eE][nN][cCsS][eE]*"
20+
- "[oO][fF][lL]*"
21+
- "[pP][aA][tT][eE][nN][tT][sS]*"
22+
pull_request:
23+
paths:
24+
- ".github/workflows/check-license.ya?ml"
25+
- "[cC][oO][pP][yY][iI][nN][gG]*"
26+
- "[cC][oO][pP][yY][rR][iI][gG][hH][tH]*"
27+
- "[lL][iI][cC][eE][nN][cCsS][eE]*"
28+
- "[oO][fF][lL]*"
29+
- "[pP][aA][tT][eE][nN][tT][sS]*"
30+
workflow_dispatch:
31+
repository_dispatch:
32+
33+
jobs:
34+
check-license:
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v2
40+
41+
- name: Install Ruby
42+
uses: ruby/setup-ruby@v1
43+
with:
44+
ruby-version: ruby # Install latest version
45+
46+
- name: Install licensee
47+
run: gem install licensee
48+
49+
- name: Check license file
50+
run: |
51+
EXIT_STATUS=0
52+
# See: https://github.com/licensee/licensee
53+
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
54+
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
55+
echo "Detected license file: $DETECTED_LICENSE_FILE"
56+
if [ "$DETECTED_LICENSE_FILE" != "\"${EXPECTED_LICENSE_FILENAME}\"" ]; then
57+
echo "::error file=${DETECTED_LICENSE_FILE}::detected license file $DETECTED_LICENSE_FILE doesn't match expected: $EXPECTED_LICENSE_FILENAME"
58+
EXIT_STATUS=1
59+
fi
60+
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
61+
echo "Detected license type: $DETECTED_LICENSE_TYPE"
62+
if [ "$DETECTED_LICENSE_TYPE" != "\"${EXPECTED_LICENSE_TYPE}\"" ]; then
63+
echo "::error file=${DETECTED_LICENSE_FILE}::detected license type $DETECTED_LICENSE_TYPE doesn't match expected \"${EXPECTED_LICENSE_TYPE}\""
64+
EXIT_STATUS=1
65+
fi
66+
exit $EXIT_STATUS

LICENSE.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
This file includes licensing information for serial-discovery
2-
3-
Copyright (c) 2018-2021 ARDUINO SA (www.arduino.cc)
4-
5-
The software is released under the GNU General Public License, which covers the main body
6-
of the serial-discovery code. The terms of this license can be found at:
7-
https://www.gnu.org/licenses/gpl-3.0.en.html
8-
9-
You can be released from the requirements of the above licenses by purchasing
10-
a commercial license. Buying such a license is mandatory if you want to modify or
11-
otherwise use the software for commercial activities involving the Arduino
12-
software without disclosing the source code of your own applications. To purchase
13-
a commercial license, send an email to license@arduino.cc
14-
151
GNU GENERAL PUBLIC LICENSE
162
Version 3, 29 June 2007
173

0 commit comments

Comments
 (0)