Skip to content
Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Latest commit

Β 

History

611 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GitHub Marketplace GitHub release CI License: Apache-2.0

setup-fortran

Set up Fortran compiler toolchains for GitHub Actions. Supports GNU, Intel, LLVM, NVIDIA, AMD, Arm, and LFortran compilers across Linux, macOS, and Windows.

Migration Guide

Migrating from v1 requires only a few changes:

  • The legacy compiler names gcc, intel, intel-classic, and nvidia-hpc remain supported as compatibility aliases. Migrating to the canonical names is recommended.
  • ifx configurations on macOS were previously redirected to ifort. This behavior is no longer supported; ifx on macOS will fail. Remove these configurations from your workflow matrices.
  • In 2022, oneAPI release numbers differed from compiler version numbers. For example, oneAPI 2022.1 on Windows installed ifx version 2022.2.0. Compiler versions are now used consistently, so 2022.1 is no longer listed as a supported version. Use 2022.2.0 instead.

Usage

- uses: minhqdao/setup-fortran@v2
  with:
    compiler: <compiler>
    version: <version>

Inputs

Input Description Default
compiler Compiler to install (gfortran, ifx, ifort, nvfortran, aocc, lfortran, flang, armflang) gfortran
version Compiler version to install. Enclose the version string in quotation marks (e.g. "2026.1.1" or "0.64.0") latest
msystem Windows toolchain environment (native, ucrt64, clang64) native
cleanup-disk Free up disk space by removing large pre-installed toolkits during nvfortran setup (true, false) false
update-environment Whether to export toolchain environment variables (FC, CC, CXX, FPM_*, F77, F90, FORTRAN_COMPILER) into the runner environment (true, false) true

For compatibility with fortran-lang/setup-fortran, the legacy names gcc, intel, intel-classic, and nvidia-hpc are accepted as aliases for gfortran, ifx, ifort, and nvfortran, respectively. Aliases do not change based on platform; for example, intel always resolves to ifx. Use of the canonical names is recommended.

Compiler Support

gfortran

Version ubuntu-24.04 ubuntu-22.04 ubuntu-24.04-arm ubuntu-22.04-arm macos-26 macos-26-intel macos-15 macos-15-intel macos-14 windows-2025 windows-2022 windows-2025 (ucrt64) windows-2022 (ucrt64)
latest βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
16 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
15 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
14 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
13 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
12 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
11 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

ifx

Version ubuntu-24.04 ubuntu-22.04 windows-2025 windows-2022
latest βœ“ βœ“ βœ“ βœ“
2026.1.1 βœ“ βœ“
2026.1.0 βœ“ βœ“
2026.1 βœ“ βœ“ βœ“ βœ“
2026.0 βœ“ βœ“ βœ“ βœ“
2025.3.3 βœ“ βœ“
2025.3.2 βœ“ βœ“
2025.3.1 βœ“ βœ“
2025.3.0 βœ“ βœ“
2025.3 βœ“ βœ“ βœ“ βœ“
2025.2.1 βœ“ βœ“
2025.2.0 βœ“ βœ“
2025.2 βœ“ βœ“ βœ“ βœ“
2025.1.0 βœ“ βœ“
2025.1 βœ“ βœ“ βœ“ βœ“
2025.0.0 βœ“ βœ“
2025.0 βœ“ βœ“ βœ“ βœ“
2024.2.1 βœ“ βœ“
2024.2.0 βœ“ βœ“
2024.2 βœ“ βœ“ βœ“ βœ“
2024.1.0 βœ“ βœ“
2024.1 βœ“ βœ“ βœ“ βœ“
2024.0.2 βœ“ βœ“
2024.0.1 βœ“ βœ“
2024.0 βœ“ βœ“ βœ“ βœ“
2023.2.4 βœ“ βœ“
2023.2.3 βœ“ βœ“
2023.2.2 βœ“ βœ“
2023.2.1 βœ“ βœ“ βœ“ βœ“
2023.2.0 βœ“ βœ“ βœ“ βœ“
2023.2 βœ“ βœ“ βœ“ βœ“
2023.1.0 βœ“ βœ“ βœ“ βœ“
2023.1 βœ“ βœ“ βœ“ βœ“
2023.0.0 βœ“ βœ“
2023.0 βœ“ βœ“
2022.3.0 βœ“ βœ“
2022.3 βœ“ βœ“
2022.2.1 βœ“ βœ“
2022.2.0 βœ“ βœ“ βœ“ βœ“
2022.2 βœ“ βœ“ βœ“ βœ“
2022.1.0 βœ“ βœ“
2022.1 βœ“ βœ“
2022.0.2 βœ“ βœ“
2022.0.1 βœ“ βœ“
2022.0 βœ“ βœ“
2021.4.0 βœ“ βœ“
2021.4 βœ“ βœ“
2021.3.0 βœ“ βœ“
2021.3 βœ“ βœ“
2021.2.0 βœ“ βœ“
2021.2 βœ“ βœ“
2021.1.2 βœ“ βœ“
2021.1.1 βœ“ βœ“
2021.1 βœ“ βœ“

In 2022, ifx compiler version numbers differed from oneAPI release numbers. Specify the compiler version here, not the oneAPI release number.


ifort

Version ubuntu-24.04 ubuntu-22.04 macos-26 macos-15 macos-14 macos-26-intel macos-15-intel windows-2025 windows-2022
latest βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
2021.13 βœ“ βœ“ βœ“ βœ“
2021.12 βœ“ βœ“ βœ“ βœ“
2021.11 βœ“ βœ“ βœ“ βœ“
2021.10 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
2021.9 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
2021.8 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
2021.7.1 βœ“ βœ“
2021.7 βœ“ βœ“ βœ“ βœ“
2021.6 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
2021.5 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
2021.4 βœ“ βœ“
2021.3 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
2021.2 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
2021.1.2 βœ“ βœ“
2021.1 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

Intel ships ifort for macOS as x86_64 binaries. On ARM64 runners they run under Rosetta 2, which the action verifies (and installs if missing) before installation. To keep companion C/C++ objects linkable there, the action exports CFLAGS, CXXFLAGS, and LDFLAGS with -arch x86_64.


nvfortran

Version ubuntu-24.04 ubuntu-22.04 ubuntu-24.04-arm ubuntu-22.04-arm
latest βœ“ βœ“ βœ“ βœ“
26.5 βœ“ βœ“ βœ“ βœ“
26.3 βœ“ βœ“ βœ“ βœ“
26.1 βœ“ βœ“ βœ“ βœ“
25.11 βœ“ βœ“ βœ“ βœ“
25.9 βœ“ βœ“ βœ“ βœ“
25.7 βœ“ βœ“ βœ“ βœ“
25.5 βœ“ βœ“ βœ“ βœ“
25.3 βœ“ βœ“ βœ“ βœ“
25.1 βœ“ βœ“ βœ“ βœ“
24.11 βœ“ βœ“ βœ“ βœ“
24.9 βœ“ βœ“ βœ“ βœ“
24.7 βœ“ βœ“ βœ“ βœ“
24.5 βœ“ βœ“ βœ“ βœ“
24.3 βœ“ βœ“ βœ“ βœ“
24.1 βœ“ βœ“ βœ“ βœ“
23.11 βœ“ βœ“ βœ“ βœ“
23.9 βœ“ βœ“ βœ“ βœ“
23.7 βœ“ βœ“ βœ“ βœ“
23.5 βœ“ βœ“ βœ“ βœ“
23.3 βœ“ βœ“ βœ“ βœ“
23.1 βœ“ βœ“ βœ“ βœ“
22.11 βœ“ βœ“ βœ“ βœ“
22.9 βœ“ βœ“ βœ“ βœ“
22.7 βœ“ βœ“ βœ“ βœ“
22.5 βœ“ βœ“ βœ“ βœ“
22.3 βœ“ βœ“ βœ“ βœ“
22.2 βœ“ βœ“ βœ“ βœ“
22.1 βœ“ βœ“ βœ“ βœ“
21.11 βœ“ βœ“ βœ“ βœ“
21.9 βœ“ βœ“ βœ“ βœ“
21.7 βœ“ βœ“ βœ“ βœ“
21.5 βœ“ βœ“ βœ“ βœ“
21.3 βœ“ βœ“ βœ“ βœ“
21.2 βœ“ βœ“ βœ“ βœ“
21.1 βœ“ βœ“ βœ“ βœ“
20.11 βœ“ βœ“ βœ“ βœ“
20.9 βœ“ βœ“ βœ“ βœ“
20.7 βœ“ βœ“ βœ“ βœ“

aocc

Version ubuntu-24.04 ubuntu-22.04
latest βœ“ βœ“
5.2 βœ“ βœ“
5.1 βœ“ βœ“
5.0 βœ“ βœ“
4.2 βœ“ βœ“
4.1 βœ“ βœ“

lfortran

Version ubuntu-24.04 ubuntu-22.04 ubuntu-24.04-arm ubuntu-22.04-arm macos-26 macos-26-intel macos-15 macos-15-intel macos-14 windows-2025 windows-2022 windows-2025 (ucrt64) windows-2022 (ucrt64) windows-2025 (clang64) windows-2022 (clang64)
latest βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
0.65.0 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
0.64.0 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
0.63.0 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
0.62.0 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
0.61.0 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
0.60.0 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
0.59.0 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
0.58.0 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
0.57.0 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“

flang (LLVM Flang)

Version ubuntu-24.04 ubuntu-22.04 ubuntu-24.04-arm ubuntu-22.04-arm macos-26 macos-26-intel macos-15 macos-15-intel macos-14 windows-2025 windows-2022 windows-11-arm windows-2025 (ucrt64) windows-2022 (ucrt64) windows-2025 (clang64) windows-2022 (clang64)
latest βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
23 βœ“ βœ“ βœ“ βœ“ βœ“
22 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
21 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
20 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
19 βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“ βœ“
18 βœ“ βœ“ βœ“ βœ“
17 βœ“ βœ“ βœ“ βœ“
16 βœ“

Specific patch versions (e.g. 21.1.6) are supported on macOS and native Windows runners and validated against available GitHub releases. Patch versions are not individually tested.


armflang (Arm Toolchain for Linux)

Version ubuntu-24.04-arm ubuntu-22.04-arm
latest βœ“ βœ“
22.1 βœ“ βœ“
21.1 βœ“ βœ“
20.1 βœ“ βœ“

Examples

Basic Usage

steps:
  - uses: actions/checkout@v7
  - uses: minhqdao/setup-fortran@v2
  - run: ${{ env.FC }} hello.f90

If omitted, compiler defaults to gfortran and version to the latest supported version for the platform.

Specific Version

- uses: minhqdao/setup-fortran@v2
  with:
    compiler: lfortran
    version: "0.65.0"

Matrix Build

strategy:
  matrix:
    os: [ubuntu-latest, macos-latest, windows-latest]
    toolchain:
      - { compiler: gfortran, version: "15" }
      - { compiler: ifx, version: "2026.1" }
      - { compiler: lfortran, version: "0.65.0" }
    exclude:
      - os: macos-latest
        toolchain: { compiler: ifx, version: "2026.1" }
    include:
      - os: windows-11-arm
        toolchain: { compiler: flang, version: "22" }
jobs:
  test:
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v7
      - uses: minhqdao/setup-fortran@v2
        with:
          compiler: ${{ matrix.toolchain.compiler }}
          version: ${{ matrix.toolchain.version }}
      - run: ${{ env.FC }} hello.f90

Windows with MSYS2

- uses: minhqdao/setup-fortran@v2
  with:
    compiler: lfortran
    msystem: ucrt64

Outputs

Output Description
version Resolved version of the installed compiler
fc Command or path to the Fortran compiler
cc Command or path to the C compiler
cxx Command or path to the C++ compiler

Environment Variables

Variable Description
FC Command or path to the Fortran compiler
CC Command or path to the C compiler
CXX Command or path to the C++ compiler
FPM_FC Command or path to the Fortran compiler for fpm
FPM_CC Command or path to the C compiler for fpm
FPM_CXX Command or path to the C++ compiler for fpm
F77 Command or path to the Fortran compiler (alias for FC)
F90 Command or path to the Fortran compiler (alias for FC)

Development

Requires Node.js 24 or newer (.nvmrc pins the version CI uses).

Install dependencies with npm ci.

Run npm run all to format and lint the source, run unit tests, bundle the action into dist, and run the smoke tests.

Commit changes to dist together with the source changes, as GitHub Actions executes the bundled code from this directory.

Maintenance

Adding a New Version

  1. Add the version to SUPPORTED_VERSIONS in the respective installation script (latest first).
  2. Add the version to the CI matrix for that compiler.
  3. Update the README.
  4. Run npm run all β€” it will fail if the version isn't tested or documented.

Compilers have separate installation scripts for each platform they support.

Reporting Issues

Report bugs and feature requests in the issue tracker.

License

Apache-2.0

Releases

Used by

Contributors

Languages