Skip to content

Commit 5a6876c

Browse files
committed
update .github/actions
1 parent 8c4547d commit 5a6876c

File tree

5 files changed

+143
-59
lines changed

5 files changed

+143
-59
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Check Go license boilerplate
2+
description: Check license boilerplate used in Go files
3+
inputs:
4+
boilerplate-path:
5+
description: License boilerplate file path
6+
required: true
7+
boilerplate-content:
8+
description: License boilerplate content
9+
default: |-
10+
/*
11+
SPDX-FileCopyrightText: ${YEAR} SAP SE or an SAP affiliate company and ${REPOSITORY} contributors
12+
SPDX-License-Identifier: Apache-2.0
13+
*/
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Check boilerplate file
18+
shell: bash
19+
env:
20+
INPUT_BOILERPLATE_PATH: ${{ inputs.boilerplate-path }}
21+
INPUT_BOILERPLATE_CONTENT: ${{ inputs.boilerplate-content }}
22+
run: |
23+
this_year=$(date +%Y)
24+
last_year=$((this_year-1))
25+
repository=$(echo $GITHUB_REPOSITORY | cut -d/ -f2)
26+
27+
tempdir=$(mktemp -d)
28+
trap 'rm -rf $tempdir' EXIT
29+
30+
printenv INPUT_BOILERPLATE_CONTENT | YEAR=$this_year REPOSITORY=$repository envsubst > $tempdir/boilerplate-this-year
31+
printenv INPUT_BOILERPLATE_CONTENT | YEAR=$last_year REPOSITORY=$repository envsubst > $tempdir/boilerplate-last-year
32+
33+
if diff -q $INPUT_BOILERPLATE_PATH $tempdir/boilerplate-this-year >/dev/null; then
34+
exit 0
35+
fi
36+
if diff -q $INPUT_BOILERPLATE_PATH $tempdir/boilerplate-last-year >/dev/null; then
37+
>&1 echo "Warning: license boilerplate outdated ($last_year); next year, this will result in an error."
38+
exit 0
39+
fi
40+
41+
>&1 echo "Error: incorrect license boilerplate."
42+
exit 1
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Check Go license headers
2+
description: Check license headers of Go files
3+
inputs:
4+
base-path:
5+
description: Base directory
6+
default: .
7+
boilerplate-path:
8+
description: License header file path
9+
required: true
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Check files
14+
shell: ruby {0}
15+
env:
16+
INPUT_BASE_PATH: ${{ inputs.base-path }}
17+
INPUT_BOILERPLATE_PATH: ${{ inputs.boilerplate-path }}
18+
run: |
19+
base_path = ENV["INPUT_BASE_PATH"]
20+
raise "Input parameter base-path must not start with slash" if base_path.start_with?("/")
21+
raise "Input parameter base-path must not be empty" if base_path.empty?
22+
raise "Specified base-path does not exist: #{base_path}" if !Dir.exists?(base_path)
23+
24+
boilerplate_path = ENV["INPUT_BOILERPLATE_PATH"]
25+
raise "Input parameter boilerplate-path must not start with slash" if boilerplate_path.start_with?("/")
26+
raise "Input parameter boilerplate-path must not be empty" if boilerplate_path.empty?
27+
28+
boilerplate = File.readlines(boilerplate_path)
29+
errors = 0
30+
31+
Dir.glob("**/*.go").each do |p|
32+
file = File.readlines(p)
33+
file.each_with_index do |line,i|
34+
next if line =~ /^\/\/go:build/
35+
next if line =~ /^\/\/\s*\+build/
36+
next if line =~ /^\s*$/
37+
if file[i,boilerplate.size] != boilerplate then
38+
STDERR.puts "#{p}: bad or missing license header"
39+
errors += 1
40+
end
41+
break
42+
end
43+
end
44+
45+
exit 1 if errors > 0

.github/actions/get-highest-tag/action.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ description: Get highest semver tag in current repository
33
inputs:
44
prefix:
55
description: Tag prefix (only tags with that prefix are considered)
6+
default: ''
67
outputs:
78
tag:
89
description: Highest tag (according to semver ordering)

.github/actions/setup-helm-docs/action.yaml

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,53 @@ description: Setup helm-docs
33
inputs:
44
version:
55
description: Version
6-
required: true
76
default: latest
87
install-directory:
98
description: Target installation directory
10-
required: false
119
default: '$HOME/.helm-docs/bin'
1210
outputs:
1311
path:
1412
description: Path to the installed helm-docs executable
1513
value: ${{ steps.install.outputs.path }}
1614
runs:
17-
using: "composite"
15+
using: composite
1816
steps:
19-
- name: Install helm-docs
20-
id: install
21-
shell: bash
22-
run: |
23-
version=${{ inputs.version}}
24-
install_directory=${{ inputs.install-directory }}
25-
if [ "$version" == latest ]; then
26-
version=$(curl -sSf https://api.github.com/repos/norwoodj/helm-docs/releases/latest | jq -r .tag_name)
27-
fi
28-
version=${version/#v/}
29-
case $(uname -s) in
30-
Linux)
31-
os=Linux
32-
;;
33-
*)
34-
>&1 echo "Unsupported OS: $(uname -s)"
35-
exit 1
36-
;;
37-
esac
38-
case $(uname -m) in
39-
arm64|aarch64)
40-
arch=arm64
41-
;;
42-
x86_64|amd64)
43-
arch=x86_64
44-
;;
45-
*)
46-
>&1 echo "§Unsupported architecture: $(uname -m)"
47-
exit 1
48-
;;
49-
esac
50-
mkdir -p "$install_directory"
51-
temp_directory=$(mktemp -d)
52-
trap 'rm -rf $temp_directory' EXIT
53-
curl -sSfL https://github.com/norwoodj/helm-docs/releases/download/v${version}/helm-docs_${version}_${os}_${arch}.tar.gz | tar xz -C $temp_directory
54-
cp -f $temp_directory/helm-docs $install_directory
55-
chmod a+x "$install_directory/helm-docs"
56-
echo "$install_directory" >> $GITHUB_PATH
57-
echo "path=$install_directory/helm-docs" >> $GITHUB_OUTPUT
17+
- name: Install helm-docs
18+
id: install
19+
shell: bash
20+
run: |
21+
version=${{ inputs.version}}
22+
install_directory=${{ inputs.install-directory }}
23+
if [ "$version" == latest ]; then
24+
version=$(curl -sSf https://api.github.com/repos/norwoodj/helm-docs/releases/latest | jq -r .tag_name)
25+
fi
26+
version=${version/#v/}
27+
case $(uname -s) in
28+
Linux)
29+
os=Linux
30+
;;
31+
*)
32+
>&1 echo "Unsupported OS: $(uname -s)"
33+
exit 1
34+
;;
35+
esac
36+
case $(uname -m) in
37+
arm64|aarch64)
38+
arch=arm64
39+
;;
40+
x86_64|amd64)
41+
arch=x86_64
42+
;;
43+
*)
44+
>&1 echo "§Unsupported architecture: $(uname -m)"
45+
exit 1
46+
;;
47+
esac
48+
mkdir -p "$install_directory"
49+
temp_directory=$(mktemp -d)
50+
trap 'rm -rf $temp_directory' EXIT
51+
curl -sSfL https://github.com/norwoodj/helm-docs/releases/download/v${version}/helm-docs_${version}_${os}_${arch}.tar.gz | tar xz -C $temp_directory
52+
cp -f $temp_directory/helm-docs $install_directory
53+
chmod a+x "$install_directory/helm-docs"
54+
echo "$install_directory" >> $GITHUB_PATH
55+
echo "path=$install_directory/helm-docs" >> $GITHUB_OUTPUT

.github/actions/setup-semver/action.yaml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,28 @@ description: Setup semver
33
inputs:
44
version:
55
description: Version
6-
required: true
76
default: latest
87
install-directory:
98
description: Target installation directory
10-
required: false
119
default: '$HOME/.semver/bin'
1210
outputs:
1311
path:
1412
description: Path to the installed semver executable
1513
value: ${{ steps.install.outputs.path }}
1614
runs:
17-
using: "composite"
15+
using: composite
1816
steps:
19-
- name: Install semver
20-
id: install
21-
shell: bash
22-
run: |
23-
version=${{ inputs.version}}
24-
install_directory=${{ inputs.install-directory }}
25-
if [ "$version" == latest ]; then
26-
version=master
27-
fi
28-
mkdir -p "$install_directory"
29-
curl -sSf -L -o "$install_directory/semver" https://raw.githubusercontent.com/fsaintjacques/semver-tool/$version/src/semver
30-
chmod a+x "$install_directory/semver"
31-
echo "$install_directory" >> $GITHUB_PATH
32-
echo "path=$install_directory/semver" >> $GITHUB_OUTPUT
17+
- name: Install semver
18+
id: install
19+
shell: bash
20+
run: |
21+
version=${{ inputs.version}}
22+
install_directory=${{ inputs.install-directory }}
23+
if [ "$version" == latest ]; then
24+
version=master
25+
fi
26+
mkdir -p "$install_directory"
27+
curl -sSf -L -o "$install_directory/semver" https://raw.githubusercontent.com/fsaintjacques/semver-tool/$version/src/semver
28+
chmod a+x "$install_directory/semver"
29+
echo "$install_directory" >> $GITHUB_PATH
30+
echo "path=$install_directory/semver" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)