Skip to content

Commit

Permalink
Merge branch 'version'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Jun 26, 2021
2 parents e2ad96c + e2ede4c commit 7553e00
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 48 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/download.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ on:
push:
paths:
- 'scripts/download-actionlint.bash'
branches:
- '*'
tags-ignore:
- '*'
pull_request:
paths:
- 'scripts/download-actionlint.bash'
workflow_dispatch:

jobs:
download:
Expand All @@ -15,8 +20,9 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Download actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
- uses: actions/checkout@v2
# bash <(curl ...) is not available because it does not download the latest script just after pushing a change
- run: ./scripts/download-actionlint.bash
shell: bash
id: get_actionlint
- name: Run actionlint
Expand Down
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ before:
builds:
- <<: &build_defaults
main: ./cmd/actionlint
ldflags: -s -w -X main.version={{.Version}} -X "main.gotFrom=downloaded from release page"
env:
- CGO_ENABLED=0
id: macos
Expand Down
11 changes: 6 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ make fuzz FUZZ_FUNC=FuzzParse

When releasing v1.2.3 as example:

1. Run `./scripts/make-release-tag.bash 1.2.3`. It modifies version string in `cmd/actionlint/main.go`, make a new tag for release, and pushes them to remote
2. Wait until [the CI release job](.github/workflows/release.yaml) completes successfully:
1. Ensure all changes were already pushed to remote by checking `git push origin master` outputs `Everything up-to-date`
2. `git tag v1.2.3 && git push origin v1.2.3`
3. Wait until [the CI release job](.github/workflows/release.yaml) completes successfully:
- GoReleaser builds release binaries and make pre-release at GitHub and updates [Homebrew formula](./HomebrewFormula/actionlint.rb)
- The CI job also updates version string in `./scripts/download-actionlint.bash`
3. Open the pre-release at [release page](https://github.com/rhysd/actionlint/releases) with browser
4. Write up release notes, uncheck pre-release checkbox and publish the new release
5. Run `git pull && changelog-from-release > CHANGELOG.md` locally to update [CHANGELOG.md](./CHANGELOG.md)
4. Open the pre-release at [release page](https://github.com/rhysd/actionlint/releases) with browser
5. Write up release notes, uncheck pre-release checkbox and publish the new release
6. Run `git pull && changelog-from-release > CHANGELOG.md` locally to update [CHANGELOG.md](./CHANGELOG.md)
25 changes: 21 additions & 4 deletions cmd/actionlint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import (
"fmt"
"io/ioutil"
"os"
"runtime/debug"

"github.com/rhysd/actionlint"
)

// This constant is updated by scripts/make-release-tag.bash. Do not modify it manually.
const version = "1.2.0"
// These variables might be modified by ldflags on building release binaries by GoReleaser. Do not modify manually
var (
version = ""
gotFrom = "built from source"
)

const usageHeader = `Usage: actionlint [FLAGS] [FILES...] [-]
Expand Down Expand Up @@ -49,6 +53,19 @@ func usage() {
flag.PrintDefaults()
}

func getVersion() string {
if version != "" {
return version
}

info, ok := debug.ReadBuildInfo()
if !ok {
return "unknown" // Should be unreachable though
}

return info.Main.Version
}

func run(args []string, opts *actionlint.LinterOptions, initConfig bool) ([]*actionlint.Error, error) {
l, err := actionlint.NewLinter(os.Stdout, opts)
if err != nil {
Expand Down Expand Up @@ -100,12 +117,12 @@ func main() {
flag.BoolVar(&opts.NoColor, "no-color", false, "Disable colorful output")
flag.BoolVar(&opts.Verbose, "verbose", false, "Enable verbose output")
flag.BoolVar(&opts.Debug, "debug", false, "Enable debug output (for development)")
flag.BoolVar(&ver, "version", false, "Show version")
flag.BoolVar(&ver, "version", false, "Show version and how this binary was installed")
flag.Usage = usage
flag.Parse()

if ver {
fmt.Println(version)
fmt.Printf("%s\n%s\n", getVersion(), gotFrom)
return
}

Expand Down
37 changes: 0 additions & 37 deletions scripts/make-release-tag.bash

This file was deleted.

0 comments on commit 7553e00

Please sign in to comment.