Skip to content

Commit 92535a2

Browse files
committed
prefer document URL at specific version tag
1 parent 4c3740e commit 92535a2

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

command.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"flag"
55
"fmt"
66
"io"
7+
"regexp"
78
"runtime"
89
"runtime/debug"
910
)
@@ -25,7 +26,14 @@ const (
2526
ExitStatusFailure = 3
2627
)
2728

28-
const commandUsageHeader = `Usage: actionlint [FLAGS] [FILES...] [-]
29+
func printUsageHeader(out io.Writer) {
30+
v := getCommandVersion()
31+
b := "main"
32+
if regexp.MustCompile(`^\d+\.\d+\.\d+$`).MatchString(v) {
33+
b = "v" + v
34+
}
35+
36+
fmt.Fprintf(out, `Usage: actionlint [FLAGS] [FILES...] [-]
2937
3038
actionlint is a linter for GitHub Actions workflow files.
3139
@@ -50,9 +58,11 @@ const commandUsageHeader = `Usage: actionlint [FLAGS] [FILES...] [-]
5058
5159
Documents:
5260
53-
https://github.com/rhysd/actionlint/tree/main/docs
61+
https://github.com/rhysd/actionlint/tree/%s/docs
5462
55-
Flags:`
63+
Flags:
64+
`, b)
65+
}
5666

5767
func getCommandVersion() string {
5868
if version != "" {
@@ -143,7 +153,7 @@ func (cmd *Command) Main(args []string) int {
143153
flags.BoolVar(&ver, "version", false, "Show version and how this binary was installed")
144154
flags.StringVar(&opts.StdinFileName, "stdin-filename", "", "File name when reading input from stdin")
145155
flags.Usage = func() {
146-
fmt.Fprintln(cmd.Stderr, commandUsageHeader)
156+
printUsageHeader(cmd.Stderr)
147157
flags.PrintDefaults()
148158
}
149159
if err := flags.Parse(args[1:]); err != nil {

playground/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ <h2 class="subtitle">Static checker for GitHub Actions workflow files</h2>
6060
<h2><i id="res-icon" class="devicon-githubactions-plain"></i>Resources</h2>
6161
<p>
6262
<ul>
63-
<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>
63+
<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>
6464
<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>
6565
<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>
6666
<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>

scripts/bump-version.bash

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ sed_ "\
6262
" "$usage_doc"
6363

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

6770
echo 'Creating a version bump commit and a version tag'
6871
git add "$pre_commit_hook" "$usage_doc"

0 commit comments

Comments
 (0)