From a2f462bb0930b2a1bd97a2c0d236754f810fe39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Mon, 27 May 2024 00:01:16 +0200 Subject: [PATCH] Add support for Ubuntu 24.04 (#57) --- .github/workflows/test.main.kts | 18 +++- .github/workflows/test.yaml | 86 ++++++++++++++----- action-types.yml | 1 + action.yml | 2 +- readme/README_template.md | 1 + .../github/action/setup_wsl/Distribution.kt | 13 ++- 6 files changed, 98 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test.main.kts b/.github/workflows/test.main.kts index c4b9ca3c..7173ac7c 100755 --- a/.github/workflows/test.main.kts +++ b/.github/workflows/test.main.kts @@ -78,6 +78,13 @@ val openSuseLeap15_2 = mapOf( "default-absent-tool" to "which" ) +val ubuntu2404 = mapOf( + "wsl-id" to "Ubuntu-24.04", + "user-id" to "Ubuntu-24.04", + "match-pattern" to "*Ubuntu*24.04*", + "default-absent-tool" to "dos2unix" +) + val ubuntu2204 = mapOf( "wsl-id" to "Ubuntu", "user-id" to "Ubuntu-22.04", @@ -111,6 +118,7 @@ val distributions = listOf( alpine, kali, openSuseLeap15_2, + ubuntu2404, ubuntu2204, ubuntu2004, ubuntu1804, @@ -554,7 +562,8 @@ workflowWithCopyright( ) runAfterSuccess( name = "Test - /etc/wsl.conf should not exist", - command = "[ ! -f /etc/wsl.conf ] || { cat /etc/wsl.conf; false; }" + command = "[ ! -f /etc/wsl.conf ] || { cat /etc/wsl.conf; false; }", + conditionTransformer = { executeActionStep.successNotOnUbuntu2404Condition } ) runAfterSuccess( name = "Test - C: should be mounted at /mnt/c", @@ -1057,6 +1066,13 @@ val Step.successOnAlpineCondition && (matrix.distribution.user-id == 'Alpine') """.trimIndent() +val Step.successNotOnUbuntu2404Condition + get() = """ + always() + && (${outcome.eq(Success)}) + && (matrix.distribution.user-id != 'Ubuntu-24.04') + """.trimIndent() + fun Step.getSuccessNotOnDistributionCondition(i: Int, distribution: String) = """ always() && (${outcome.eq(Success)}) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f62bb1be..921cbe9f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -348,6 +348,10 @@ jobs: user-id: 'openSUSE-Leap-15.2' match-pattern: '*openSUSE*Leap*15.2*' default-absent-tool: 'which' + - wsl-id: 'Ubuntu-24.04' + user-id: 'Ubuntu-24.04' + match-pattern: '*Ubuntu*24.04*' + default-absent-tool: 'dos2unix' - wsl-id: 'Ubuntu' user-id: 'Ubuntu-22.04' match-pattern: '*Ubuntu*22.04*' @@ -840,6 +844,10 @@ jobs: user-id: 'openSUSE-Leap-15.2' match-pattern: '*openSUSE*Leap*15.2*' default-absent-tool: 'which' + - wsl-id: 'Ubuntu-24.04' + user-id: 'Ubuntu-24.04' + match-pattern: '*Ubuntu*24.04*' + default-absent-tool: 'dos2unix' - wsl-id: 'Ubuntu' user-id: 'Ubuntu-22.04' match-pattern: '*Ubuntu*22.04*' @@ -940,6 +948,10 @@ jobs: user-id: 'openSUSE-Leap-15.2' match-pattern: '*openSUSE*Leap*15.2*' default-absent-tool: 'which' + - wsl-id: 'Ubuntu-24.04' + user-id: 'Ubuntu-24.04' + match-pattern: '*Ubuntu*24.04*' + default-absent-tool: 'dos2unix' - wsl-id: 'Ubuntu' user-id: 'Ubuntu-22.04' match-pattern: '*Ubuntu*22.04*' @@ -996,6 +1008,7 @@ jobs: if: |- always() && (steps.step-1.outcome == 'success') + && (matrix.distribution.user-id != 'Ubuntu-24.04') - id: 'step-5' name: 'Test - C: should be mounted at /mnt/c' shell: 'wsl-bash {0}' @@ -1073,6 +1086,10 @@ jobs: user-id: 'openSUSE-Leap-15.2' match-pattern: '*openSUSE*Leap*15.2*' default-absent-tool: 'which' + - wsl-id: 'Ubuntu-24.04' + user-id: 'Ubuntu-24.04' + match-pattern: '*Ubuntu*24.04*' + default-absent-tool: 'dos2unix' - wsl-id: 'Ubuntu' user-id: 'Ubuntu-22.04' match-pattern: '*Ubuntu*22.04*' @@ -1302,6 +1319,10 @@ jobs: user-id: 'openSUSE-Leap-15.2' match-pattern: '*openSUSE*Leap*15.2*' default-absent-tool: 'which' + - wsl-id: 'Ubuntu-24.04' + user-id: 'Ubuntu-24.04' + match-pattern: '*Ubuntu*24.04*' + default-absent-tool: 'dos2unix' - wsl-id: 'Ubuntu' user-id: 'Ubuntu-22.04' match-pattern: '*Ubuntu*22.04*' @@ -1514,16 +1535,21 @@ jobs: match-pattern: '*openSUSE*Leap*15.2*' default-absent-tool: 'which' distribution5: + wsl-id: 'Ubuntu-24.04' + user-id: 'Ubuntu-24.04' + match-pattern: '*Ubuntu*24.04*' + default-absent-tool: 'dos2unix' + distribution6: wsl-id: 'Ubuntu' user-id: 'Ubuntu-20.04' match-pattern: '*Ubuntu*20.04*' default-absent-tool: 'dos2unix' - distribution6: + distribution7: wsl-id: 'Ubuntu-18.04' user-id: 'Ubuntu-18.04' match-pattern: '*Ubuntu*18.04*' default-absent-tool: 'dos2unix' - distribution7: + distribution8: wsl-id: 'Ubuntu-16.04' user-id: 'Ubuntu-16.04' match-pattern: '*Ubuntu*16.04*' @@ -1549,16 +1575,21 @@ jobs: match-pattern: '*openSUSE*Leap*15.2*' default-absent-tool: 'which' distribution5: + wsl-id: 'Ubuntu-24.04' + user-id: 'Ubuntu-24.04' + match-pattern: '*Ubuntu*24.04*' + default-absent-tool: 'dos2unix' + distribution6: wsl-id: 'Ubuntu' user-id: 'Ubuntu-22.04' match-pattern: '*Ubuntu*22.04*' default-absent-tool: 'dos2unix' - distribution6: + distribution7: wsl-id: 'Ubuntu-18.04' user-id: 'Ubuntu-18.04' match-pattern: '*Ubuntu*18.04*' default-absent-tool: 'dos2unix' - distribution7: + distribution8: wsl-id: 'Ubuntu-16.04' user-id: 'Ubuntu-16.04' match-pattern: '*Ubuntu*16.04*' @@ -1615,6 +1646,12 @@ jobs: distribution: '${{ matrix.distributions.distribution7.user-id }}' set-as-default: 'false' - id: 'step-8' + name: 'Execute action for ${{ matrix.distributions.distribution8.user-id }}' + uses: './' + with: + distribution: '${{ matrix.distributions.distribution8.user-id }}' + set-as-default: 'false' + - id: 'step-9' name: 'Test - wsl-bash_${{ matrix.distributions.distribution1.user-id }} should use the correct distribution' shell: 'wsl-bash_Debian {0}' run: |- @@ -1623,7 +1660,7 @@ jobs: if: |- always() && (steps.step-1.outcome == 'success') - - id: 'step-9' + - id: 'step-10' name: 'Test - wsl-bash_${{ matrix.distributions.distribution2.user-id }} should use the correct distribution' shell: 'wsl-bash_Alpine {0}' run: |- @@ -1632,7 +1669,7 @@ jobs: if: |- always() && (steps.step-2.outcome == 'success') - - id: 'step-10' + - id: 'step-11' name: 'Test - wsl-bash_${{ matrix.distributions.distribution3.user-id }} should use the correct distribution' shell: 'wsl-bash_kali-linux {0}' run: |- @@ -1641,7 +1678,7 @@ jobs: if: |- always() && (steps.step-3.outcome == 'success') - - id: 'step-11' + - id: 'step-12' name: 'Test - wsl-bash_${{ matrix.distributions.distribution4.user-id }} should use the correct distribution' shell: 'wsl-bash_openSUSE-Leap-15.2 {0}' run: |- @@ -1650,41 +1687,50 @@ jobs: if: |- always() && (steps.step-4.outcome == 'success') - - id: 'step-12' + - id: 'step-13' name: 'Test - wsl-bash_${{ matrix.distributions.distribution5.user-id }} should use the correct distribution' - shell: 'wsl-bash_Ubuntu-22.04 {0}' + shell: 'wsl-bash_Ubuntu-24.04 {0}' run: |- cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true) [[ "$(cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true))" == ${{ matrix.distributions.distribution5.match-pattern }} ]] if: |- always() && (steps.step-5.outcome == 'success') - && (matrix.distributions.distribution5.user-id != 'Ubuntu-20.04') - - id: 'step-13' - name: 'Test - wsl-bash_${{ matrix.distributions.distribution5.user-id }} should use the correct distribution' - shell: 'wsl-bash_Ubuntu-20.04 {0}' + - id: 'step-14' + name: 'Test - wsl-bash_${{ matrix.distributions.distribution6.user-id }} should use the correct distribution' + shell: 'wsl-bash_Ubuntu-22.04 {0}' run: |- cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true) - [[ "$(cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true))" == ${{ matrix.distributions.distribution5.match-pattern }} ]] + [[ "$(cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true))" == ${{ matrix.distributions.distribution6.match-pattern }} ]] if: |- always() - && (steps.step-5.outcome == 'success') - && (matrix.distributions.distribution5.user-id != 'Ubuntu-22.04') - - id: 'step-14' + && (steps.step-6.outcome == 'success') + && (matrix.distributions.distribution6.user-id != 'Ubuntu-20.04') + - id: 'step-15' name: 'Test - wsl-bash_${{ matrix.distributions.distribution6.user-id }} should use the correct distribution' - shell: 'wsl-bash_Ubuntu-18.04 {0}' + shell: 'wsl-bash_Ubuntu-20.04 {0}' run: |- cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true) [[ "$(cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true))" == ${{ matrix.distributions.distribution6.match-pattern }} ]] if: |- always() && (steps.step-6.outcome == 'success') - - id: 'step-15' + && (matrix.distributions.distribution6.user-id != 'Ubuntu-22.04') + - id: 'step-16' name: 'Test - wsl-bash_${{ matrix.distributions.distribution7.user-id }} should use the correct distribution' - shell: 'wsl-bash_Ubuntu-16.04 {0}' + shell: 'wsl-bash_Ubuntu-18.04 {0}' run: |- cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true) [[ "$(cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true))" == ${{ matrix.distributions.distribution7.match-pattern }} ]] if: |- always() && (steps.step-7.outcome == 'success') + - id: 'step-17' + name: 'Test - wsl-bash_${{ matrix.distributions.distribution8.user-id }} should use the correct distribution' + shell: 'wsl-bash_Ubuntu-16.04 {0}' + run: |- + cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true) + [[ "$(cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true))" == ${{ matrix.distributions.distribution8.match-pattern }} ]] + if: |- + always() + && (steps.step-8.outcome == 'success') diff --git a/action-types.yml b/action-types.yml index 2a8a10b7..cafaa218 100644 --- a/action-types.yml +++ b/action-types.yml @@ -21,6 +21,7 @@ inputs: - Debian - kali-linux - openSUSE-Leap-15.2 + - Ubuntu-24.04 - Ubuntu-22.04 - Ubuntu-20.04 - Ubuntu-18.04 diff --git a/action.yml b/action.yml index ea82c69d..39532a50 100644 --- a/action.yml +++ b/action.yml @@ -27,7 +27,7 @@ inputs: 'Ubuntu-22.04' and 'Ubuntu-20.04' can not be used together at the same time. They use the same WSL distribution ID, so the second that is used will not be installed as the first one will be found as already installed by WSL distribution ID. - Valid values: 'Alpine', 'Debian', 'kali-linux', 'openSUSE-Leap-15.2', 'Ubuntu-22.04', 'Ubuntu-20.04', 'Ubuntu-18.04', 'Ubuntu-16.04' + Valid values: 'Alpine', 'Debian', 'kali-linux', 'openSUSE-Leap-15.2', 'Ubuntu-24.04', 'Ubuntu-22.04', 'Ubuntu-20.04', 'Ubuntu-18.04', 'Ubuntu-16.04' required: false default: Debian diff --git a/readme/README_template.md b/readme/README_template.md index a2dd9867..c34a1181 100644 --- a/readme/README_template.md +++ b/readme/README_template.md @@ -156,6 +156,7 @@ The values currently supported by this action are: * `Alpine` * `kali-linux` * `openSUSE-Leap-15.2` +* `Ubuntu-24.04` * `Ubuntu-22.04` * `Ubuntu-20.04` * `Ubuntu-18.04` diff --git a/src/main/kotlin/net/kautler/github/action/setup_wsl/Distribution.kt b/src/main/kotlin/net/kautler/github/action/setup_wsl/Distribution.kt index e41f18a4..4e90526f 100644 --- a/src/main/kotlin/net/kautler/github/action/setup_wsl/Distribution.kt +++ b/src/main/kotlin/net/kautler/github/action/setup_wsl/Distribution.kt @@ -40,7 +40,8 @@ val distributions = listOf( Ubuntu1604, Ubuntu1804, Ubuntu2004, - Ubuntu2204 + Ubuntu2204, + Ubuntu2404 ).associateBy { it.userId } sealed class Distribution( @@ -246,6 +247,16 @@ abstract class AptGetBasedDistribution : Distribution { } } +object Ubuntu2404 : AptGetBasedDistribution( + wslId = "Ubuntu-24.04", + distributionName = "Ubuntu", + version = SemVer("24.4.0", jso()), + // work-around for missing shortlink on https://learn.microsoft.com/en-us/windows/wsl/install-manual#downloading-distributions + //downloadUrl = URL("https://aka.ms/wslubuntu2404"), + productId = "9nz3klhxdjp5", + installerFile = "ubuntu2404.exe" +) + object Ubuntu2204 : AptGetBasedDistribution( wslId = "Ubuntu", userId = "Ubuntu-22.04",