Skip to content

Commit bd72673

Browse files
committed
Making the reuse action easier to use
Instead of an undifferentiated pile of arguments, a more ordered set of options is available. The general arguments remain as an override.
1 parent 3b8355b commit bd72673

File tree

2 files changed

+96
-1
lines changed

2 files changed

+96
-1
lines changed

reuse/action.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,34 @@ inputs:
2323
description: "The branch to check out the reuse-tool from"
2424
required: false
2525
default: "main"
26+
copyright-holder:
27+
description: "The name of the copyright holder"
28+
required: false
29+
default: "University of Manchester"
30+
license:
31+
description: "The name of the license to apply"
32+
required: false
33+
default: "apache-2.0"
34+
merge:
35+
description: "Whether to merge copyrights"
36+
required: false
37+
default: "true"
38+
fallback-dot-license:
39+
description: "Whether to create a .license file as a fallback"
40+
required: false
41+
default: "true"
42+
extra-formats-file:
43+
description: "The name of the extra formats file"
44+
required: false
45+
default: ".extraformats"
46+
ignore-file:
47+
description: "The name of the ignore file"
48+
required: false
49+
default: ".licenseignore"
50+
base-dir:
51+
description: "The base directory to analyse and annotate"
52+
required: false
53+
default: "."
2654
runs:
2755
using: composite
2856
steps:
@@ -79,8 +107,23 @@ runs:
79107
key: ${{ steps.cache-venv.outputs.cache-primary-key }}
80108
if: steps.cache-venv.outputs.cache-hit != 'true'
81109

110+
- name: Set Up Arguments
111+
id: args
112+
shell: bash
113+
env:
114+
Arguments: ${{ inputs.args }}
115+
Who: ${{ inputs.copyright-holder }}
116+
License: ${{ inputs.license }}
117+
Merge: ${{ inputs.merge }}
118+
Fallback: ${{ inputs.fallback-dot-license }}
119+
Extra: ${{ inputs.extra-formats-file }}
120+
Ignore: ${{ inputs.ignore-file }}
121+
Dir: ${{ inputs.base-dir }}
122+
run: |
123+
$GITHUB_ACTION_PATH/compose-args.bash
124+
82125
- name: Run reuse
83126
shell: bash
84127
run: |
85128
source reuse-tool-venv/bin/activate
86-
reuse ${{ inputs.args }}
129+
reuse ${{ steps.args.outputs.args }}

reuse/compose-args.bash

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/bash
2+
3+
# Copyright (c) 2025 The University of Manchester
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
# If a full set of args supplied, skip generating them
20+
if [ -z "$Arguments" ]; then
21+
# Basic arguments
22+
Arguments="annotate --copyright \"$Who\" -license '$License' --recursive"
23+
24+
# Add if flag set
25+
if [ "$Merge" == 'true' ]; then
26+
Arguments="$Arguments --merge-copyrights"
27+
fi
28+
29+
# Add if flag set
30+
if [ "$Fallback" == 'true' ]; then
31+
Arguments="$Arguments --fallback-dot-license"
32+
fi
33+
34+
# Add if file exists
35+
if [ -f "$Extra" ]; then
36+
Arguments="$Arguments --extra-formats '$Extra'"
37+
fi
38+
39+
# Add if file exists
40+
if [ -f "$Ignore" ]; then
41+
Arguments="$Arguments --ignore-file '$Ignore'"
42+
fi
43+
44+
# Add if directory exists, else use fallback
45+
if [ -d "$Dir" ]; then
46+
Arguments="$Arguments '$Dir'"
47+
else
48+
Arguments="$Arguments ."
49+
fi
50+
fi
51+
52+
echo "args=$Arguments" #>>$GITHUB_OUTPUT

0 commit comments

Comments
 (0)