Agree! The workflow should take care of the settings automatically and not require manual intervention.
If the version data is in a file, I think the key will be reading it from a file and using it in your build steps vs using an environment variable.
I see one suggestiont that mentions how a step can update an environment variable that can be used in a future step. However, that won’t work in the case of using the artifact upload action since the variable would need to be in the configuration at the Workflow level.
Instead, you’ll likely need to do two things:
- Update your build script to read the header file into a variable and use that accordingly to create the executable with the correct version name. I am assuming the build script writes the file to a known location that will always be the same.
- Hard code the output location in your artifact upload step. That way, the exe with the version naming will always be picked up from the correct location and you won’t have to worry about configuring the workflow to name the exe. Note that in the artifact upload action, you can specify a path, not necessarily a file name. If you specify a directory, the action picks up all the files in that directory.
Here’s an example I got working:
version.txt; Version file (my stand in for your header file):
build-app.ps1; Build script:
New-Item -ItemType directory -Path ./output
$version = Get-Content ./version.txt -Raw
$version = $version -replace "`n|`r",""
$file = "app-" + $version + ".exe"
echo $version | Out-File ./output/$file
name: Windows with VC++
- uses: actions/checkout@master
- name: build
- name: upload
2020-01-12T18:56:01.9520969Z ##[group]Run actions/upload-artifact@master
2020-01-12T18:56:01.9521294Z name: app
2020-01-12T18:56:01.9521463Z path: ./output
2020-01-12T18:56:02.2515502Z Uploading artifact 'app' from 'd:\a\read-artifact-version-from-file\read-artifact-version-from-file\output' for run #9
2020-01-12T18:56:02.3437290Z Uploading 1 files
2020-01-12T18:56:02.6906586Z File upload complete.
2020-01-12T18:56:02.6911850Z Uploaded '8' bytes from 'd:\a\read-artifact-version-from-file\read-artifact-version-from-file\output' to server
On another note, you may also consider creating a release along with uploading an artifact. Artifacts are only made avaialable for 90 days and the amount of storage avialable for artifacts is limited by the type of GitHub account you have. Also, you might be able to share informationf or downloading releases more programatically vs sharing and/or using links to download artifacts as there’e no API at the moment to support that; you and your uses will have to go directly to the run that created the artifact and download it from there or you’ll have to manually track down the link to the artifact and share that.
Please keep the discussion going; let us know how things work out.