From a9593c170528c52168e751a3c9a49e84ec4de6e7 Mon Sep 17 00:00:00 2001 From: Dave Rolsky Date: Sun, 8 Dec 2024 11:32:09 -0600 Subject: [PATCH] Allow setting `changes-file` to an empty string If it's set to an empty string, the action will not look for a changelog. --- .github/workflows/test-no-changes-file.yml | 46 ++++++++++++++++++++++ README.md | 2 + make-archive.pl | 2 +- tests/check-release.pl | 9 ++++- 4 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test-no-changes-file.yml diff --git a/.github/workflows/test-no-changes-file.yml b/.github/workflows/test-no-changes-file.yml new file mode 100644 index 0000000..6051d94 --- /dev/null +++ b/.github/workflows/test-no-changes-file.yml @@ -0,0 +1,46 @@ +name: Test working-directory Parameter + +on: + push: + pull_request: + +jobs: + test: + name: Test no changes file + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Copy test project to root + shell: bash + run: | + cp -a test-project/* . + rm -fr test-project + - name: Build binary + uses: houseabsolute/actions-rust-cross@v0 + with: + command: build + args: "--release" + target: x86_64-unknown-linux-musl + GITHUB_TOKEN: ${{ github.token }} + - name: Release + id: release + uses: ./ + with: + executable-name: test-project + target: x86_64-unknown-linux-musl + changes-file: "" + # We don't want to actually do a release when running tests. + release-tag-prefix: "do-not-release" + - name: Install psutils on Windows + run: choco install --ignore-checksums psutils + if: runner.os == 'Windows' + - name: Check release artifacts + shell: bash + run: | + ./tests/check-release.pl \ + --artifact-id "${{ steps.release.outputs.artifact-id }}" \ + --executable-name test-project \ + --github-token "${{ github.token }}" \ + --repo houseabsolute/actions-rust-release \ + --target "x86_64-unknown-linux-musl" diff --git a/README.md b/README.md index 49a1d26..5c09c4e 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,8 @@ this case. The name of the file that contains the changelog for this project. This will be used to generate a description for the GitHub Release. +If you set this to an empty string, then no changelog file will be included. + ### `working-directory` - **Required**: no diff --git a/make-archive.pl b/make-archive.pl index 2d9de19..3f796cc 100755 --- a/make-archive.pl +++ b/make-archive.pl @@ -83,7 +83,7 @@ sub main { } my $td = tempdir( CLEANUP => 1 ); - for my $file (@files) { + for my $file ( grep {length} @files ) { copy( $file => $td ) or die "Cannot copy $file => $td: $!"; } diff --git a/tests/check-release.pl b/tests/check-release.pl index 73a702d..ae7692a 100755 --- a/tests/check-release.pl +++ b/tests/check-release.pl @@ -24,6 +24,7 @@ sub main { my $github_token; my $repo; my $target; + my $changes_file = 1; GetOptions( 'artifact-id=s' => \$artifact_id, @@ -31,6 +32,7 @@ sub main { 'github-token=s' => \$github_token, 'repo=s' => \$repo, 'target=s' => \$target, + 'changes-file!' => \$changes_file, ); # We want to run this in a clean dir to avoid any conflicts with files in the current dir, like @@ -82,7 +84,12 @@ sub main { system( 'tar', 'xzf', $archive_file ); } - for my $file ( $executable_name, qw( README.md Changes.md ) ) { + my @expect_files = 'README.md'; + if ($changes_file) { + push @expect_files, 'Changes.md'; + } + + for my $file ( $executable_name, @expect_files ) { ok( -f $file, "$file exists after unpacking archive" ); }