Skip to content

Commit

Permalink
Allow setting changes-file to an empty string
Browse files Browse the repository at this point in the history
If it's set to an empty string, the action will not look for a changelog.
  • Loading branch information
autarch committed Dec 8, 2024
1 parent 9037cb8 commit a9593c1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/test-no-changes-file.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion make-archive.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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: $!";
}
Expand Down
9 changes: 8 additions & 1 deletion tests/check-release.pl
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ sub main {
my $github_token;
my $repo;
my $target;
my $changes_file = 1;

GetOptions(
'artifact-id=s' => \$artifact_id,
'executable-name=s' => \$executable_name,
'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
Expand Down Expand Up @@ -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" );
}

Expand Down

0 comments on commit a9593c1

Please sign in to comment.