action-gh-release
action-gh-release copied to clipboard
Rename File Before Publishing
I have this release for my project.
I have different builds for MacOS, Linux and Windows. Windows is not a problem because Rust compiler automatically appends .exe
to the filename, however the filenames are the same for MacOS and Linux. Should be a way to rename them.
Github releases doesn’t support more than one release asset with the same name. Typically want you want to do is to create an archive containing your binary with a name that reflects the target os as part of your artifact producing build step
if you point me to you’re workflow I’ll be happy to point you in the right direction.
I believe OP's issue is that their build script always outputs an executable with the same name, no matter what system it was built for. This becomes problematic when they try to upload multiple versions of the software for different systems, because as @softprops mentioned: "Github releases doesn’t support more than one release asset with the same name". To fix this issue and make your releases look a bit nicer, you can append things like '-Windows' or '-Linux' to the name of your executable file. This can be achieved by using workflow commands. Simply run a command appropriate to your runner machine's virtual environment. If you are using Ubuntu as your runner's virtual environment you can do something like this:
- name: Rename output file
run: mv "/build/program.exe" "/build/program-win.exe"
mv "/build/program.exe" "/build/program-win.exe"
While this does rename the file, it does not solve the underlying lack of ability of being able to specify a filename upon upload.
When using the (now unmaintained) actions/upload-release-asset
action, you can indeed specify a filename:
- name: Upload artifact
uses: actions/[email protected]
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifact.exe
asset_name: artifact-${{ env.VERSION }}-Windows.exe
asset_content_type: application/vnd.microsoft.portable-executable