aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/actionlint/init.lua
blob: 4d6e71bb2e6228da3b5b229d61373ea19b1bdd94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
local Pkg = require "mason-core.package"
local platform = require "mason-core.platform"
local _ = require "mason-core.functional"
local github = require "mason-core.managers.github"
local std = require "mason-core.managers.std"

local coalesce, when = _.coalesce, _.when

return Pkg.new {
    name = "actionlint",
    desc = [[Static checker for GitHub Actions workflow files]],
    homepage = "https://github.com/rhysd/actionlint",
    languages = { Pkg.Lang.YAML },
    categories = { Pkg.Cat.Linter },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        local repo = "rhysd/actionlint"
        local function format_release_file(file)
            return _.compose(_.format(file), _.gsub("^v", ""))
        end

        platform.when {
            unix = function()
                github
                    .untargz_release_file({
                        repo = repo,
                        asset_file = coalesce(
                            when(platform.is.mac_x64, format_release_file "actionlint_%s_darwin_amd64.tar.gz"),
                            when(platform.is.mac_arm64, format_release_file "actionlint_%s_darwin_arm64.tar.gz"),
                            when(platform.is.linux_x64, format_release_file "actionlint_%s_linux_amd64.tar.gz"),
                            when(platform.is.linux_arm, format_release_file "actionlint_%s_linux_armv6.tar.gz"),
                            when(platform.is.linux_arm64, format_release_file "actionlint_%s_linux_arm64.tar.gz"),
                            when(platform.is.linux_x86, format_release_file "actionlint_%s_linux_386.tar.gz")
                        ),
                    })
                    .with_receipt()
                std.chmod("+x", { "actionlint" })
            end,
            win = function()
                github
                    .unzip_release_file({
                        repo = repo,
                        asset_file = coalesce(
                            when(platform.is.win_arm64, format_release_file "actionlint_%s_windows_arm64.zip"),
                            when(platform.is.win_x64, format_release_file "actionlint_%s_windows_amd64.zip"),
                            when(platform.is.win_x86, format_release_file "actionlint_%s_windows_386.zip")
                        ),
                    })
                    .with_receipt()
            end,
        }
        ctx:link_bin("actionlint", platform.is.win and "actionlint.exe" or "actionlint")
    end,
}