From a79c0870104326c253cf6e012a251ebb30f95e94 Mon Sep 17 00:00:00 2001 From: Chris de Graaf Date: Sat, 2 Nov 2019 20:16:47 +0700 Subject: [PATCH] Add a TagBot plugin --- .github/workflows/TagBot.yml | 12 ++++++++++++ docs/src/user.md | 1 + src/PkgTemplates.jl | 1 + src/plugin.jl | 1 + src/plugins/tagbot.jl | 19 +++++++++++++++++++ src/template.jl | 2 +- templates/github/workflows/TagBot.yml | 15 +++++++++++++++ .../AllPlugins/.github/workflows/TagBot.yml | 12 ++++++++++++ .../Basic/.github/workflows/TagBot.yml | 12 ++++++++++++ .../.github/workflows/TagBot.yml | 12 ++++++++++++ .../.github/workflows/TagBot.yml | 12 ++++++++++++ .../WackyOptions/.github/workflows/TagBot.yml | 13 +++++++++++++ test/reference.jl | 1 + test/show.jl | 3 +++ 14 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/TagBot.yml create mode 100644 src/plugins/tagbot.jl create mode 100644 templates/github/workflows/TagBot.yml create mode 100644 test/fixtures/AllPlugins/.github/workflows/TagBot.yml create mode 100644 test/fixtures/Basic/.github/workflows/TagBot.yml create mode 100644 test/fixtures/DocumenterGitHubActions/.github/workflows/TagBot.yml create mode 100644 test/fixtures/DocumenterTravis/.github/workflows/TagBot.yml create mode 100644 test/fixtures/WackyOptions/.github/workflows/TagBot.yml diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml new file mode 100644 index 0000000..150f0c4 --- /dev/null +++ b/.github/workflows/TagBot.yml @@ -0,0 +1,12 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/src/user.md b/docs/src/user.md index d2771ac..be25765 100644 --- a/docs/src/user.md +++ b/docs/src/user.md @@ -40,6 +40,7 @@ Tests Readme License Git +TagBot ``` ### Continuous Integration (CI) diff --git a/src/PkgTemplates.jl b/src/PkgTemplates.jl index 2e080db..673a6dc 100644 --- a/src/PkgTemplates.jl +++ b/src/PkgTemplates.jl @@ -28,6 +28,7 @@ export ProjectFile, Readme, SrcDir, + TagBot, Tests, TravisCI diff --git a/src/plugin.jl b/src/plugin.jl index a9f12f8..f620839 100644 --- a/src/plugin.jl +++ b/src/plugin.jl @@ -257,6 +257,7 @@ 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")) diff --git a/src/plugins/tagbot.jl b/src/plugins/tagbot.jl new file mode 100644 index 0000000..a7ca682 --- /dev/null +++ b/src/plugins/tagbot.jl @@ -0,0 +1,19 @@ +""" + TagBot(; destination="TagBot.yml", gpgsign=false) + +Adds GitHub release support via [TagBot](https://github.com/JuliaRegistries/TagBot). + +## Keyword Arguments +- `destination::AbstractString`: Destination of the worflow file, + relative to `.github/workflows`. +- `gpgsign::Bool`: Whether or not to enable GPG signing of tags. +""" +@with_kw_noshow struct TagBot <: BasicPlugin + destination::String = "TagBot.yml" + gpgsign::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_GPG" => p.gpgsign) diff --git a/src/template.jl b/src/template.jl index e3eac7b..5a920f5 100644 --- a/src/template.jl +++ b/src/template.jl @@ -1,4 +1,4 @@ -default_plugins() = [ProjectFile(), SrcDir(), Git(), License(), Readme(), Tests()] +default_plugins() = [ProjectFile(), SrcDir(), Git(), License(), Readme(), Tests(), TagBot()] default_user() = LibGit2.getconfig("github.user", "") default_version() = VersionNumber(VERSION.major) diff --git a/templates/github/workflows/TagBot.yml b/templates/github/workflows/TagBot.yml new file mode 100644 index 0000000..8609de3 --- /dev/null +++ b/templates/github/workflows/TagBot.yml @@ -0,0 +1,15 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + <<#HAS_GPG>> + gpg-key: ${{ secrets.GPG_KEY }} + <> diff --git a/test/fixtures/AllPlugins/.github/workflows/TagBot.yml b/test/fixtures/AllPlugins/.github/workflows/TagBot.yml new file mode 100644 index 0000000..150f0c4 --- /dev/null +++ b/test/fixtures/AllPlugins/.github/workflows/TagBot.yml @@ -0,0 +1,12 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: JuliaRegistries/TagBot@v1 + with: + 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..150f0c4 --- /dev/null +++ b/test/fixtures/Basic/.github/workflows/TagBot.yml @@ -0,0 +1,12 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: JuliaRegistries/TagBot@v1 + with: + 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..150f0c4 --- /dev/null +++ b/test/fixtures/DocumenterGitHubActions/.github/workflows/TagBot.yml @@ -0,0 +1,12 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: JuliaRegistries/TagBot@v1 + with: + 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..150f0c4 --- /dev/null +++ b/test/fixtures/DocumenterTravis/.github/workflows/TagBot.yml @@ -0,0 +1,12 @@ +name: TagBot +on: + schedule: + - cron: 0 * * * * +jobs: + TagBot: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: JuliaRegistries/TagBot@v1 + with: + 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..deaf74f --- /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: actions/checkout@v1 + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + gpg-key: ${{ secrets.GPG_KEY }} diff --git a/test/reference.jl b/test/reference.jl index 4af27a7..3083d6f 100644 --- a/test/reference.jl +++ b/test/reference.jl @@ -76,6 +76,7 @@ end License(; name="ISC"), ProjectFile(; version=v"1"), Readme(; inline_badges=true), + TagBot(; gpgsign=true), Tests(; project=true), TravisCI(; coverage=false, diff --git a/test/show.jl b/test/show.jl index 688e7bb..b5c197c 100644 --- a/test/show.jl +++ b/test/show.jl @@ -46,6 +46,9 @@ const LICENSES_DIR = joinpath(TEMPLATES_DIR, "licenses") inline_badges: false SrcDir: file: "$(joinpath(TEMPLATES_DIR, "src", "module.jl"))" + TagBot: + destination: "TagBot.yml" + gpgsign: false Tests: file: "$(joinpath(TEMPLATES_DIR, "test", "runtests.jl"))" project: false