diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml new file mode 100644 index 0000000..d77d3a0 --- /dev/null +++ b/.github/workflows/TagBot.yml @@ -0,0 +1,11 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Project.toml b/Project.toml index 9a68c8f..9e17826 100644 --- a/Project.toml +++ b/Project.toml @@ -12,7 +12,8 @@ Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [compat] -Mustache = ">= 0.5.13" +Mustache = "1" +Parameters = "0.12" julia = "1" [extras] diff --git a/docs/src/user.md b/docs/src/user.md index d2771ac..ddb0a7e 100644 --- a/docs/src/user.md +++ b/docs/src/user.md @@ -40,6 +40,7 @@ Tests Readme License Git +TagBot ``` ### Continuous Integration (CI) @@ -74,6 +75,7 @@ Documenter ```@docs Develop +CompatHelper Citation ``` diff --git a/src/PkgTemplates.jl b/src/PkgTemplates.jl index 17b99d1..b0f22f2 100644 --- a/src/PkgTemplates.jl +++ b/src/PkgTemplates.jl @@ -1,7 +1,6 @@ module PkgTemplates -using Base: active_project -using Base.Filesystem: contractuser +using Base: active_project, contractuser using Dates: month, today, year using LibGit2: LibGit2, GitRemote, GitRepo @@ -18,6 +17,7 @@ export Citation, DroneCI, Codecov, + CompatHelper, Coveralls, Develop, Documenter, @@ -28,6 +28,7 @@ export ProjectFile, Readme, SrcDir, + TagBot, Tests, TravisCI diff --git a/src/plugin.jl b/src/plugin.jl index a9f12f8..1d412a5 100644 --- a/src/plugin.jl +++ b/src/plugin.jl @@ -257,8 +257,10 @@ include(joinpath("plugins", "tests.jl")) include(joinpath("plugins", "readme.jl")) include(joinpath("plugins", "license.jl")) include(joinpath("plugins", "git.jl")) +include(joinpath("plugins", "tagbot.jl")) include(joinpath("plugins", "develop.jl")) include(joinpath("plugins", "coverage.jl")) include(joinpath("plugins", "ci.jl")) +include(joinpath("plugins", "compat_helper.jl")) include(joinpath("plugins", "citation.jl")) include(joinpath("plugins", "documenter.jl")) diff --git a/src/plugins/ci.jl b/src/plugins/ci.jl index a7a1d78..a351cdc 100644 --- a/src/plugins/ci.jl +++ b/src/plugins/ci.jl @@ -29,7 +29,7 @@ Integrates your packages with [GitHub Actions](https://github.com/features/actio ## Keyword Arguments - `file::AbstractString`: Template file for the workflow file. -- `destination::AbstractString`: Destination of the worflow file, +- `destination::AbstractString`: Destination of the workflow file, relative to `.github/workflows`. - `linux::Bool`: Whether or not to run builds on Linux. - `osx::Bool`: Whether or not to run builds on OSX (MacOS). @@ -58,7 +58,6 @@ end source(p::GitHubActions) = p.file destination(p::GitHubActions) = joinpath(".github", "workflows", p.destination) - tags(::GitHubActions) = "<<", ">>" badges(::GitHubActions) = Badge( @@ -302,7 +301,6 @@ See [`Documenter`](@ref) for more information. end gitignore(p::GitLabCI) = p.coverage ? COVERAGE_GITIGNORE : String[] - source(p::GitLabCI) = p.file destination(::GitLabCI) = ".gitlab-ci.yml" diff --git a/src/plugins/compat_helper.jl b/src/plugins/compat_helper.jl new file mode 100644 index 0000000..fd23144 --- /dev/null +++ b/src/plugins/compat_helper.jl @@ -0,0 +1,25 @@ +""" + CompatHelper(; + file="$(contractuser(default_file("github", "workflows", "CompatHelper.yml")))", + destination="CompatHelper.yml", + ) + +Integrates your packages with [CompatHelper](https://github.com/bcbi/CompatHelper.jl) via GitHub Actions. + +## Keyword Arguments +- `file::AbstractString`: Template file for the workflow file. +- `destination::AbstractString`: Destination of the workflow file, + relative to `.github/workflows`. +""" +@with_kw_noshow struct CompatHelper <: BasicPlugin + file::String = default_file("github", "workflows", "CompatHelper.yml") + destination::String = "CompatHelper.yml" +end + +source(p::CompatHelper) = p.file +destination(p::CompatHelper) = joinpath(".github", "workflows", p.destination) +tags(::CompatHelper) = "<<", ">>" + +view(p::CompatHelper, t::Template, ::AbstractString) = Dict( + "VERSION" => format_version(max(v"1.2", t.julia)), +) diff --git a/src/plugins/tagbot.jl b/src/plugins/tagbot.jl new file mode 100644 index 0000000..be418b5 --- /dev/null +++ b/src/plugins/tagbot.jl @@ -0,0 +1,25 @@ +""" + TagBot(; destination="TagBot.yml", registry=nothing, dispatch=false) + +Adds GitHub release support via [TagBot](https://github.com/JuliaRegistries/TagBot). + +## Keyword Arguments +- `destination::AbstractString`: Destination of the workflow file, + relative to `.github/workflows`. +- `registry::Union{AbstractString, Nothing}`: Custom registry, in the format `owner/repo`. +- `dispatch::Bool`: Whether or not to enable the `dispatch` option. +""" +@with_kw_noshow struct TagBot <: BasicPlugin + destination::String = "TagBot.yml" + registry::Union{String, Nothing} = nothing + dispatch::Bool = false +end + +source(::TagBot) = default_file("github", "workflows", "TagBot.yml") +destination(p::TagBot) = joinpath(".github", "workflows", p.destination) +tags(::TagBot) = "<<", ">>" + +view(p::TagBot, ::Template, ::AbstractString) = Dict( + "HAS_DISPATCH" => p.dispatch, + "REGISTRY" => p.registry, +) diff --git a/src/template.jl b/src/template.jl index e3eac7b..363b7d3 100644 --- a/src/template.jl +++ b/src/template.jl @@ -1,6 +1,15 @@ -default_plugins() = [ProjectFile(), SrcDir(), Git(), License(), Readme(), Tests()] default_user() = LibGit2.getconfig("github.user", "") default_version() = VersionNumber(VERSION.major) +default_plugins() = [ + CompatHelper(), + ProjectFile(), + SrcDir(), + Git(), + License(), + Readme(), + Tests(), + TagBot(), +] function default_authors() name = LibGit2.getconfig("user.name", "") diff --git a/templates/github/workflows/CompatHelper.yml b/templates/github/workflows/CompatHelper.yml new file mode 100644 index 0000000..7a5cf86 --- /dev/null +++ b/templates/github/workflows/CompatHelper.yml @@ -0,0 +1,17 @@ +name: CompatHelper +on: + schedule: + - cron: 0 * * * * +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: julia-actions/setup-julia@latest + with: + version: <<&VERSION>> + - name: Pkg.add("CompatHelper") + run: julia -e 'using Pkg; Pkg.add("CompatHelper")' + - name: CompatHelper.main() + run: julia -e 'using CompatHelper; CompatHelper.main()' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/templates/github/workflows/TagBot.yml b/templates/github/workflows/TagBot.yml new file mode 100644 index 0000000..fd18fbd --- /dev/null +++ b/templates/github/workflows/TagBot.yml @@ -0,0 +1,17 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + <<#REGISTRY>> + registry: <<®ISTRY>> + <> + <<#HAS_DISPATCH>> + dispatch: true + <> diff --git a/test/fixtures/AllPlugins/.github/workflows/CompatHelper.yml b/test/fixtures/AllPlugins/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..e78623d --- /dev/null +++ b/test/fixtures/AllPlugins/.github/workflows/CompatHelper.yml @@ -0,0 +1,17 @@ +name: CompatHelper +on: + schedule: + - cron: 0 * * * * +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: julia-actions/setup-julia@latest + with: + version: 1.2 + - name: Pkg.add("CompatHelper") + run: julia -e 'using Pkg; Pkg.add("CompatHelper")' + - name: CompatHelper.main() + run: julia -e 'using CompatHelper; CompatHelper.main()' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/fixtures/AllPlugins/.github/workflows/TagBot.yml b/test/fixtures/AllPlugins/.github/workflows/TagBot.yml new file mode 100644 index 0000000..d77d3a0 --- /dev/null +++ b/test/fixtures/AllPlugins/.github/workflows/TagBot.yml @@ -0,0 +1,11 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/fixtures/AllPlugins/docs/Manifest.toml b/test/fixtures/AllPlugins/docs/Manifest.toml index fe71747..286113b 100644 --- a/test/fixtures/AllPlugins/docs/Manifest.toml +++ b/test/fixtures/AllPlugins/docs/Manifest.toml @@ -13,15 +13,15 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" [[DocStringExtensions]] deps = ["LibGit2", "Markdown", "Pkg", "Test"] -git-tree-sha1 = "0513f1a8991e9d83255e0140aace0d0fc4486600" +git-tree-sha1 = "88bb0edb352b16608036faadcc071adda068582a" uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" -version = "0.8.0" +version = "0.8.1" [[Documenter]] deps = ["Base64", "DocStringExtensions", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"] -git-tree-sha1 = "1b6ae3796f60311e39cd1770566140d2c056e87f" +git-tree-sha1 = "d45c163c7a3ae293c15361acc52882c0f853f97c" uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -version = "0.23.3" +version = "0.23.4" [[InteractiveUtils]] deps = ["Markdown"] @@ -48,9 +48,9 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804" [[Parsers]] deps = ["Dates", "Test"] -git-tree-sha1 = "ef0af6c8601db18c282d092ccbd2f01f3f0cd70b" +git-tree-sha1 = "c56ecb484f286639f161e712b8311f5ab77e8d32" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "0.3.7" +version = "0.3.8" [[Pkg]] deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] diff --git a/test/fixtures/Basic/.github/workflows/CompatHelper.yml b/test/fixtures/Basic/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..e78623d --- /dev/null +++ b/test/fixtures/Basic/.github/workflows/CompatHelper.yml @@ -0,0 +1,17 @@ +name: CompatHelper +on: + schedule: + - cron: 0 * * * * +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: julia-actions/setup-julia@latest + with: + version: 1.2 + - name: Pkg.add("CompatHelper") + run: julia -e 'using Pkg; Pkg.add("CompatHelper")' + - name: CompatHelper.main() + run: julia -e 'using CompatHelper; CompatHelper.main()' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/fixtures/Basic/.github/workflows/TagBot.yml b/test/fixtures/Basic/.github/workflows/TagBot.yml new file mode 100644 index 0000000..d77d3a0 --- /dev/null +++ b/test/fixtures/Basic/.github/workflows/TagBot.yml @@ -0,0 +1,11 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/fixtures/DocumenterGitHubActions/.github/workflows/CompatHelper.yml b/test/fixtures/DocumenterGitHubActions/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..e78623d --- /dev/null +++ b/test/fixtures/DocumenterGitHubActions/.github/workflows/CompatHelper.yml @@ -0,0 +1,17 @@ +name: CompatHelper +on: + schedule: + - cron: 0 * * * * +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: julia-actions/setup-julia@latest + with: + version: 1.2 + - name: Pkg.add("CompatHelper") + run: julia -e 'using Pkg; Pkg.add("CompatHelper")' + - name: CompatHelper.main() + run: julia -e 'using CompatHelper; CompatHelper.main()' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/fixtures/DocumenterGitHubActions/.github/workflows/TagBot.yml b/test/fixtures/DocumenterGitHubActions/.github/workflows/TagBot.yml new file mode 100644 index 0000000..d77d3a0 --- /dev/null +++ b/test/fixtures/DocumenterGitHubActions/.github/workflows/TagBot.yml @@ -0,0 +1,11 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/fixtures/DocumenterTravis/.github/workflows/CompatHelper.yml b/test/fixtures/DocumenterTravis/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..e78623d --- /dev/null +++ b/test/fixtures/DocumenterTravis/.github/workflows/CompatHelper.yml @@ -0,0 +1,17 @@ +name: CompatHelper +on: + schedule: + - cron: 0 * * * * +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: julia-actions/setup-julia@latest + with: + version: 1.2 + - name: Pkg.add("CompatHelper") + run: julia -e 'using Pkg; Pkg.add("CompatHelper")' + - name: CompatHelper.main() + run: julia -e 'using CompatHelper; CompatHelper.main()' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/fixtures/DocumenterTravis/.github/workflows/TagBot.yml b/test/fixtures/DocumenterTravis/.github/workflows/TagBot.yml new file mode 100644 index 0000000..d77d3a0 --- /dev/null +++ b/test/fixtures/DocumenterTravis/.github/workflows/TagBot.yml @@ -0,0 +1,11 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/fixtures/WackyOptions/.github/workflows/CompatHelper.yml b/test/fixtures/WackyOptions/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..e78623d --- /dev/null +++ b/test/fixtures/WackyOptions/.github/workflows/CompatHelper.yml @@ -0,0 +1,17 @@ +name: CompatHelper +on: + schedule: + - cron: 0 * * * * +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: julia-actions/setup-julia@latest + with: + version: 1.2 + - name: Pkg.add("CompatHelper") + run: julia -e 'using Pkg; Pkg.add("CompatHelper")' + - name: CompatHelper.main() + run: julia -e 'using CompatHelper; CompatHelper.main()' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/fixtures/WackyOptions/.github/workflows/TagBot.yml b/test/fixtures/WackyOptions/.github/workflows/TagBot.yml new file mode 100644 index 0000000..83f761a --- /dev/null +++ b/test/fixtures/WackyOptions/.github/workflows/TagBot.yml @@ -0,0 +1,13 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + registry: Foo/Bar + dispatch: true diff --git a/test/reference.jl b/test/reference.jl index 4af27a7..9e5f4db 100644 --- a/test/reference.jl +++ b/test/reference.jl @@ -39,8 +39,8 @@ end @testset "All plugins" begin test_all("AllPlugins"; authors=USER, plugins=[ - AppVeyor(), CirrusCI(), Citation(), Codecov(), Coveralls(), Develop(), - Documenter(), DroneCI(), GitHubActions(), GitLabCI(), TravisCI(), + AppVeyor(), CirrusCI(), Citation(), Codecov(), CompatHelper(), Coveralls(), + Develop(), Documenter(), DroneCI(), GitHubActions(), GitLabCI(), TravisCI(), ]) end @@ -76,6 +76,7 @@ end License(; name="ISC"), ProjectFile(; version=v"1"), Readme(; inline_badges=true), + TagBot(; registry="Foo/Bar", dispatch=true), Tests(; project=true), TravisCI(; coverage=false, diff --git a/test/runtests.jl b/test/runtests.jl index b4835d4..30cf2b2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,5 @@ -using Base.Filesystem: contractuser, path_separator +using Base: contractuser +using Base.Filesystem: path_separator using LibGit2: LibGit2, GitCommit, GitRemote, GitRepo using Pkg: Pkg, PackageSpec, TOML diff --git a/test/show.jl b/test/show.jl index 688e7bb..a3a4990 100644 --- a/test/show.jl +++ b/test/show.jl @@ -13,15 +13,6 @@ const LICENSES_DIR = joinpath(TEMPLATES_DIR, "licenses") end @testset "Template" begin - expected = """ - Template: - authors: ["Chris de Graaf "] - dir: "~/.local/share/julia/dev" - host: "github.com" - julia: v"1.0.0" - user: "$USER" - plugins: - """ expected = """ Template: authors: ["$USER"] @@ -30,6 +21,9 @@ const LICENSES_DIR = joinpath(TEMPLATES_DIR, "licenses") julia: v"1.0.0" user: "$USER" plugins: + CompatHelper: + file: "$(joinpath(TEMPLATES_DIR, "github", "workflows", "CompatHelper.yml"))" + destination: "CompatHelper.yml" Git: ignore: String[] ssh: false @@ -46,6 +40,10 @@ const LICENSES_DIR = joinpath(TEMPLATES_DIR, "licenses") inline_badges: false SrcDir: file: "$(joinpath(TEMPLATES_DIR, "src", "module.jl"))" + TagBot: + destination: "TagBot.yml" + registry: nothing + dispatch: false Tests: file: "$(joinpath(TEMPLATES_DIR, "test", "runtests.jl"))" project: false