-
Notifications
You must be signed in to change notification settings - Fork 314
How to prevent creating multiple releases when using a build matrix? #14
Comments
There does not appear to be. And yes, it's quite annoying to clean up afterwards. In my case I'm not using a matrix, I'm instead using one job per OS - this is because each OS requires a fair amount of unique operations. I'd still like it to somehow detect that there was a pre-existing release or draft for that tag and name and skip. However I'm torn between two ways this could be done:
|
Split "Create Release" job and "Build" job, and use upload-artifact and download-artifact to transfer URL. release:
name: Create Github Release
if: contains(github.ref, 'tags/v')
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Output Release URL File
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
- name: Save Release URL File for publish
uses: actions/upload-artifact@v1
with:
name: release_url
path: release_url.txt
publish:
if: contains(github.ref, 'tags/v')
needs: [test, release]
runs-on: ubuntu-latest
strategy:
matrix:
version: [foo, bar, baz]
steps:
- uses: actions/checkout@v1
- name: Load Release URL File from release job
uses: actions/download-artifact@v1
with:
name: release_url
- name: Build
run: BUILD_COMMAND --version ${{ matrix.version }} --output ./${{ matrix.version }}
zip -r ${{ matrix.version }} ./${{ matrix.version }}
- name: Get Release File Name & Upload URL
id: get_release_info
run: |
echo ::set-output name=file_name::${REPOSITORY_NAME##*/}-${TAG_REF_NAME##*/v} # RepositoryName-v1.0.0
value=`cat release_url/release_url.txt`
echo ::set-output name=upload_url::$value
env:
TAG_REF_NAME: ${{ github.ref }}
REPOSITORY_NAME: ${{ github.repository }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ./${{ matrix.rid }}.zip
asset_name: ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.rid }}.zip
asset_content_type: application/zip |
I prefer to have the release created only if at least one of the builds succeeded. In fact I'd prefer that it only happened if all builds succeeded. But that's my preferred workflow and there might be a way to do it using a split build process like that, but these are workarounds that add additional time and load - but at least there are workarounds. Thank you @nogic1008 for the inspiration. |
I have an alternative solution, that runs in a single (defined) job, which has worked well for me. The idea is to use an extra matrix variable on the build you want to upload the release, and use conditionals for any steps that should only get run for an upload. Code
References |
Another alternative, if you don't have a preference for which matrix build triggers upload, is to skip the matrix include thing and use step conditionals like |
I recently switched to https://github.com/softprops/action-gh-release due to this problem |
One potential approach would be to create:
Then put the create release only in the all.yml
The only problem is that each platform needs the create_release upload url for it's own release: linux.yml
EDIT: found this blog post which is useful: |
Another approach is mentioned in this blog post: I got it to work for building a single release containing multiple binaries:
|
@extrawurst can you show how that Action solves this problem? I wasn't able to figure it out based on their readme. They don't seem to provide an example of use with a build matrix. I am hoping it might be possible to run three OS builds and then create a release only if all three went through and only after they all did. Is this possible with that Action? |
@TomasHubelbauer no that problem still persists if one of your builds fails the resulting artefact simply is missing |
I have a matrix which results in 3 builds. Is there a way to ensure only the first one will draft a new release?
The text was updated successfully, but these errors were encountered: