Skip to content

Commit

Permalink
ci(release): make compiler toolchain/version configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Oct 20, 2023
1 parent 5a98a51 commit df3e7f2
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
29 changes: 23 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ on:
description: 'Branch to release from.'
required: true
type: string
compiler_toolchain:
description: 'Compiler toolchain to use. See awvwgk/setup-fortran for supported options.'
required: true
type: string
compiler_version:
description: 'Compiler version to use. See awvwgk/setup-fortran for supported versions of each toolchain.'
required: true
type: string
developmode:
description: 'Build binaries in develop mode. If false, IDEVELOPMODE is set to 0.'
required: false
Expand Down Expand Up @@ -84,8 +92,11 @@ jobs:
bash
powershell
- name: Setup Intel Fortran
uses: modflowpy/install-intelfortran-action@v1
- name: Setup ${{ inputs.compiler_toolchain }} ${{ inputs.compiler_version }}
uses: awvwgk/setup-fortran@main
with:
compiler: ${{ inputs.compiler_toolchain }}
version: ${{ inputs.compiler_version }}

- name: Set version number
id: set_version
Expand Down Expand Up @@ -278,8 +289,11 @@ jobs:
cache-downloads: true
cache-environment: true

- name: Setup Intel Fortran
uses: modflowpy/install-intelfortran-action@v1
- name: Setup ${{ inputs.compiler_toolchain }} ${{ inputs.compiler_version }}
uses: awvwgk/setup-fortran@main
with:
compiler: ${{ inputs.compiler_toolchain }}
version: ${{ inputs.compiler_version }}

- name: Update version
id: update_version
Expand Down Expand Up @@ -429,8 +443,11 @@ jobs:
bash
powershell
- name: Setup Intel Fortran
uses: modflowpy/install-intelfortran-action@v1
- name: Setup ${{ inputs.compiler_toolchain }} ${{ inputs.compiler_version }}
uses: awvwgk/setup-fortran@main
with:
compiler: ${{ inputs.compiler_toolchain }}
version: ${{ inputs.compiler_version }}

- name: Update version
id: update_version
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/release_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ on:
description: 'Branch to release from.'
required: true
type: string
compiler_toolchain:
description: 'Compiler toolchain to use. Options are gcc, intel, or intel-classic, as supported by awvwgk/setup-fortran.'
required: true
type: string
default: intel-classic
compiler_version:
description: 'Compiler version to use. See awvwgk/setup-fortran for supported versions of each toolchain.'
required: true
type: string
default: 2021.7.0
commit_version:
description: 'Commit version numbers back to the develop branch. Not considered if reset is false.'
required: false
Expand Down Expand Up @@ -53,6 +63,8 @@ jobs:
shell: bash -l {0}
outputs:
branch: ${{ steps.set_branch.outputs.branch }}
compiler_toolchain: ${{ steps.set_compiler.outputs.compiler_toolchain }}
compiler_version: ${{ steps.set_compiler.outputs.compiler_version }}
version: ${{ steps.set_version.outputs.version }}
steps:
- name: Set branch
Expand All @@ -77,6 +89,26 @@ jobs:
exit 1
fi
echo "branch=$branch" >> $GITHUB_OUTPUT
- name: Set compiler
id: set_compiler
run: |
# if compiler toolchain was provided explicitly via workflow_dispatch, use it
if [[ ("${{ github.event_name }}" == "workflow_dispatch") && (-n "${{ inputs.compiler_toolchain }}") ]]; then
compiler_toolchain="${{ inputs.compiler_toolchain }}"
compiler_version="${{ inputs.compiler_version }}"
echo "using compiler toolchain $compiler_toolchain version $compiler_version from workflow_dispatch"
elif [[ ("${{ github.event_name }}" == "push") && ("${{ github.ref_name }}" != "master") ]]; then
# if release was triggered by pushing a release branch, use the default toolchain and version
compiler_toolchain="intel-classic"
compiler_version="2021.7.0"
echo "using default compiler toolchain $compiler_toolchain version $compiler_version"
else
# otherwise exit with an error
echo "error: this workflow should not have triggered for event ${{ github.event_name }} on branch ${{ github.ref_name }}"
exit 1
fi
echo "compiler_toolchain=$compiler_toolchain" >> $GITHUB_OUTPUT
echo "compiler_version=$compiler_version" >> $GITHUB_OUTPUT
- name: Set version
id: set_version
run: |
Expand All @@ -103,6 +135,8 @@ jobs:
# If the workflow is manually triggered, the maintainer must manually set approve=true to approve a release.
# If triggered by pushing a release branch, the release is approved if the branch name doesn't contain "rc".
approve: ${{ (github.event_name == 'workflow_dispatch' && inputs.approve == 'true') || (github.event_name != 'workflow_dispatch' && !contains(github.ref_name, 'rc')) }}
compiler_toolchain: ${{ needs.set_options.outputs.compiler_toolchain }}
compiler_version: ${{ needs.set_options.outputs.compiler_version }}
branch: ${{ needs.set_options.outputs.branch }}
developmode: false
full: true
Expand Down

0 comments on commit df3e7f2

Please sign in to comment.