Skip to content

Commit

Permalink
feat: Add working-directory field so you can release a sub-dir Rust p…
Browse files Browse the repository at this point in the history
…roject
  • Loading branch information
Snoupix committed Nov 18, 2024
1 parent e536e52 commit efa5a9a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ explicitly if you want them to be included.
The name of the file that contains the changelog for this project. This will be used to generate a
description for the GitHub Release.

### `working-directory`

- **Required**: no
- **Default**: `"."`

The current working directory in which the Rust project is. It defaults to "." so the
current working directory.

## Outputs

This action provides two outputs.
Expand Down
17 changes: 13 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ inputs:
The name of the file that contains the changelog for this project. This will be used to
generate a description for the GitHub Release. The default is `Changes.md`.
default: "Changes.md"
working-directory:
description: |
The current working directory in which the Rust project is. It defaults to "." so the
current working directory.
default: "."
outputs:
artifact-id:
description: |
Expand All @@ -67,6 +72,7 @@ runs:
echo "archive-name = ${{ inputs.archive-name }}"
echo "extra-files = ${{ inputs.extra-files }}"
echo "changes-file = ${{ inputs.changes-file }}"
echo "working-directory = ${{ inputs.working-directory }}"
echo "github.ref = ${{ github.ref }}"
echo "github.ref_type = ${{ github.ref_type }}"
echo "matches release-tag-prefix = ${{ startsWith( github.ref_name, inputs.release-tag-prefix ) }}"
Expand All @@ -82,13 +88,15 @@ runs:
--target "${{ inputs.target }}" \
--archive-name "${{ inputs.archive-name }}" \
--changes-file "${{ inputs.changes-file }}" \
--extra-files "${{ inputs.extra-files }}"
--extra-files "${{ inputs.extra-files }}" \
--working-directory "${{ inputs.working-directory }}"
- name: Generate SHA-256 checksum file (*nix)
shell: bash
run: |
set -e
set -x
cd ${{ inputs.working-directory }}
shasum --algorithm 256 \
"${{ steps.package-archive.outputs.archive-basename }}" \
> "${{ steps.package-archive.outputs.archive-basename }}.sha256"
Expand All @@ -101,6 +109,7 @@ runs:
- name: Generate SHA-256 checksum file (Windows)
shell: powershell
run: |
cd ${{ inputs.working-directory }}
shasum --algorithm 256 `
"${{ steps.package-archive.outputs.archive-basename }}" `
> "${{ steps.package-archive.outputs.archive-basename }}.sha256"
Expand All @@ -111,12 +120,12 @@ runs:
uses: actions/upload-artifact@v4
with:
name: ${{ steps.package-archive.outputs.archive-basename }}
path: ${{ steps.package-archive.outputs.archive-basename }}*
path: ${{ inputs.working-directory }}/${{ steps.package-archive.outputs.archive-basename }}*
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
draft: true
# The trailing "*" should pick up the checksum file.
files: ${{ steps.package-archive.outputs.archive-basename }}*
body_path: ${{ inputs.changes-file }}
files: ${{ inputs.working-directory }}/${{ steps.package-archive.outputs.archive-basename }}*
body_path: ${{ inputs.working-directory }}/${{ inputs.changes-file }}
if: github.ref_type == 'tag' && startsWith( github.ref_name, inputs.release-tag-prefix )
15 changes: 10 additions & 5 deletions make-archive.pl
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@

sub main {
GetOptions(
'executable-name=s' => \my $executable_name,
'target=s' => \my $target,
'archive-name=s' => \my $archive_name,
'changes-file=s' => \my $changes_file,
'extra-files=s' => \my $extra_files,
'executable-name=s' => \my $executable_name,
'target=s' => \my $target,
'archive-name=s' => \my $archive_name,
'changes-file=s' => \my $changes_file,
'extra-files=s' => \my $extra_files,
'working-directory=s' => \my $working_dir,
);

if ( $working_dir ) {
chdir $working_dir;
}

if ( !$executable_name ) {
die 'The --executable-name option is required.';
}
Expand Down

0 comments on commit efa5a9a

Please sign in to comment.