Skip to content

Commit

Permalink
Add RegisterAction plugin (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
mileslucas authored Mar 18, 2021
1 parent 697c8ae commit 2ce6808
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/src/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ ColPracBadge
```@docs
Develop
Citation
RegisterAction
```

## A More Complicated Example
Expand Down
1 change: 1 addition & 0 deletions src/PkgTemplates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export
NoDeploy,
ProjectFile,
Readme,
RegisterAction,
Secret,
SrcDir,
TagBot,
Expand Down
1 change: 1 addition & 0 deletions src/plugin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,4 @@ include(joinpath("plugins", "compat_helper.jl"))
include(joinpath("plugins", "citation.jl"))
include(joinpath("plugins", "documenter.jl"))
include(joinpath("plugins", "badges.jl"))
include(joinpath("plugins", "register.jl"))
27 changes: 27 additions & 0 deletions src/plugins/register.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
RegisterAction(;
file="$(contractuser(default_file("github", "workflows", "register.yml")))",
destination="register.yml",
prompt="Version to register or component to bump",
)
Add a GitHub Actions workflow for registering a package with the General registry via workflow dispatch.
See [here](https://github.com/julia-actions/RegisterAction) for more information.
## Keyword Arguments
- `file::AbstractString`: Template file for the workflow file.
- `destination::AbstractString`: Destination of the workflow file,
relative to `.github/workflows`.
- `prompt::AbstractString`: Prompt for workflow dispatch.
"""
@plugin struct RegisterAction <: FilePlugin
file::String = default_file("github", "workflows", "register.yml")
destination::String = "register.yml"
prompt::String = "Version to register or component to bump"
end

source(p::RegisterAction) = p.file
destination(p::RegisterAction) = joinpath(".github", "workflows", p.destination)
tags(::RegisterAction) = "<<", ">>"

view(p::RegisterAction, ::Template, ::AbstractString) = Dict("PROMPT" => p.prompt)
14 changes: 14 additions & 0 deletions templates/github/workflows/register.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Register Package
on:
workflow_dispatch:
inputs:
version:
description: <<&PROMPT>>
required: true
jobs:
register:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/RegisterAction@latest
with:
token: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions test/fixtures/AllPlugins/.github/workflows/register.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Register Package
on:
workflow_dispatch:
inputs:
version:
description: Version to register or component to bump
required: true
jobs:
register:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/RegisterAction@latest
with:
token: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions test/fixtures/WackyOptions/.github/workflows/register.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Register Package
on:
workflow_dispatch:
inputs:
version:
description: gimme version
required: true
jobs:
register:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/RegisterAction@latest
with:
token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion test/reference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ end
@testset "All plugins" begin
test_all("AllPlugins"; authors=USER, plugins=[
AppVeyor(), CirrusCI(), Citation(), Codecov(), CompatHelper(), Coveralls(),
Develop(), Documenter(), DroneCI(), GitHubActions(), GitLabCI(), TravisCI(),
Develop(), Documenter(), DroneCI(), GitHubActions(), GitLabCI(), TravisCI(), RegisterAction(),
])
end

Expand Down Expand Up @@ -128,6 +128,7 @@ end
License(; name="ISC"),
ProjectFile(; version=v"1"),
Readme(; inline_badges=true, badge_off=[Codecov]),
RegisterAction(; prompt="gimme version"),
TagBot(;
trigger="OtherUser",
token=Secret("MYTOKEN"),
Expand Down

0 comments on commit 2ce6808

Please sign in to comment.