diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3c5e36d..f0d5cc4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,8 +36,13 @@ jobs: This is sample package. This is sample package. + id: build - run: | docker run --rm -v $PWD:/work -t centos:7 bash -c 'rpm -Uvh /work/*.rpm && testbin' + - name: Test file_name + run: test ${{ steps.build.outputs.file_name }} = 'testbin-1.0.0-1.el7.x86_64.rpm' + - name: Test debuginfo_file_name + run: test ${{ steps.build.outputs.debuginfo_file_name }} = 'testbin-debuginfo-1.0.0-1.el7.x86_64.rpm' test-script-version: runs-on: ubuntu-latest diff --git a/README.md b/README.md index b50fe59..3399455 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,16 @@ inputs: ``` +## Output + +```yaml +outputs: + file_name: + description: 'File name of resulting .rpm file. This does not contain a debuginfo file.' + debuginfo_file_name: + description: 'File name of resulting .rpm debuginfo file.' +``` + ## Usage ```yaml diff --git a/action.yml b/action.yml index 6f0c554..3ef7d71 100644 --- a/action.yml +++ b/action.yml @@ -32,9 +32,14 @@ inputs: post: description: 'Package post.' default: '' +outputs: + file_name: + description: 'File name of resulting .rpm file. This does not contain a debuginfo file.' + debuginfo_file_name: + description: 'File name of resulting .rpm debuginfo file.' runs: using: 'docker' - image: 'docker://jiro4989/build-rpm-action:2.3.0' + image: 'docker://jiro4989/build-rpm-action:2.4.0' # Ref: https://haya14busa.github.io/github-action-brandings/ # TODO: update branding if you want. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..a1477c4 --- /dev/null +++ b/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -eu + +version=$1 +tag="jiro4989/build-rpm-action:$version" +docker build --no-cache -t "$tag" . +docker push "$tag" diff --git a/entrypoint.sh b/entrypoint.sh index 7a0b4fc..bae2c81 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -44,3 +44,21 @@ readonly RPMBUILD_SPEC_DIR="$RPMBUILD_DIR/SPECS" cp -p "$RPMBUILD_DIR/RPMS/$(uname -m)"/*.rpm . ls -lah ./*.rpm + +# for grep +set +e + +for f in *.rpm; do + # exclude debuginfo file + line_count="$(echo "$f" | grep -Eoc "^${INPUT_PACKAGE}-debuginfo-")" + if [ "$line_count" -ne 0 ]; then + RPM_DEBUGINFO_FILE="$f" + continue + fi + RPM_FILE="$f" +done + +set -e + +echo "file_name=$RPM_FILE" >> "${GITHUB_OUTPUT}" +echo "debuginfo_file_name=$RPM_DEBUGINFO_FILE" >> "${GITHUB_OUTPUT}"