Skip to content

Commit

Permalink
Update GitHub action for releases
Browse files Browse the repository at this point in the history
Currently, the matrix configuration definitions and logic in the
'Release Info' step for which one of those configurations to use is far
apart in the main.yml file. If the matrix configuration ever changes it
can be difficult to also remember to update the 'Release Info' step,
which can lead to failed releases.

To make this error less like, this adds a new 'is_release_job' matrix
include that is set to false by default, but set to true for the one
matrix configuration that should be used for building releases. Since
these are near each other and all configured in the 'matrix' setting, it
should hopefully be easier to remember to make updates if needed. Now
matrix updates no longer require changes to the 'Release Info' step.

This also modifies the 'Release Info' step to remove the deprecated
set-output command:

https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
  • Loading branch information
stevedlawrence authored and dburgener committed Oct 5, 2023
1 parent 17347c4 commit 0fd05c3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
fail-fast: false
matrix:
cc: [ 'gcc', 'clang' ]
include:
- is_release_job: false
- is_release_job: true
cc: 'gcc'
env:
CC: ${{ matrix.cc }}
steps:
Expand Down Expand Up @@ -107,12 +111,12 @@ jobs:
- name: Release Info
id: release_info
run: |
if [[ '${{ github.ref }}' == refs/tags/v* && ${{ matrix.cc }} == 'gcc' ]]
if [[ '${{ github.ref }}' == refs/tags/v* && ${{ matrix.is_release_job }} == 'true' ]]
then
echo ::set-output name=is_release::true
echo ::set-output name=tag::$(echo ${{ github.ref }} | cut -dv -f2)
echo is_release=true >> $GITHUB_OUTPUT
echo tag=$(echo ${{ github.ref }} | cut -dv -f2) >> $GITHUB_OUTPUT
else
echo ::set-output name=is_release::false
echo is_release=false >> $GITHUB_OUTPUT
fi
shell: bash

Expand Down

0 comments on commit 0fd05c3

Please sign in to comment.