aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-07-02 13:04:38 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-07-02 13:04:38 +0300
commit258e70e5e8653fecb924f2af79f43c3fca98931e (patch)
treeb950cc2581cd455dd7355be6b44bacb12639c47c
parentworkflows/test: use windows-latest (diff)
downloadsetup-gcc-258e70e5e8653fecb924f2af79f43c3fca98931e.tar.gz
setup-gcc-258e70e5e8653fecb924f2af79f43c3fca98931e.zip
test support of multiple versions
-rw-r--r--README.md36
-rw-r--r--action.yml46
2 files changed, 76 insertions, 6 deletions
diff --git a/README.md b/README.md
index 310fa60..598256b 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,9 @@ API
| Input | Value | Default | Description
| --------- | ------- | ------- | -----------
-| platform | x64 | ✓ | Install the x86_64 toolchain.
+| version | latest | ✓ | Install the latest version available in the repository.
+| | *any* | | Install a specific version if it's available (see below).
+| platform | x64 | k | Install the x86_64 toolchain.
| | *any* | | Install the i686 toolchain.
| cygwin | *any* | ✓ | Install native binaries.
| | 1 | | Install Cygwin packages.
@@ -41,6 +43,38 @@ API
| hardlinks | *any* | ✓ | Cygwin: don't convert any symlinks.
| | 1 | | Cygwin: convert symlinks in /usr/bin to hardlinks.
+Supported versions
+------------------
+
+Unless the `version` parameter value is "latest", the ubuntu-toolchain-r/test
+PPA is added to make more GCC versions available.
+Then you can pass the version number as the `version` parameter value ('4.8',
+'8', '9', etc.), and this action will install the corresponding `g++-VERSION`
+package.
+
+The `version` value is not checked for being an available version for the
+current distribution.
+The supported versions for a particular distribution are those found in the
+official repositories & those found in that distribution's series in the PPA.
+For example, the supported versions for Bionic & Focal as of July 2021 are
+listed below.
+
+| `version` | Bionic | Focal
+| --------- | ------ | -----
+| 4.8 | ✓ |
+| 5 | ✓ |
+| 6 | ✓ |
+| 7 | ✓ | ✓
+| 8 | ✓ | ✓
+| 9 | ✓ | ✓
+| 10 | ✓ | ✓
+| 11 | ✓ | ✓
+
+This table is not definitive; I expect more future versions of GCC to be made
+available in the PPA, especially for Focal.
+
+On Cygwin, the `version` parameter is ignored.
+
License
-------
diff --git a/action.yml b/action.yml
index 4704db6..761aa30 100644
--- a/action.yml
+++ b/action.yml
@@ -2,6 +2,10 @@ name: Install GCC
description: Install GCC
inputs:
+ version:
+ description: GCC version to install
+ required: false
+ default: latest
platform:
description: Target platform
required: false
@@ -18,17 +22,27 @@ inputs:
description: On Cygwin, replace executable symlinks with hardlinks
required: false
default: 0
+outputs:
+ gcc:
+ description: gcc binary name
+ value: '${{ steps.install.outputs.gcc }}'
+ gxx:
+ description: g++ binary name
+ value: '${{ steps.install.outputs.gxx }}'
runs:
using: composite
steps:
- - run: |
+ - id: install
+ run: |
New-Variable os -Value '${{ runner.os }}' -Option Constant
New-Variable linux_host -Value ($os -eq 'Linux') -Option Constant
New-Variable cygwin_host -Value ('${{ inputs.cygwin }}' -eq '1') -Option Constant
New-Variable windows_host -Value ($os -eq 'Windows' -and !$cygwin_host) -Option Constant
+ New-Variable version -Value ('${{ inputs.version }}') -Option Constant
+ New-Variable latest -Value ($version -eq 'latest') -Option Constant
New-Variable x64 -Value ('${{ inputs.platform }}' -eq 'x64') -Option Constant
function Locate-Choco {
@@ -40,6 +54,10 @@ runs:
}
}
+ function Enable-TestingPPA {
+ sudo add-apt-repository --yes --update ppa:ubuntu-toolchain-r/test
+ }
+
function Install-Package {
param(
[Parameter(Mandatory=$true, ValueFromRemainingArguments=$true)]
@@ -61,7 +79,18 @@ runs:
}
if ($linux_host) {
- $pkg = if ($x64) { 'g++' } else { 'g++-multilib' }
+ $pkg = 'g++'
+ $gcc = 'gcc'
+ $gxx = 'g++'
+ if (!$latest) {
+ Enable-TestingPPA
+ $pkg += "-$version"
+ $gcc += "-$version"
+ $gxx += "-$version"
+ }
+ if (!$x64) {
+ $pkg += '-multilib'
+ }
Install-Package $pkg
} elseif ($cygwin_host) {
if (!$x64) {
@@ -73,7 +102,11 @@ runs:
'@
}
- Install-Package gcc-g++
+ $pkg = 'gcc-g++'
+ $gcc = 'gcc'
+ $gxx = 'g++'
+
+ Install-Package $pkg
} elseif ($windows_host) {
# TODO: use setup-mingw when calling composite actions within
# composite actions is implemented.
@@ -85,6 +118,9 @@ runs:
} else {
throw "Sorry, installing GCC is unsupported on $os"
}
+
+ echo "::set-output name=gcc::$gcc"
+ echo "::set-output name=gxx::$gxx"
shell: pwsh
- run: |
@@ -119,8 +155,8 @@ runs:
}
if ($cc) {
- Link-Exe gcc cc
- Link-Exe g++ c++
+ Link-Exe '${{ steps.install.outputs.gcc }}' cc
+ Link-Exe '${{ steps.install.outputs.gxx }}' c++
}
shell: pwsh