Skip to content

Commit

Permalink
prefer document URL at specific version tag
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed May 22, 2024
1 parent 4c3740e commit 92535a2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
18 changes: 14 additions & 4 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"io"
"regexp"
"runtime"
"runtime/debug"
)
Expand All @@ -25,7 +26,14 @@ const (
ExitStatusFailure = 3
)

const commandUsageHeader = `Usage: actionlint [FLAGS] [FILES...] [-]
func printUsageHeader(out io.Writer) {
v := getCommandVersion()
b := "main"
if regexp.MustCompile(`^\d+\.\d+\.\d+$`).MatchString(v) {
b = "v" + v
}

fmt.Fprintf(out, `Usage: actionlint [FLAGS] [FILES...] [-]
actionlint is a linter for GitHub Actions workflow files.
Expand All @@ -50,9 +58,11 @@ const commandUsageHeader = `Usage: actionlint [FLAGS] [FILES...] [-]
Documents:
https://github.com/rhysd/actionlint/tree/main/docs
https://github.com/rhysd/actionlint/tree/%s/docs
Flags:`
Flags:
`, b)
}

func getCommandVersion() string {
if version != "" {
Expand Down Expand Up @@ -143,7 +153,7 @@ func (cmd *Command) Main(args []string) int {
flags.BoolVar(&ver, "version", false, "Show version and how this binary was installed")
flags.StringVar(&opts.StdinFileName, "stdin-filename", "", "File name when reading input from stdin")
flags.Usage = func() {
fmt.Fprintln(cmd.Stderr, commandUsageHeader)
printUsageHeader(cmd.Stderr)
flags.PrintDefaults()
}
if err := flags.Parse(args[1:]); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h2 class="subtitle">Static checker for GitHub Actions workflow files</h2>
<h2><i id="res-icon" class="devicon-githubactions-plain"></i>Resources</h2>
<p>
<ul>
<li><a class="has-text-link-light" target="_blank" rel="noopener" href="https://github.com/rhysd/actionlint/blob/main/docs/checks.md">Checks by actionlint</a></li>
<li><a class="has-text-link-light" target="_blank" rel="noopener" href="https://github.com/rhysd/actionlint/blob/v1.7.0/docs/checks.md">Checks by actionlint</a></li>
<li><a class="has-text-link-light" target="_blank" rel="noopener" href="https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions">Workflow syntax for GitHub Actions</a></li>
<li><a class="has-text-link-light" target="_blank" rel="noopener" href="https://docs.github.com/en/actions/learn-github-actions/contexts">Available contexts in workflow</a></li>
<li><a class="has-text-link-light" target="_blank" rel="noopener" href="https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions">Security hardening for GitHub Actions</a></li>
Expand Down
5 changes: 4 additions & 1 deletion scripts/bump-version.bash
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ sed_ "\
" "$usage_doc"

echo "Updating $playground_html"
sed_ "s/id=\"version\">v[0-9]+\.[0-9]+\.[0-9]+/id=\"version\">v${version}/" "$playground_html"
sed_ "\
s/id=\"version\">v[0-9]+\.[0-9]+\.[0-9]+/id=\"version\">v${version}/; \
s/\/blob\/v[0-9]+\.[0-9]+\.[0-9]+\/docs\/checks\.md/\/blob\/v${version}\/docs\/checks\.md/; \
" "$playground_html"

echo 'Creating a version bump commit and a version tag'
git add "$pre_commit_hook" "$usage_doc"
Expand Down

0 comments on commit 92535a2

Please sign in to comment.